api-auditor.rst (24785B)
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 3.0, 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 is currently targeting protocol version **v2**. 35 36 **Version history:** 37 38 * ``v2``: Uses extensible ``records`` response envelopes, plural collection 39 paths, uniform suppression and deletion operations for diagnostics, and 40 serves the auditor WebUI below ``/webui/``. 41 42 **Upcoming versions:** 43 44 * none anticipated 45 46 **Ideas for future version:** 47 48 * ``vXXX``: marker for features not yet targeted for release 49 50 51 .. _authentication: 52 53 -------------- 54 Authentication 55 -------------- 56 57 Each auditor instance has separate authentication settings for the private API resources 58 of that instance. 59 60 Currently, the API supports two main authentication methods: 61 62 * ``external``: With this method, no checks are done by the auditor backend. 63 Instead, a reverse proxy / API gateway must do all authentication/authorization checks. 64 * ``token``: With this method, the client must provide an 65 ``Authorization: Bearer secret-token:$TOKEN`` header, where ``$TOKEN`` is 66 the configured secret authentication token. 67 68 69 ------------- 70 Auditor WebUI 71 ------------- 72 73 The auditor serves its browser-based administration interface below 74 ``/webui/``. The WebUI resources themselves are public. Private auditor API 75 resources remain subject to the authentication described above. 76 77 .. include:: auditor/get-webui.rst 78 79 .. _auditor-version: 80 81 ------------------------- 82 Obtaining Auditor Version 83 ------------------------- 84 85 This endpoint exposes protocol and implementation metadata for the auditor, 86 including the single exchange master public key configured for this auditor. 87 88 .. include:: auditor/get-config.rst 89 90 91 .. _deposit-confirmation: 92 93 --------------------- 94 Deposit Confirmations 95 --------------------- 96 97 Merchants should probabilistically submit some of the deposit 98 confirmations they receive from the exchange to auditors to ensure 99 that the exchange does not lie about recording deposit confirmations 100 with the exchange. Participating in this scheme ensures that in case 101 an exchange runs into financial trouble to pay its obligations, the 102 merchants that did participate in detecting the bad behavior can be 103 paid out first. 104 105 .. include:: auditor/put-deposit-confirmation.rst 106 107 108 .. _auditor-monitoring-spa-api: 109 110 -------------- 111 Monitoring API 112 -------------- 113 114 The following entries specify how to access the results of an audit. 115 116 For most endpoints, rows may be marked as 'suppressed' to not send them again 117 upon subsequent GET requests. To do this, a 118 :ts:type:`GenericAuditorMonitorPatchRequest` object is used in the respective 119 PATCH request. 120 121 **Details:** 122 123 .. ts:def:: GenericAuditorMonitorPatchRequest 124 125 interface GenericAuditorMonitorPatchRequest { 126 127 // If true, subsequent GET requests will not return this element by default 128 suppressed : boolean; 129 130 } 131 132 133 .. _fee-time-inconsistency-list: 134 135 Fee Time Inconsistencies 136 ------------------------ 137 138 This section highlights cases where validity periods associated with wire fees 139 the exchange may charge merchants are invalid. This usually means that the 140 validity periods given for the same type of fee are overlapping and it is thus 141 unclear which fee really applies. This is a sign of a serious 142 misconfiguration or data corruption as usually the exchange logic should 143 prevent such a fee configuration from being accepted. 144 145 .. include:: auditor/get-monitoring-fee-time-inconsistency.rst 146 147 .. include:: auditor/patch-monitoring-fee-time-inconsistency-SERIAL_ID.rst 148 149 .. _emergency-list: 150 151 Emergencies 152 ----------- 153 154 This endpoint is used to obtain a list of emergencies. 155 156 Emergencies are errors where the total value of coins deposited (of a 157 particular denomination) exceeds the total value that the exchange remembers 158 issuing. This usually means that the private keys of the exchange were 159 compromised (stolen or factored) and subsequently used to sign coins off the 160 books. If this happens, all coins of the respective denomination that the 161 exchange has redeemed so far may have been created by the attacker, and the 162 exchange would have to refund all of the outstanding coins from ordinary 163 users. Thus, the risk exposure is the amount of coins in circulation for a 164 particular denomination and the maximum loss for the exchange from this type 165 of compromise. 166 167 The difference between emergencies and emergencies by count is how the auditor 168 detected the problem: by comparing amounts, or by counting coins. 169 Theoretically, counting coins should always detect an issue first, but given 170 the importance of emergencies, the auditor checks both total amounts and total 171 numbers of coins (they may differ as coins may be partially deposited). 172 173 .. include:: auditor/get-monitoring-emergency.rst 174 175 .. include:: auditor/patch-monitoring-emergency-SERIAL_ID.rst 176 177 .. _emergency-by-count-list: 178 179 Emergencies By Count 180 -------------------- 181 182 This endpoint is used to obtain a list of emergencies by count. 183 184 Emergencies are errors where more coins were deposited than the 185 exchange remembers issuing. This usually means that the private keys 186 of the exchange were compromised (stolen or factored) and subsequently 187 used to sign coins off the books. If this happens, all coins of the 188 respective denomination that the exchange has redeemed so far may have 189 been created by the attacker, and the exchange would have to refund 190 all of the outstanding coins from ordinary users. Thus, the risk 191 exposure is the amount of coins in circulation for a particular 192 denomination and the maximum loss for the exchange from this type of 193 compromise. 194 195 Emergencies "by count" are cases where this type of money printing was 196 detected simply by counting the number of coins the exchange officially put 197 into circulation and comparing it to the number of coins that were redeemed. 198 If the number of redeemed coins is higher than the number of issued coins, the 199 auditor reports an emergency-by-count. 200 201 .. include:: auditor/get-monitoring-emergency-by-count.rst 202 203 .. include:: auditor/patch-monitoring-emergency-by-count-SERIAL_ID.rst 204 205 206 .. _row-inconsistency-list: 207 208 Row Inconsistencies 209 ------------------- 210 211 This section highlights inconsistencies in a specific row of a specific table 212 of the exchange. Row inconsistencies are reported from different sources, and 213 largely point to some kind of data corruption (or bug). Nothing is implied 214 about the seriousness of the inconsistency. Most inconsistencies are detected 215 if some signature fails to validate. The affected table is noted in the 216 'table' field. A description of the nature of the inconsistency is noted in 217 'diagnostic'. 218 219 .. include:: auditor/get-monitoring-row-inconsistency.rst 220 221 222 .. include:: auditor/patch-monitoring-row-inconsistency-SERIAL_ID.rst 223 224 .. _reserve-in-inconsistency-list: 225 226 Reserve In Inconsistencies 227 -------------------------- 228 229 This section lists cases where the exchange's and auditor's expectation of 230 amounts transferred into a reserve differs. Basically, the exchange database 231 states that a certain reserve was credited for a certain amount via a wire 232 transfer, but the auditor disagrees about this basic fact. This may result in 233 either a customer losing funds (by being issued less digital cash than they 234 should be) or the exchange losing funds (by issuing a customer more digital 235 cash than they should be). 236 237 .. include:: auditor/get-monitoring-reserve-in-inconsistency.rst 238 239 240 241 242 .. include:: auditor/patch-monitoring-reserve-in-inconsistency-SERIAL_ID.rst 243 244 245 .. _purse-not-closed-inconsistencies-list: 246 247 Purse Not Closed Inconsistencies 248 -------------------------------- 249 250 This section highlights cases, in which either payer or payee did not finish 251 their part of a P2P payment. This caused a purse --– which may contain some 252 money --- to reach its expiration date. However, the exchange failed to 253 properly expire the purse, which means the payer did not get their money back. 254 The cause is usually that the **taler-exchange-expire** helper is not running 255 properly. 256 257 258 .. include:: auditor/get-monitoring-purse-not-closed-inconsistencies.rst 259 260 261 .. include:: auditor/patch-monitoring-purse-not-closed-inconsistencies-SERIAL_ID.rst 262 263 264 Early Aggregations 265 ------------------ 266 267 .. _early-aggregation-list: 268 269 270 This endpoint returns cases in which wire transfers are encountered before their 271 justifications. This can be harmless, if the justifications appear shortly afterwards. 272 273 .. include:: auditor/get-monitoring-early-aggregation.rst 274 275 .. include:: auditor/patch-monitoring-early-aggregations-SERIAL_ID.rst 276 277 278 279 Pending Deposits 280 ---------------- 281 282 .. _pending-deposits-list: 283 284 This endpoint returns cases in which deposits are pending, that is an 285 expected wire transfer for a given deposit was not yet found even though 286 it is past the wire deadline. 287 This can be harmless, if the wire transfers appear shortly afterwards. 288 289 .. include:: auditor/get-monitoring-pending-deposits.rst 290 291 .. include:: auditor/patch-monitoring-pending-deposits-SERIAL_ID.rst 292 293 294 295 296 297 298 .. _reserve-not-closed-inconsistency-list: 299 300 Reserve Not Closed Inconsistencies 301 ---------------------------------- 302 303 This section highlights cases, in which reserves were not closed, despite being expired. 304 As a result, customers that wired funds to the exchange and then failed to withdraw them 305 are not getting their money back. The cause is usually that the **taler-exchange-closer** 306 process is not running properly. 307 308 .. include:: auditor/get-monitoring-reserve-not-closed-inconsistency.rst 309 310 311 312 313 .. include:: auditor/patch-monitoring-reserve-not-closed-inconsistency-SERIAL_ID.rst 314 315 316 317 318 .. _reserve-balance-insufficient-inconsistency-list: 319 320 Reserve Balance Insufficient Inconsistencies 321 -------------------------------------------- 322 323 This section highlights cases where more coins were withdrawn from a 324 reserve than the reserve contained funding for. This is a serious 325 compromise resulting in proportional financial losses to the exchange. 326 327 .. include:: auditor/get-monitoring-reserve-balance-insufficient-inconsistency.rst 328 329 330 331 332 333 .. include:: auditor/patch-monitoring-reserve-balance-insufficient-inconsistency-SERIAL_ID.rst 334 335 336 .. _invalid-signature-losses-list: 337 338 Invalid Signature Losses 339 ------------------------ 340 341 This section lists operations that the exchange performed, but for which the 342 signatures provided are invalid. Hence the operations are invalid and the 343 amount involved could be a loss for the exchange (as the involved parties 344 could successfully dispute the resulting transactions). 345 346 .. include:: auditor/get-monitoring-bad-sig-losses.rst 347 348 349 .. include:: auditor/patch-monitoring-bad-sig-losses-SERIAL_ID.rst 350 351 352 .. _coin-inconsistency-list: 353 354 Coin Inconsistencies 355 -------------------- 356 357 This section lists cases where the exchange made arithmetic errors found when 358 looking at the transaction history of a coin. The totals sum up the differences 359 in amounts that matter for profit/loss calculations of the exchange. When an 360 exchange merely shifted money from customers to merchants (or vice versa) without 361 any effects on its own balance, those entries are excluded from the total. 362 363 .. include:: auditor/get-monitoring-coin-inconsistency.rst 364 365 366 .. include:: auditor/patch-monitoring-coin-inconsistency-SERIAL_ID.rst 367 368 369 370 371 .. _denominations-without-signatures-list: 372 373 Denominations Without Signatures 374 -------------------------------- 375 376 This section highlights denomination keys that lack a proper 377 signature from the **taler-auditor-offline** tool. This may be 378 legitimate, say in case where the auditor's involvement in the 379 exchange business is ending and a new auditor is responsible for 380 future denominations. So this must be read with a keen eye on the 381 business situation. 382 383 .. include:: auditor/get-monitoring-denominations-without-sigs.rst 384 385 386 387 .. include:: auditor/patch-monitoring-denominations-without-sigs-SERIAL_ID.rst 388 389 390 .. _misattribution-in-inconsistency-list: 391 392 Misattribution In Inconsistencies 393 --------------------------------- 394 395 This section lists cases where the sender account record of an incoming wire 396 transfer differs between the exchange and the bank. This may cause funds to 397 be sent to the wrong account should the reserve be closed with a remaining 398 balance, as that balance would be credited to the original account. 399 400 .. include:: auditor/get-monitoring-misattribution-in-inconsistency.rst 401 402 403 404 .. include:: auditor/patch-monitoring-misattribution-in-inconsistency-SERIAL_ID.rst 405 406 407 .. _kycauth-in-inconsistency-list: 408 409 KYCAUTH In Inconsistencies 410 -------------------------- 411 412 This section lists cases where the exchange and the bank disagree about a 413 transfer that established a KYC authentication account. 414 415 .. include:: auditor/get-monitoring-kycauth-in-inconsistency.rst 416 417 .. include:: auditor/patch-monitoring-kycauth-in-inconsistency-SERIAL_ID.rst 418 419 420 421 .. _deposit-confirmations-list: 422 423 Deposit Confirmations 424 --------------------- 425 426 This section contains a list of deposits confirmations that an exchange 427 provided to merchants but *failed* to store in its own database. This is 428 indicative of potential fraud by the exchange operator, as the exchange should 429 only issue deposit confirmations after storing the respective deposit records 430 in its database. Not storing the deposit data means that the exchange would 431 not pay the merchant (pocketing the money) or allow the customer to 432 double-spend the money (which is naturally also not good). 433 434 Note that entries could appear in this list also because the exchange database 435 replication is delayed. Hence, entries that are only a few seconds old might 436 not be indicative of an actual problem. If entries in this list are more than 437 a few seconds old, the first thing to check is whether or not the database 438 replication from the exchange is working properly. 439 440 .. include:: auditor/get-monitoring-deposit-confirmations.rst 441 442 443 .. include:: auditor/patch-monitoring-deposit-confirmations-SERIAL_ID.rst 444 445 446 .. _denomination-key-validity-withdraw-inconsistency-list: 447 448 Denomination Key Validity Withdraw Inconsistencies 449 -------------------------------------------------- 450 451 This section highlights cases, where denomination keys were used to sign coins 452 withdrawn from a reserve before the denomination was valid or after it was 453 already expired for signing. This doesn't exactly imply any financial loss 454 for anyone, it is mostly weird and may have affected the fees the customer 455 paid. 456 457 .. include:: auditor/get-monitoring-denomination-key-validity-withdraw-inconsistency.rst 458 459 .. include:: auditor/patch-monitoring-denomination-key-validity-withdraw-inconsistency-SERIAL_ID.rst 460 461 .. _amount-arithmetic-inconsistency-list: 462 463 Amount Arithmetic Inconsistencies 464 --------------------------------- 465 466 This endpoint is used to obtain a list of amount arithmetic inconsistencies. 467 468 This section lists cases where the arithmetic of the exchange involving 469 amounts disagrees with the arithmetic of the auditor. Disagreements imply 470 that either the exchange made a loss (sending out too much money), or screwed 471 a customer (and thus at least needs to fix the financial damage done to the 472 customer). The profitable column is set to true if the arithmetic problem was 473 determined to be profitable for the exchange, false if the problem resulted 474 in a net loss for the exchange. 475 476 477 .. include:: auditor/get-monitoring-amount-arithmetic-inconsistency.rst 478 479 480 .. include:: auditor/patch-monitoring-amount-arithmetic-inconsistency-SERIAL_ID.rst 481 482 483 .. _wire-format-inconsistency-list: 484 485 Wire Format Inconsistencies 486 --------------------------- 487 488 This section highlights cases where the wire transfer subject 489 was used more than once and is thus not unique. This indicates 490 a problem with the bank's implementation of the revenue API, as 491 the bank is supposed to warrant uniqueness of wire transfer 492 subjects exposed via the revenue API (and bounce non-unique 493 transfers). 494 495 .. include:: auditor/get-monitoring-wire-format-inconsistency.rst 496 497 498 499 500 .. include:: auditor/patch-monitoring-wire-format-inconsistency-SERIAL_ID.rst 501 502 503 .. _aml-holds-list: 504 505 AML Holds 506 --------- 507 508 This endpoint is used to obtain a list of the wire transfers the exchange 509 aggregated but did not execute. 510 511 The exchange aggregates the deposits it owes to a merchant, decides what the 512 payout should be, records that decision, and only then makes the wire 513 transfer. Between those two steps the money is still the exchange's. An 514 ``aggregation_tracking`` row is therefore not proof that the merchant was 515 paid; a ``wire_out`` row is. This endpoint lists the transfers that are stuck 516 in between, one row per wire transfer identifier, and the row disappears once 517 the transfer is made. 518 519 The exchange has two legitimate reasons to sit on such funds. It may not pay 520 out to an account whose KYC/AML requirements are still open; and it need not 521 make a transfer whose amount would not survive the wire fee, in which case it 522 waits for further deposits to the same account. ``deferral_reason`` says which 523 of the two the exchange gave, or ``NONE`` if it gave neither. The three cases 524 are also totalled separately, as the ``total_aml_hold``, 525 ``total_small_aggregate`` and ``total_transfer_lag`` balances (see 526 :ref:`balances-list`), so that "the exchange is waiting for legitimization 527 data", "the exchange is waiting for more deposits" and "the exchange is not 528 paying" cannot be confused with each other or with having paid. 529 530 Whether a hold is *justified* is a question for a human, not for the auditor: 531 the auditor reports what is being withheld and from whom, and leaves the 532 judgement to the reader. What it does check is that the exchange does not get 533 to withhold money silently, and that the reason it gives is consistent with 534 everything else the auditor can see. 535 536 .. note:: 537 538 ``deferral_reason`` is the exchange's own statement, taken from its 539 append-only ``aggregation_deferrals`` table, which is replicated to the 540 auditor. The auditor does not overrule it, but it does check it: the amount 541 against its own recomputation of what the aggregate is worth, and a ``KYC`` 542 claim against the ``legitimization_measures`` and 543 ``legitimization_processes`` tables. If the exchange names a measure that is 544 not open, the hold is still reported as a ``KYC`` hold and a row 545 inconsistency against ``aggregation_deferrals`` is raised alongside it. An 546 exchange-internal audit (the ``-i`` option of 547 **taler-helper-auditor-transfer**) additionally compares the claim with the 548 live ``aggregation_transient`` table, which cannot be replicated. 549 550 .. include:: auditor/get-monitoring-aml-holds.rst 551 552 553 .. include:: auditor/patch-monitoring-aml-holds-SERIAL_ID.rst 554 555 556 557 558 .. _closure-lags-list: 559 560 Closure Lags 561 ------------ 562 563 This endpoint is used to obtain a list of closure lags. 564 565 A closure lag happens if a reserve should have closed a reserve and 566 wired (remaining) funds back to the originating account, but did not 567 do so on time. Significant lag may be indicative of fraud, while 568 moderate lag is indicative that the systems may be too slow to handle the 569 load. Small amounts of lag can occur in normal operation. 570 571 If closure lag is experienced, the administrator should check that 572 the **taler-exchange-closer** component is operating correctly. 573 574 575 .. include:: auditor/get-monitoring-closure-lags.rst 576 577 578 .. include:: auditor/patch-monitoring-closure-lags-SERIAL_ID.rst 579 580 581 582 583 .. _wire-out-inconsistency-list: 584 585 Wire Out Inconsistencies 586 ------------------------ 587 588 This section highlights cases where the exchange wired a different amount to a 589 destination account than the auditor expected. 590 591 .. include:: auditor/get-monitoring-wire-out-inconsistency.rst 592 593 594 595 596 597 .. include:: auditor/patch-monitoring-wire-out-inconsistency-SERIAL_ID.rst 598 599 600 .. _reserve-balance-summary-wrong-inconsistency-list: 601 602 Reserve Balance Summary Wrong Inconsistencies 603 --------------------------------------------- 604 605 This section highlights cases, where the exchange's and auditors' 606 expectation of the amount of money left in a reserve differs. 607 608 .. include:: auditor/get-monitoring-reserve-balance-summary-wrong-inconsistency.rst 609 610 .. include:: auditor/patch-monitoring-reserve-balance-summary-wrong-inconsistency-SERIAL_ID.rst 611 612 613 .. _row-minor-inconsistencies-list: 614 615 Row Minor Inconsistencies 616 ------------------------- 617 618 The section highlights inconsistencies where a row in an exchange table has a 619 value that does not satisfy expectations (such as a malformed 620 signature). These are cause for concern, but not necessarily point to a 621 monetary loss (yet). 622 623 .. include:: auditor/get-monitoring-row-minor-inconsistencies.rst 624 625 .. include:: auditor/patch-monitoring-row-minor-inconsistencies-SERIAL_ID.rst 626 627 628 ------------------------- 629 Monitoring Auditor Status 630 ------------------------- 631 632 The following entries specify how to access information the auditor keeps to 633 properly perform audits. These tables do not contain inconsistencies, instead 634 they store information about balances, reserves, purses etc. Values in these 635 tables should not differ from their respective exchanges' version. 636 637 .. _balances-list: 638 639 Balances 640 -------- 641 642 Returns the various balances the auditor tracks for the exchange, such as 643 coins in circulation, fees earned, losses experienced, etc. 644 645 Three of the keys concern money the exchange owes a merchant and has not sent. 646 Which one an amount lands in follows the reason the exchange gave for not 647 sending it: 648 649 ``total_aml_hold`` 650 The exchange says a KYC/AML requirement against the recipient is still open. 651 This is money withheld pending legitimization. 652 653 ``total_small_aggregate`` 654 The exchange says what it has collected for the account so far would not 655 cover the wire fee, so it is waiting for further deposits. This is normal 656 operation rather than an irregularity; it has a key of its own so that it 657 does not inflate the other two, which are not. 658 659 ``total_transfer_lag`` 660 The exchange gave no reason at all. This is money the exchange simply has 661 not paid out. 662 663 All three are current state rather than a running tally: the amount is 664 recomputed from the outstanding transfers on every audit run, so it falls again 665 as transfers are executed, and a transfer moves between the keys if the 666 exchange changes what it says about it. They are distinct from 667 ``total_amount_lag``, which counts deposits the exchange has not aggregated at 668 all. The individual transfers behind all three keys are listed by 669 :ref:`aml-holds-list`. 670 671 .. include:: auditor/get-monitoring-balances.rst 672 673 674 .. _historic-denomination-revenue-list: 675 676 Historic Denomination Revenue 677 ----------------------------- 678 679 This endpoint is used to obtain a list of historic denomination revenue, that 680 is the profits and losses an exchange has made from coins of a particular 681 denomination where the denomination is past its (deposit) expiration and thus 682 all values are final. 683 684 .. include:: auditor/get-monitoring-historic-denomination-revenue.rst 685 686 .. _historic-reserve-summary-list: 687 688 Historic Reserve Summary 689 ------------------------ 690 691 This section summarizes historic profits an exchange 692 made from reserves and associated reserve-specific 693 fees. 694 695 .. include:: auditor/get-monitoring-historic-reserve-summary.rst 696 697 698 .. _reserves-list: 699 700 701 Reserves 702 -------- 703 704 This endpoint is used to obtain a list of open reserves that the auditor is 705 currently tracking balances for. 706 707 .. include:: auditor/get-monitoring-reserves.rst 708 709 710 .. _purses-list: 711 712 Purses 713 ------ 714 715 This endpoint is used to obtain information about open purses. 716 717 .. include:: auditor/get-monitoring-purses.rst 718 719 Progress 720 -------- 721 722 This section contains information about the auditing progress an auditor has made. 723 724 .. include:: auditor/get-monitoring-progress.rst 725 726 727 Deleting Monitoring Records 728 --------------------------- 729 730 Deleting a monitoring record is intended for administrative cleanup after the 731 underlying issue has been resolved. Suppression should be preferred when the 732 audit history should remain available. 733 734 .. include:: auditor/delete-monitoring-records.rst