Skip to content

Security

What protects this system, what does not, and what each party in the path can see. Everything below was checked against the code and the tests; where something is only designed or untested it is listed as such.

1. What is being protected, and from whom

A household's bank transactions and balances, on hardware the owner controls, readable from the owner's phone.

The realistic threats, in the order they are likely to matter:

  1. A lost or stolen phone, holding whatever lets it talk to the server.
  2. The internet finding the hostname. Anything reachable is scanned within hours.
  3. The proxy in the middle. A Cloudflare Tunnel ends TLS at Cloudflare, so Cloudflare could read what passes.
  4. A copied disk or backup of the server.
  5. Somebody on the home network, if the web pages are served over plain http there.
  6. A guessed or phished password.
  7. A leaked Enable Banking key, which reads the linked accounts (it cannot move money).

Not in scope: an attacker with a shell on the server or the server's administrator password. They hold the key files, the database key and the running process, and nothing here helps against that.

2. What each party can see

Party Sees Cannot see
Nordea Everything (it is your bank)
Enable Banking The data in transit between Nordea and your server, the fact that you use it. It states it stores nothing. Anything on your server
Cloudflare Request paths, timing, sizes, your phone's IP address, the pairing code in the pairing request, the query string of API requests. The web pages, if you serve them through the tunnel. The content of the phone's answers: they are sealed to a key only the phone holds
Your server Everything, unlocked, while running
A copy of data/ Nothing readable: the database file is encrypted
A copy of data/ and secrets/ Everything

Two honest consequences:

  • Cloudflare sees metadata and the query string. A search such as text=salary travels in the clear. The phone app should not put sensitive text in a query string; the sealed answers protect the response, not the request line.
  • Serving the web pages through the tunnel gives Cloudflare their content. That is why the compose file lists PublicPaths and keeps the pages for the home network.

3. What is built

3.1 Sealed answers to the phone

Every API answer to a paired phone is encrypted to a key the phone registered at pairing. Per response the server makes a fresh P-256 key pair, agrees a secret with the phone's key (ECDH), derives an AES-256 key with HKDF-SHA256 and encrypts with AES-GCM. The key is bound to the device id and to the request's token id, and the token id and status are authenticated data. So:

  • a proxy sees ciphertext only;
  • a captured answer cannot be handed to the phone as the answer to a different request;
  • every answer uses a new key and nonce.

