Skip to content

Commit e223b7b

Browse files
authored
be: read the banks known from public samples, trusting dnssec instead of a pin (#63)
1 parent 20828eb commit e223b7b

20 files changed

Lines changed: 104 additions & 48 deletions

File tree

‎.docs/banks/README.md‎

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
# Banks
22

33
Which banks the library reads, and what it reads from each. Every bank has a page of its own with the template, the
4-
setup and what has not been seen yet, in a folder per country: `cz/<bank>/`, and `sk/<bank>/` once a Slovak bank is
5-
read; another country is another folder. This page only says where each one stands, and changes with every bank's pull
6-
request.
4+
setup and what has not been seen yet, in a folder per country: `cz/<bank>/` and `sk/<bank>/`; another country is
5+
another folder. This page only says where each one stands, and changes with every bank's pull request.
76

87
A bank is in one of three states:
98

109
- **Verified**: read from real e-mails, its DKIM key pinned and checked daily. `read()` returns a `Transaction`.
1110
- **Samples only**: the template follows public code ([radekhulan/myinvoice](https://github.com/radekhulan/myinvoice),
12-
MIT), not a real e-mail, and no key is pinned. `read()` refuses every e-mail from it as `Unverified`, naming the key
13-
DNS gave, until a real e-mail confirms the template and that key.
11+
[tomaj/bank-mails-parser](https://github.com/tomaj/bank-mails-parser), MIT), not a real e-mail, and no key is pinned.
12+
`read()` returns a `Transaction` once the signature verifies with any key DNSSEC proves the bank's domain published;
13+
ČSOB SK, whose domain has no DNSSEC, stays `Unverified`. A real e-mail moves it to verified and pins its key.
1414
- **Not yet**: no parser.
1515

16+
The tables list every bank in the central bank's register of payment codes: [ČNB](https://www.cnb.cz/cs/platebni-styk/ucty-kody-bank/)
17+
and [NBS](https://nbs.sk/en/payments/general-information/directories-and-registers/directory-identification-codes-domestic-payment-system-in-sr/),
18+
read on 2026-11-24. Left out are those that hold no account a payment arrives on: the central banks, building societies
19+
(stavební spořitelny), development and export banks (Národní rozvojová banka, Česká exportní banka, SZRB, EXIMBANKA SR),
20+
ČSOB Hypoteční banka, Štátna pokladnica, Sberbank CZ in liquidation, consumer lenders (COFIDIS, BNP Paribas Personal
21+
Finance) and payment institutions that are not banks (Banking Circle, Comgate, Trust Pay and the like).
22+
1623
## Czechia
1724

1825
| Bank | State | Reads | Leaves out | Details |
@@ -28,6 +35,26 @@ A bank is in one of three states:
2835
| Česká spořitelna | not yet | | | [#15](https://github.com/landsman/bank-java/issues/15) |
2936
| Citfin | not yet | | | [#21](https://github.com/landsman/bank-java/issues/21) |
3037
| Partners Banka | not yet | | sends no e-mail at all | [#25](https://github.com/landsman/bank-java/issues/25) |
38+
| mBank | not yet | | | |
39+
| J&T BANKA | not yet | | | |
40+
| PPF banka | not yet | | | |
41+
| TRINITY BANK | not yet | | | |
42+
| ING Bank | not yet | | | |
43+
| PKO BP | not yet | | | |
44+
| Citibank Europe | not yet | | | |
45+
| Deutsche Bank | not yet | | | |
46+
| COMMERZBANK | not yet | | | |
47+
| BNP Paribas | not yet | | | |
48+
| HSBC Continental Europe | not yet | | | |
49+
| Všeobecná úverová banka, pobočka Praha | not yet | | | |
50+
| Oberbank | not yet | | | |
51+
| Volksbank Raiffeisenbank Nordoberpfalz, pobočka Cheb | not yet | | | |
52+
| Bank of China (CEE) | not yet | | | |
53+
| Bank of Communications | not yet | | | |
54+
| Industrial and Commercial Bank of China | not yet | | | |
55+
| Multitude Bank | not yet | | | |
56+
| Artesa, spořitelní družstvo | not yet | | | |
57+
| Peněžní dům, spořitelní družstvo | not yet | | | |
3158

3259
## Slovakia
3360

@@ -37,7 +64,21 @@ A bank is in one of three states:
3764
| ČSOB | samples only | incoming SEPA credits; IBANs, name, symbols from the payer's reference, message | outgoing payments, transaction id; the 2019 sample was not DKIM-signed and `csob.sk` has no DNSSEC | [csob](sk/csob/README.md) |
3865
| Slovenská sporiteľňa | not yet | | | [#23](https://github.com/landsman/bank-java/issues/23) |
3966
| Tatra banka | samples only | credits and debits; transaction id and direction from the signed subject, IBAN, name, symbols from the payer's reference, balance | counter-account, type; its 2019 key is published but not pinned | [tatra](sk/tatra/README.md) |
67+
| Všeobecná úverová banka (VÚB) | not yet | | | |
68+
| Prima banka | not yet | | | |
69+
| UniCredit Bank, pobočka | not yet | | | |
70+
| mBank, pobočka | not yet | | | |
71+
| J&T BANKA, pobočka | not yet | | | |
72+
| Komerční banka, pobočka | not yet | | | |
73+
| Penta Bank | not yet | | | |
74+
| ING Bank, pobočka | not yet | | | |
75+
| Citibank Europe, pobočka | not yet | | | |
76+
| Commerzbank, pobočka | not yet | | | |
77+
| Oberbank, pobočka | not yet | | | |
78+
| BKS Bank, pobočka | not yet | | | |
79+
| PKO BP, pobočka | not yet | | | |
80+
| KDB Bank Europe, pobočka | not yet | | | |
4081

4182
What a missing transaction id means for deduplication, and a masked account for knowing whose payment it is:
42-
[using the library](../usage.md#two-checks-stay-with-you). A bank that is not yet read has an issue collecting what is
43-
known and which samples are needed; an e-mail from it is `Unparsed` with `reason()` `NOT_A_BANK_EMAIL`.
83+
[using the library](../usage.md#two-checks-stay-with-you). A bank that is not yet read gets an issue collecting what is
84+
known and which samples are needed once someone asks for it; an e-mail from it is `Unparsed` with `reason()` `NOT_A_BANK_EMAIL`.

‎.docs/banks/cz/creditas/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
**Not seen as a real e-mail yet (2026-11-10).** The parser follows the sanitised samples in
44
[radekhulan/myinvoice](https://github.com/radekhulan/myinvoice/blob/master/api/tests/Unit/Bank/CreditasBankEmailNoticeParserTest.php)
5-
(MIT). Those samples were at least partly typed: their counter-account fails the modulo 11 check. No key is pinned, so
6-
`withDns()` refuses every Creditas e-mail as `Unverified`, naming the key DNS gave; see
5+
(MIT). Those samples were at least partly typed: their counter-account fails the modulo 11 check. No key is pinned:
6+
`withDns()` accepts any key DNSSEC proves `creditas.cz` published; see
77
[#20](https://github.com/landsman/bank-java/issues/20).
88

99
## What it carries

‎.docs/banks/cz/csob/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[tomaj/bank-mails-parser](https://github.com/tomaj/bank-mails-parser/tree/master/tests/fixtures/csob-cz) (MIT, 43 of
55
them, 2018 to 2022), whose accounts fail the modulo 11 check. ČSOB signed as `d=csob.cz; s=alpha` in a 2020 e-mail
66
([remp2020's csob.eml](https://github.com/remp2020/crm-payments-module/blob/master/docs/csob.eml)); that key is gone, so
7-
none is pinned and `withDns()` refuses every ČSOB e-mail as `Unverified`. See
7+
none is pinned: `withDns()` accepts any key DNSSEC proves `csob.cz` published. See
88
[#16](https://github.com/landsman/bank-java/issues/16).
99

1010
ČSOB's own internet banking sends another template, **"Moje info - Avízo"**, read from

‎.docs/banks/cz/moneta/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
**Not seen as a real e-mail yet (2026-11-10).** The parser follows the sanitised samples in
44
[radekhulan/myinvoice](https://github.com/radekhulan/myinvoice/blob/master/api/tests/Unit/Bank/MonetaBankEmailNoticeParserTest.php)
5-
(MIT), whose MONETA parser real users run. No key is pinned, so `withDns()` refuses every MONETA e-mail as `Unverified`,
6-
with the fingerprint of the key DNS gave in the message. The first real e-mail confirms the template and that key;
5+
(MIT), whose MONETA parser real users run. No key is pinned: `withDns()` accepts any key DNSSEC proves `moneta.cz`
6+
published. The first real e-mail confirms the template and pins its key;
77
see [#18](https://github.com/landsman/bank-java/issues/18).
88

99
## What it carries, and what it does not

‎.docs/banks/cz/raiffeisenbank/README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
**Not seen as a real e-mail yet (2026-11-10).** The parser follows the sanitised samples in
44
[radekhulan/myinvoice](https://github.com/radekhulan/myinvoice/blob/master/api/tests/Unit/Bank/RaiffeisenbankEmailNoticeParserTest.php)
55
(MIT). Those are text a mail library made of the HTML, and at least partly typed: their accounts fail the modulo 11
6-
check. No key is pinned, so `withDns()` refuses every Raiffeisenbank e-mail as `Unverified`, naming the key DNS gave;
7-
see [#17](https://github.com/landsman/bank-java/issues/17).
6+
check. No key is pinned: `withDns()` accepts any key DNSSEC proves `rb.cz` published; see [#17](https://github.com/landsman/bank-java/issues/17).
87

98
## What it carries
109

‎.docs/banks/cz/unicredit/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
**Not seen as a real e-mail yet (2026-11-10).** The parser follows the one sanitised sample in
44
[radekhulan/myinvoice](https://github.com/radekhulan/myinvoice/blob/master/api/tests/Unit/Bank/UnicreditBankEmailNoticeParserTest.php)
5-
(MIT), whose accounts fail the modulo 11 check. No key is pinned, so `withDns()` refuses every UniCredit e-mail as
6-
`Unverified`; see [#19](https://github.com/landsman/bank-java/issues/19).
5+
(MIT), whose accounts fail the modulo 11 check. No key is pinned: `withDns()` accepts any key DNSSEC proves
6+
`unicreditgroup.cz` published; see [#19](https://github.com/landsman/bank-java/issues/19).
77

8-
**Before a key is pinned, a real outgoing e-mail has to show how it writes its direction.** The parser takes the
8+
**A real outgoing e-mail still has to show how it writes its direction.** The parser takes the
99
amount's sign, as myinvoice does: none is money in, a minus is money out. The sample is incoming. If an outgoing
1010
payment came without a minus, a refund to a customer, with the invoice's amount and symbol, would pay that invoice
1111
again.

‎.docs/banks/sk/tatra/README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
[tomaj/bank-mails-parser](https://github.com/tomaj/bank-mails-parser/tree/master/tests/fixtures/tatrabanka)'s fixtures
66
(2015), both MIT. That e-mail was signed with selector `mta`, and `mta._domainkey.tatrabanka.sk` is still published:
77
RSA 2048, DNSSEC-secure, fingerprint `sOUiSq9+xyeXpczY9SzI+HLjzU4jZyfQUXGvxjtXmVc=` (2026-11-10, through 1.1.1.1 and
8-
8.8.8.8). It is not pinned until a real e-mail confirms the template and that Tatra still signs with it, so `withDns()`
9-
refuses every Tatra banka e-mail as `Unverified`. See [#24](https://github.com/landsman/bank-java/issues/24).
8+
8.8.8.8). It is not pinned: `withDns()` accepts any key DNSSEC proves `tatrabanka.sk` published, this one included. See [#24](https://github.com/landsman/bank-java/issues/24).
109

1110
## What it carries
1211

‎.docs/development.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ folder is not a package.
6262
5. **Pin its key**: the fingerprint `DkimVerifier.fingerprint` gives for the key in DNS, read through two resolvers, in
6363
the bank's `KEY_FINGERPRINTS` (returned by `keyFingerprints()`, which `pinnedKeys()` lists), and a check in
6464
`KeyCheckLiveTest`.
65-
Its domain has to be DNSSEC-signed, or `withDns()` refuses every e-mail from it.
65+
Its domain has to be DNSSEC-signed, or `withDns()` refuses every e-mail from it. A bank written from public samples,
66+
with no real e-mail to show its selector, leaves `keyFingerprints()` empty: `withDns()` then accepts any key DNSSEC
67+
proves its domain published.
6668
6. **Document it** in [setup](setup.md), a folder like [banks/cz/airbank](banks/cz/airbank/README.md), and its row in [banks](banks/README.md).
6769

6870
The real e-mail stays out of the repository: an anonymised message no longer matches its signature, so the tests sign

‎.docs/usage.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ amount, a variable symbol and a date.
128128

129129
## Keys
130130

131-
`withDns()` needs nothing from you: it validates the bank's key through DNSSEC and accepts only the keys this release
132-
pins, see [whose key it is](verification.md#whose-key-it-is). The machine's resolver only has to pass DNSSEC records
131+
`withDns()` needs nothing from you: it validates the bank's key through DNSSEC and, for a bank read from real e-mails,
132+
accepts only the keys this release pins, see [whose key it is](verification.md#whose-key-it-is). The machine's resolver only has to pass DNSSEC records
133133
through, as nearly every one does; one that strips them makes every e-mail `Unverified` with the message
134134
`... is not DNSSEC-secure`. `BankNotifications.pinnedKeys()` lists the pinned keys, for an audit or a line at start-up.
135135

‎.docs/verification.md‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ flowchart TB
1818
sender -- "yes" --> dns{"bank's key from DNS,<br/>DNSSEC-validated<br/>from the root"}
1919
dns -- "DNS down" --> temporary(["TemporaryFailure"])
2020
dns -- "forged or unsigned" --> unverified(["Unverified"])
21-
dns -- "secure" --> pin{"key pinned<br/>in this release?"}
21+
dns -- "secure" --> pin{"one of the keys<br/>this release pins<br/>for the bank?"}
22+
pin -- "pins none" --> sig
2223
pin -- "no" --> unverified
2324
pin -- "yes" --> sig{"signature valid,<br/>d=airbank.cz,<br/>whole body?"}
2425
sig -- "no" --> unverified
@@ -39,8 +40,8 @@ A signature counts only when all of these hold, besides [whose key it is](#whose
3940

4041
- it verifies over the **raw bytes**, recomputed here; an `Authentication-Results` header that came with the message
4142
is never read, because whoever sent the message could have written it;
42-
- its `d=` is the domain of the bank the sender names (`airbank.cz` for Air Bank, `fio.cz` for Fio); a signature of any
43-
other domain is not even looked up;
43+
- its `d=` is the domain of the bank the sender names (`airbank.cz` for Air Bank, `fio.cz` for Fio, every bank's in
44+
[banks](banks/README.md)); a signature of any other domain is not even looked up;
4445
- the headers reading depends on (`Message-ID`, `Subject`, `Content-Type`, `Content-Transfer-Encoding`) come once:
4546
DKIM signs the last copy of a header and the mail library reads the first, so a copy added above a signed one is
4647
`Unverified`;
@@ -61,11 +62,14 @@ the bank's, and `BankNotifications.withDns()` does both without being asked:
6162
root zone's trust anchors (IANA's KSK-2017 and KSK-2024) down, instead of trusting the machine's resolver. An unsigned
6263
zone, a forged answer, a broken signature chain and a resolver that strips the signatures are all refused.
6364
`airbank.cz` and `fio.cz` are signed, and so are their key records (2026-11-10).
64-
- **The key is pinned.** Each bank's key fingerprints are written in the code (`KEY_FINGERPRINTS` in `AirBank` and `FioCz`, the SHA-256
65-
of the public key), and only those are accepted, whatever DNS says. Forging a key would take breaking DNSSEC *and*
66-
holding the bank's private key. `BankNotifications.pinnedKeys()` lists them.
67-
68-
The price of pinning: **when a bank rotates its key, a release that does not know the new one throws `Unverified` for
65+
- **The key is pinned**, for a bank read from real e-mails. Its key fingerprints are written in the code
66+
(`KEY_FINGERPRINTS` in `AirBank` and `FioCz`, the SHA-256 of the public key), and only those are accepted, whatever
67+
DNS says. Forging a key would take breaking DNSSEC *and* holding the bank's private key.
68+
`BankNotifications.pinnedKeys()` lists them. A bank read from public samples pins nothing, so DNSSEC alone decides:
69+
any key its domain publishes is accepted, a newsletter sender's included if it signs as the bank.
70+
71+
Only Air Bank and Fio pin keys today; the banks read from public samples pin none until a real e-mail shows their
72+
selector, see [banks](banks/README.md). The price of pinning: **when a bank rotates its key, a release that does not know the new one throws `Unverified` for
6973
that bank's e-mails** until you upgrade. Nothing is lost, the e-mails are still there to read again; `.github/workflows/keys.yml`
7074
compares the pins with DNS every day and opens an issue the day a bank publishes another key, so a release follows.
7175
`make check-keys` runs the same check by hand.

0 commit comments

Comments
 (0)