api-auditor.rst (20493B)
1 .. 2 This file is part of GNU TALER. 3 Copyright (C) 2018-2024 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 2.1, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 16 @author Christian Grothoff 17 18 =================== 19 Auditor RESTful API 20 =================== 21 22 The API specified here follows the :ref:`general conventions <http-common>` 23 for all details not specified in the individual requests. 24 The `glossary <https://docs.taler.net/taler-developer-manual.html#developer-glossary>`_ 25 defines all specific terms used in this section. 26 27 28 --------------- 29 Version History 30 --------------- 31 32 The current protocol version is **v2**. 33 34 * The auditor SPA currently targeting protocol version **v1**. 35 36 **Version history:** 37 38 * ``v2``: Adds a few additional GET endpoints to expose more auditor data 39 40 **Upcoming versions:** 41 42 * none anticipated 43 44 **Ideas for future version:** 45 46 * ``vXXX``: marker for features not yet targeted for release 47 48 49 .. _authentication: 50 51 -------------- 52 Authentication 53 -------------- 54 55 Each auditor instance has separate authentication settings for the private API resources 56 of that instance. 57 58 Currently, the API supports two main authentication methods: 59 60 * ``external``: With this method, no checks are done by the auditor backend. 61 Instead, a reverse proxy / API gateway must do all authentication/authorization checks. 62 * ``token``: With this method, the client must provide a ``Authorization: Bearer $TOKEN`` 63 header, where ``$TOKEN`` is a secret authentication token configured for the instance which must begin with the RFC 8959 prefix. 64 65 .. _auditor-version: 66 67 ------------------------- 68 Obtaining Auditor Version 69 ------------------------- 70 71 This endpoint is used by merchants to obtain a list of all exchanges audited by 72 this auditor. This may be required for the merchant to perform the required 73 know-your-customer (KYC) registration before issuing contracts. 74 75 .. include:: auditor/get-config.rst 76 77 78 .. _deposit-confirmation: 79 80 --------------------- 81 Deposit Confirmations 82 --------------------- 83 84 Merchants should probabilistically submit some of the deposit 85 confirmations they receive from the exchange to auditors to ensure 86 that the exchange does not lie about recording deposit confirmations 87 with the exchange. Participating in this scheme ensures that in case 88 an exchange runs into financial trouble to pay its obligations, the 89 merchants that did participate in detecting the bad behavior can be 90 paid out first. 91 92 .. include:: auditor/put-deposit-confirmation.rst 93 94 95 .. _auditor-monitoring-spa-api: 96 97 -------------- 98 Monitoring API 99 -------------- 100 101 The following entries specify how to access the results of an audit. 102 103 For most endpoints, rows may be marked as 'suppressed' to not send them again 104 upon subsequent GET requests. To do this, a 105 :ts:type:`GenericAuditorMonitorPatchRequest` object is used in the respective 106 PATCH request. 107 108 **Details:** 109 110 .. ts:def:: GenericAuditorMonitorPatchRequest 111 112 interface GenericAuditorMonitorPatchRequest { 113 114 // If true, subsequent GET requests will not return this element by default 115 suppressed : boolean; 116 117 } 118 119 120 .. _fee-time-inconsistency-list: 121 122 Fee Time Inconsistencies 123 ------------------------ 124 125 This section highlights cases where validity periods associated with wire fees 126 the exchange may charge merchants are invalid. This usually means that the 127 validity periods given for the same type of fee are overlapping and it is thus 128 unclear which fee really applies. This is a sign of a serious 129 misconfiguration or data corruption as usually the exchange logic should 130 prevent such a fee configuration from being accepted. 131 132 .. include:: auditor/get-monitoring-fee-time-inconsistency.rst 133 134 .. include:: auditor/patch-monitoring-fee-time-inconsistency-SERIAL_ID.rst 135 136 .. _emergency-list: 137 138 Emergencies 139 ----------- 140 141 This endpoint is used to obtain a list of emergencies. 142 143 Emergencies are errors where the total value of coins deposited (of a 144 particular denomination) exceeds the total value that the exchange remembers 145 issuing. This usually means that the private keys of the exchange were 146 compromised (stolen or factored) and subsequently used to sign coins off the 147 books. If this happens, all coins of the respective denomination that the 148 exchange has redeemed so far may have been created by the attacker, and the 149 exchange would have to refund all of the outstanding coins from ordinary 150 users. Thus, the risk exposure is the amount of coins in circulation for a 151 particular denomination and the maximum loss for the exchange from this type 152 of compromise. 153 154 The difference between emergencies and emergencies by count is how the auditor 155 detected the problem: by comparing amounts, or by counting coins. 156 Theroretically, counting coins should always detect an issue first, but given 157 the importance of emergencies, the auditor checks both total amounts and total 158 numbers of coins (they may differ as coins may be partially deposited). 159 160 .. include:: auditor/get-monitoring-emergency.rst 161 162 .. include:: auditor/patch-monitoring-emergency-SERIAL_ID.rst 163 164 .. _emergency-by-count-list: 165 166 Emergencies By Count 167 -------------------- 168 169 This endpoint is used to obtain a list of emergencies by count. 170 171 Emergencies are errors where more coins were deposited than the 172 exchange remembers issuing. This usually means that the private keys 173 of the exchange were compromised (stolen or factored) and subsequently 174 used to sign coins off the books. If this happens, all coins of the 175 respective denomination that the exchange has redeemed so far may have 176 been created by the attacker, and the exchange would have to refund 177 all of the outstanding coins from ordinary users. Thus, the risk 178 exposure is the amount of coins in circulation for a particular 179 denomination and the maximum loss for the exchange from this type of 180 compromise. 181 182 Emergencies "by count" are cases where this type of money printing was 183 detected simply by counting the number of coins the exchange officially put 184 into circulation and comparing it to the number of coins that were redeemed. 185 If the number of redeemed coins is higher than the number of issued coins, the 186 auditor reports an emergency-by-count. 187 188 .. include:: auditor/get-monitoring-emergency-by-count.rst 189 190 .. include:: auditor/patch-monitoring-emergency-by-count-SERIAL_ID.rst 191 192 193 .. _row-inconsistency-list: 194 195 Row Inconsistencies 196 ------------------- 197 198 This section highlights inconsistencies in a specific row of a specific table 199 of the exchange. Row inconsistencies are reported from different sources, and 200 largely point to some kind of data corruption (or bug). Nothing is implied 201 about the seriousness of the inconsistency. Most inconsistencies are detected 202 if some signature fails to validate. The affected table is noted in the 203 'table' field. A description of the nature of the inconsistency is noted in 204 'diagnostic'. 205 206 .. include:: auditor/get-monitoring-row-inconsistency.rst 207 208 209 .. include:: auditor/patch-monitoring-row-inconsistency-SERIAL_ID.rst 210 211 .. _reserve-in-inconsistency-list: 212 213 Reserve In Inconsistencies 214 -------------------------- 215 216 This section lists cases where the exchange's and auditor's expectation of 217 amounts transferred into a reserve differs. Basically, the exchange database 218 states that a certain reserve was credited for a certain amount via a wire 219 transfer, but the auditor disagrees about this basic fact. This may result in 220 either a customer loosing funds (by being issued less digital cash than they 221 should be) or the exchange loosing funds (by issuing a customer more digital 222 cash than they should be). 223 224 .. include:: auditor/get-monitoring-reserve-in-inconsistency.rst 225 226 227 228 229 .. include:: auditor/patch-monitoring-reserve-in-inconsistency-SERIAL_ID.rst 230 231 232 .. _purse-not-closed-inconsistencies-list: 233 234 Purse Not Closed Inconsistencies 235 -------------------------------- 236 237 This section highlights cases, in which either payer or payee did not finish 238 their part of a P2P payment. This caused a purse --– which may contain some 239 money --- to reach its expiration date. However, the exchange failed to 240 properly expire the purse, which means the payer did not get their money back. 241 The cause is usually that the **taler-exchange-expire** helper is not running 242 properly. 243 244 245 .. include:: auditor/get-monitoring-purse-not-closed-inconsistencies.rst 246 247 248 .. include:: auditor/patch-monitoring-purse-not-closed-inconsistencies-SERIAL_ID.rst 249 250 251 Early Aggregations 252 ------------------ 253 254 .. _early-aggregation-list: 255 256 257 This endpoint returns cases in which wire transfers are encountered before their 258 justifications. This can be harmless, if the justifications appear shortly afterwards. 259 260 .. include:: auditor/get-monitoring-early-aggregation.rst 261 262 263 264 Pending Deposits 265 ---------------- 266 267 .. _pending-deposits-list: 268 269 This endpoint returns cases in which deposits are pending, that is an 270 expected wire transfer for a given deposit was not yet found even though 271 it is past the wire deadline. 272 This can be harmless, if the wire transfers appear shortly afterwards. 273 274 .. include:: auditor/get-monitoring-pending-deposits.rst 275 276 277 278 279 280 281 .. _reserve-not-closed-inconsistency-list: 282 283 Reserve Not Closed Inconsistencies 284 ---------------------------------- 285 286 This section highlights cases, in which reserves were not closed, despite being expired. 287 As a result, customers that wired funds to the exchange and then failed to withdraw them 288 are not getting their money back. The cause is usually that the **taler-exchange-closer** 289 process is not running properly. 290 291 .. include:: auditor/get-monitoring-reserve-not-closed-inconsistency.rst 292 293 294 295 296 .. include:: auditor/patch-monitoring-reserve-not-closed-inconsistency-SERIAL_ID.rst 297 298 299 300 301 .. _reserve-balance-insufficient-inconsistency-list: 302 303 Reserve Balance Insufficient Inconsistencies 304 -------------------------------------------- 305 306 This section highlights cases where more coins were withdrawn from a 307 reserve than the reserve contained funding for. This is a serious 308 compromise resulting in proportional financial losses to the exchange. 309 310 .. include:: auditor/get-monitoring-reserve-balance-insufficient-inconsistency.rst 311 312 313 314 315 316 .. include:: auditor/patch-monitoring-reserve-balance-insufficient-inconsistency-SERIAL_ID.rst 317 318 319 .. _invalid-signature-losses-list: 320 321 Invalid Signature Losses 322 ------------------------ 323 324 This section lists operations that the exchange performed, but for which the 325 signatures provided are invalid. Hence the operations are invalid and the 326 amount involved could be a loss for the exchange (as the involved parties 327 could successfully dispute the resulting transactions). 328 329 .. include:: auditor/get-monitoring-bad-sig-losses.rst 330 331 332 .. include:: auditor/patch-monitoring-bad-sig-losses-SERIAL_ID.rst 333 334 335 .. _coin-inconsistency-list: 336 337 Coin Inconsistencies 338 -------------------- 339 340 This section lists cases where the exchange made arithmetic errors found when 341 looking at the transaction history of a coin. The totals sum up the differences 342 in amounts that matter for profit/loss calculations of the exchange. When an 343 exchange merely shifted money from customers to merchants (or vice versa) without 344 any effects on its own balance, those entries are excluded from the total. 345 346 .. include:: auditor/get-monitoring-coin-inconsistency.rst 347 348 349 .. include:: auditor/patch-monitoring-coin-inconsistency-SERIAL_ID.rst 350 351 352 353 354 .. _denominations-without-signatures-list: 355 356 Denominations Without Signatures 357 -------------------------------- 358 359 This section highlights denomination keys that lack a proper 360 signature from the **taler-auditor-offline** tool. This may be 361 legitimate, say in case where the auditor's involvement in the 362 exchange business is ending and a new auditor is responsible for 363 future denominations. So this must be read with a keen eye on the 364 business situation. 365 366 .. include:: auditor/get-monitoring-denominations-without-sigs.rst 367 368 369 370 .. include:: auditor/patch-monitoring-denominations-without-sigs-SERIAL_ID.rst 371 372 373 .. _misattribution-in-inconsistency-list: 374 375 Misattribution In Inconsistencies 376 --------------------------------- 377 378 This section lists cases where the sender account record of an incoming wire 379 transfer differs between the exchange and the bank. This may cause funds to 380 be sent to the wrong account should the reserve be closed with a remaining 381 balance, as that balance would be credited to the original account. 382 383 .. include:: auditor/get-monitoring-misattribution-in-inconsistency.rst 384 385 386 387 .. include:: auditor/patch-monitoring-misattribution-in-inconsistency-SERIAL_ID.rst 388 389 390 391 .. _deposit-confirmations-list: 392 393 Deposit Confirmations 394 --------------------- 395 396 This section contains a list of deposits confirmations that an exchange 397 provided to merchants but *failed* to store in its own database. This is 398 indicative of potential fraud by the exchange operator, as the exchange should 399 only issue deposit confirmations after storing the respective deposit records 400 in its database. Not storing the deposit data means that the exchange would 401 not pay the merchant (pocketing the money) or allow the customer to 402 double-spend the money (which is naturally also not good). 403 404 Note that entries could appear in this list also because the exchange database 405 replication is delayed. Hence, entries that are only a few seconds old might 406 not be indicative of an actual problem. If entries in this list are more than 407 a few seconds old, the first thing to check is whether or not the database 408 replication from the exchange is working properly. 409 410 .. include:: auditor/get-monitoring-deposit-confirmations.rst 411 412 413 .. include:: auditor/patch-monitoring-deposit-confirmations-SERIAL_ID.rst 414 415 416 .. _denomination-key-validity-withdraw-inconsistency-list: 417 418 Denomination Key Validity Withdraw Inconsistencies 419 -------------------------------------------------- 420 421 This section highlights cases, where denomination keys were used to sign coins 422 withdrawn from a reserve before the denomination was valid or after it was 423 already expired for signing. This doesn't exactly imply any financial loss 424 for anyone, it is mostly weird and may have affected the fees the customer 425 paid. 426 427 .. include:: auditor/get-monitoring-denomination-key-validity-withdraw-inconsistency.rst 428 429 .. include:: auditor/patch-monitoring-denomination-key-validity-withdraw-inconsistency-SERIAL_ID.rst 430 431 .. _amount-arithmetic-inconsistency-list: 432 433 Amount Arithmetic Inconsistencies 434 --------------------------------- 435 436 This endpoint is used to obtain a list of amount arithmetic inconsistencies. 437 438 This section lists cases where the arithmetic of the exchange involving 439 amounts disagrees with the arithmetic of the auditor. Disagreements imply 440 that either the exchange made a loss (sending out too much money), or screwed 441 a customer (and thus at least needs to fix the financial damage done to the 442 customer). The profitable column is set to true if the arithmetic problem was 443 be determined to be profitable for the exchange, false if the problem resulted 444 in a net loss for the exchange. 445 446 447 .. include:: auditor/get-monitoring-amount-arithmetic-inconsistency.rst 448 449 450 .. include:: auditor/patch-monitoring-amount-arithmetic-inconsistency-SERIAL_ID.rst 451 452 453 .. _wire-format-inconsistency-list: 454 455 Wire Format Inconsistencies 456 --------------------------- 457 458 This section highlights cases where the wire transfer subject 459 was used more than once and is thus not unique. This indicates 460 a problem with the bank's implementation of the revenue API, as 461 the bank is supposed to warrant uniqueness of wire transfer 462 subjects exposed via the revenue API (and bounce non-unique 463 transfers). 464 465 .. include:: auditor/get-monitoring-wire-format-inconsistency.rst 466 467 468 469 470 .. include:: auditor/patch-monitoring-wire-format-inconsistency-SERIAL_ID.rst 471 472 473 .. _closure-lags-list: 474 475 Closure Lags 476 ------------ 477 478 This endpoint is used to obtain a list of closure lags. 479 480 A closure lag happens if a reserve should have closed a reserve and 481 wired (remaining) funds back to the originating account, but did not 482 do so on time. Significant lag may be indicative of fraud, while 483 moderate lag is indicative that the systems may be too slow to handle the 484 load. Small amounts of lag can occur in normal operation. 485 486 If closure lag is experienced, the administrator should check that 487 the **taler-exchange-closer** component is operating correctly. 488 489 490 .. include:: auditor/get-monitoring-closure-lags.rst 491 492 493 .. include:: auditor/patch-monitoring-closure-lags-SERIAL_ID.rst 494 495 496 497 498 .. _wire-out-inconsistency-list: 499 500 Wire Out Inconsistencies 501 ------------------------ 502 503 This section highlights cases where the exchange wired a different amount to a 504 destimation account than the auditor expected. 505 506 .. include:: auditor/get-monitoring-wire-out-inconsistency.rst 507 508 509 510 511 512 .. include:: auditor/patch-monitoring-wire-out-inconsistency-SERIAL_ID.rst 513 514 515 .. _reserve-balance-summary-wrong-inconsistency-list: 516 517 Reserve Balance Summary Wrong Inconsistencies 518 --------------------------------------------- 519 520 This section highlights cases, where the exchange's and auditors' 521 expectation of the amount of money left in a reserve differs. 522 523 .. include:: auditor/get-monitoring-reserve-balance-summary-wrong-inconsistency.rst 524 525 .. include:: auditor/patch-monitoring-reserve-balance-summary-wrong-inconsistency-SERIAL_ID.rst 526 527 528 .. _row-minor-inconsistencies-list: 529 530 Row Minor Inconsistencies 531 ------------------------- 532 533 The section highlights inconsistencies where a row in an exchange table has a 534 value that is does not satisfy expectations (such as a malformed 535 signature). These are cause for concern, but not necessarily point to a 536 monetary loss (yet). 537 538 .. include:: auditor/get-monitoring-row-minor-inconsistencies.rst 539 540 .. include:: auditor/patch-monitoring-row-minor-inconsistencies-SERIAL_ID.rst 541 542 543 ------------------------- 544 Monitoring Auditor Status 545 ------------------------- 546 547 The following entries specify how to access information the auditor keeps to 548 properly perform audits. These tables do not contain inconsistencies, instead 549 they store information about balances, reserves, purses etc. Values in these 550 tables should not differ from their respective exchanges' version. 551 552 .. _balances-list: 553 554 Balances 555 -------- 556 557 Returns the various balances the auditor tracks for the exchange, such as 558 coins in circulation, fees earned, losses experienced, etc. 559 560 .. include:: auditor/get-monitoring-balances.rst 561 562 563 .. _historic-denomination-revenue-list: 564 565 Historic Denomination Revenue 566 ----------------------------- 567 568 This endpoint is used to obtain a list of historic denomination revenue, that 569 is the profits and losses an exchange has made from coins of a particular 570 denomination where the denomination is past its (deposit) expiration and thus 571 all values are final. 572 573 .. include:: auditor/get-monitoring-historic-denomination-revenue.rst 574 575 .. _denomination-pending-list: 576 577 Denomination Pending 578 -------------------- 579 580 This endpoint is used to obtain a list of balances for denominations that are still 581 active, that is coins may still be deposited (or possibly even withdrawn) and thus 582 the amounts given are not final. 583 584 .. include:: auditor/get-monitoring-denomination-pending.rst 585 586 587 .. _historic-reserve-summary-list: 588 589 Historic Reserve Summary 590 ------------------------ 591 592 This section summarizes historic profits an exchange 593 made from reserves and associated reserve-specific 594 fees. 595 596 .. include:: auditor/get-monitoring-historic-reserve-summary.rst 597 598 599 .. _reserves-list: 600 601 602 Reserves 603 -------- 604 605 This endpoint is used to obtain a list of open reserves that the auditor is 606 currently tracking balances for. 607 608 .. include:: auditor/get-monitoring-reserves.rst 609 610 611 .. _purses-list: 612 613 Purses 614 ------ 615 616 This endpoint is used to obtain information about open purses. 617 618 .. include:: auditor/get-monitoring-purses.rst 619 620 Progress 621 -------- 622 623 This section contains information about the auditing progress an auditor has made. 624 625 .. include:: auditor/get-monitoring-progress.rst 626 627 ---------- 628 Complaints 629 ---------- 630 631 This endpoint is used by the wallet or merchants to submit proof of 632 misbehavior of an exchange to the auditor. 633 634 .. note:: 635 636 To be designed and implemented. 637 638 .. include:: auditor/put-complain.rst 639 640 Complain about misbehavior to the auditor.