This is the part a tunnel cannot give you on its own, and it is tested (SealedResponseTests, and the web tests that check the content type on the wire and that the owner's browser still gets plain JSON).

3.2 Device-bound signed requests

A phone does not hold a password or a bearer token. It holds a private key in the Android Keystore and signs a short token for each request:

Property Value
Algorithm ES256 (ECDSA P-256, SHA-256). RS256 with at least 2048 bits is also accepted.
Lifetime 60 seconds by default, never more than 120, clock drift allowed: 60 seconds
Single use Every token carries a random id; a second use is refused
Bound to the request HTTP method, path and a hash of the query string are inside the signed claims
Audience A fixed name, so a token for another server is refused

The server takes the algorithm from the device's registration and never from the token, which closes the usual attacks: alg: none, an HMAC signed with the public key, and mixing algorithms. The tests cover each of those, tampering with a claim, reusing a token for another path or query, expiry, and malformed input.

A stolen token is worth at most one request within one minute, and only one that was never made. A stolen phone is worth nothing once revoked, and revocation is immediate.

This is the same idea as Enable Banking's own scheme for apps (an RS256 JWT, kid naming the application, signed with a private key that stays with the app), tightened from "valid for up to 24 hours" to "valid for one request".

3.3 Pairing

An owner who is signed in asks for a code. It is eight characters from an alphabet without look-alike letters, valid for ten minutes, usable once, destroyed by five wrong guesses, and the claim route is rate limited (10 a minute per client). The phone sends its two public keys. The server stores public keys only, in devices.json, and shows each device's key fingerprint on the Phones page so the owner can compare it with the phone's screen.

3.4 Signing in to the web pages

Control Detail
Password PBKDF2-HMAC-SHA256, 600,000 iterations, random salt. Stored as a hash only.
Second factor Time-based one-time code (RFC 6238, checked against its published test vectors). Each code works once; a wrong password does not use up the owner's code.
Lockout Five failures lock an address for 15 minutes. IPv6 clients are grouped by /64. A wrong username costs the same time as a wrong password.
Session Encrypted cookie, HttpOnly, SameSite=Lax, Secure over https, sliding 14 days
CSRF Anti-forgery token on every state-changing form; the cookie is SameSite=Strict
Headers Content-Security-Policy (default-src 'self'), nosniff, no referrer, no framing, no-store
Open redirect The return address must be a local path
Fail closed Outside Development the app refuses to start without a login, a second factor and an encrypted database

3.4a What the tunnel can reach

  • Exact proxy address. Forwarded headers are trusted from the cloudflared container's fixed address only, never a subnet. A subnet or a wildcard is refused at start. With no proxy configured, no forwarding header is believed at all (an empty trusted list would otherwise mean "trust everybody").
  • Real client address. CF-Connecting-IP replaces the connection address only when the peer is that proxy, so the lockout, the rate limit and the Psu-Ip-Address sent to the bank all see the phone, not the tunnel.
  • Surface list. App:Proxy:PublicPaths makes everything outside /api/, /callback and /healthz answer 404 when it arrives through the proxy.

3.5 Data at rest

The database file is encrypted with SQLCipher (AES-256). Tests show the file has no readable header, no table names and none of the account numbers or merchants, that the wrong key or no key cannot open it, and (as a control) that an unencrypted file does contain them. The key lives in secrets/, separate from data/. The session id Enable Banking issues is additionally encrypted with a key derived from the database key. A real publish of the server-mode app was inspected on disk to confirm all of this outside the test harness.

3.6 Towards the bank

Every call to Enable Banking carries an RS256 token signed with your application key. The library mints it with a 30 minute life and renews it 5 minutes before it ends (Enable Banking would accept up to 24 hours). The calls are read-only: the library has no payment code, and restricted production has no payment permission. The 180-day consent ends by itself, can be revoked from the overview page, at Enable Banking, or at Nordea.

4. What is not built, or not proven

Gap Consequence
The Android app does not exist yet. The protocol is implemented and tested end to end with a software phone (BankSync.PhoneSimulator, BankSyncPhoneClient), but never with the Android Keystore. Key-handling details on Android (see Android API, "Keys") are design, not experience.
Hardware-bound key agreement needs Android 12. Keystore ECDH (PURPOSE_AGREE_KEY) exists from API 31. On older phones the encryption key would have to be a software key wrapped by a Keystore key, which is weaker.
Plain http on the home network when App__AllowInsecureLan is on. Anyone who can read your home network can read the web pages and steal the session. Off by default; the compose file turns it on because the alternative is no web pages at home.
Query strings are readable by Cloudflare. Do not put sensitive text in a search.
No Cloudflare Access unless you set it up. It is optional and manual. Without it, the app's own checks are the only gate for the three public paths. They are strong, but a second independent gate is better.
Lockout counters, the replay cache and the one-time-code memory are in RAM. A restart clears them. A token captured just before a restart could be replayed once within its two minutes.
The Enable Banking key and the one-time-code key sit on the server disk as files and in .env. Protected by file permissions only. Anyone with root on the server has them.
cloudflared:latest is not pinned. A bad release would be pulled on the next recreate. Pin a version if that worries you.
One user, no roles, no admin audit trail in the database. Sign-ins and pairing events are in the container log, not in a table.
PBKDF2, not Argon2. There is no maintained Argon2 in .NET. 600,000 iterations is the current recommendation for PBKDF2-SHA256.
Not independently reviewed. Treat the cryptography as carefully built and tested, not as audited.

5. What was checked, and how

Claim How it was checked
Nothing readable in the database file Test with an unencrypted control; inspection of the file written by the published server-mode app
Signed requests resist forgery and reuse 17 unit tests on the verifier, 7 on sealing, 20+ against the running app
Cloudflare sees ciphertext only Web test reads the response body as it is on the wire; end-to-end run with the simulator against a real socket
One-time codes follow the standard The six official RFC 6238 test vectors
Proxy trust cannot be spoofed Unit tests: a header from any other peer, a mapped IPv6 peer, a garbled header, no proxy configured
The app refuses to start half-secured Web tests for each missing piece
The pages are hidden from the tunnel Unit tests, and a run of the published app with PublicPaths: pages 404, API 401, health 200, callback 400

Run them yourself with dotnet test BankSync.slnx.

6. If something goes wrong

Event Do this
Phone lost Phones → Revoke. Then change nothing else; the phone's key cannot be used.
Password or one-time-code key exposed New values in .env, recreate the container. All web sessions end.
Server stolen or disk copied Without secrets/ the data is unreadable. Revoke the bank consent at Nordea and delete the application at Enable Banking anyway.
Enable Banking key leaked Register a new certificate, replace the key file, recreate. Revoke the old application.
Tunnel token leaked Cloudflare → refresh the token, update .env, recreate.
Suspect someone paired a phone The Phones page shows every device and its key fingerprint; revoke the unknown one. Pairing needs a signed-in owner, so also change the password.