Skip to content

API security testing in banking and fintech

B2Bnetwork team · · 6 min

Security

In brief

API security testing in banking and fintech checks three layers: who is calling the API (certificate, OAuth client, sender-constrained token), what they are allowed to do (consent scope, a specific account, a specific payment) and whether the logic of financial operations survives abuse (replayed requests, race conditions, changing the amount after authorization). The baseline is the OWASP API Security Top 10, and for open banking APIs also the FAPI 2.0 profile and PSD2 requirements. Most serious flaws sit in object and consent authorization.

How a financial API differs from an ordinary one

In an online shop, an authorization flaw exposes someone's order history. In a bank's API, the same flaw shows the balance and transactions of someone else's account or lets an attacker initiate a transfer. Financial APIs also have features that ordinary APIs rarely do:

  • Many technical clients: the bank's own app, partners, and third-party providers (TPPs) under PSD2, the EU Payment Services Directive, each with different rights.
  • Customer consents with a scope and an expiry date, which the bank must enforce on every call.
  • Operations that move money and must never execute twice.
  • Regulatory requirements: PSD2 and Delegated Regulation 2018/389 (the RTS on strong customer authentication and secure communication) describe interfaces for third-party providers, and DORA requires regular digital operational resilience testing.

General API flaws are covered in API security: the most common mistakes. Here we focus on what you test in an API that handles accounts and payments.

Identity of the API client: certificates and tokens

The first layer of the test answers one question: does the API know who is really calling it?

  1. Certificates and mTLS. Does the gateway reject a connection with no certificate, an expired or revoked one, or one issued to a different entity? Does the application behind the gateway check that the client ID in the token matches the certificate?
  2. Sender-constrained tokens. The FAPI 2.0 Security Profile requires access tokens to be bound to the client's key through mTLS (RFC 8705) or DPoP (RFC 9449). The test: does a stolen token work from another connection or without proof of possession of the key?
  3. The authorization flow. Does the authorization server require PKCE and pushed authorization requests (PAR), does it check the redirect URI exactly, can an authorization code be used twice? RFC 9700 collects the current best practice for OAuth 2.0 security.
  4. Lifetime and revocation. Does the refresh token stop working once the customer withdraws consent in online banking?

Consents and object authorization

This is where tests most often find critical flaws. The first item on the OWASP API Security Top 10 (object level authorization) looks like this in a banking API: a TPP holds customer A's consent for account 1 and sends the ID of customer B's account 2 in the request.

TestQuestionExpected result
Someone else's accountdoes consent for account 1 allow reading account 2denied
Consent scopedoes a balance-only consent allow fetching transaction historydenied
Expired consentdoes the API work the day after the consent expiresdenied
Withdrawn consentdoes withdrawal in online banking take effect immediatelydenied on the next call
Another TPPcan a consent issued to one TPP be used by anotherdenied
Object fieldsdoes a partner see fields it should not, such as data of other joint holdersfields not returned
Admin functionscan a partner's client call an endpoint meant for the operatordenied

Each test runs on two sets of accounts and consents, swapping identifiers in the path, the parameters and the request body. Account and consent identifiers should be random, but randomness does not replace a server-side permission check.

The logic of financial operations

A scanner will not help here. The engineer checks whether the payment process behaves correctly when the API client acts maliciously.

  • Idempotency. Does repeating a transfer request with the same idempotency key avoid creating a second transfer, and is the same key with a different amount rejected?
  • Race conditions. Dozens of parallel withdrawal requests against a balance that covers one. Are the limit and balance checked atomically?
  • Changes after authorization. Can the amount, payee or currency be changed between creating a payment and confirming it with strong authentication?
  • Boundary values. Negative amounts, zero, very large amounts, many decimal places, rounding in currency conversion.
  • Webhooks and notifications. Does the partner verify the signature of a payment status notification, and can "payment completed" be forged?
  • Limits. Does the API throttle calls per client and per consent, so nobody can enumerate account numbers or overload the core system?

Test plan and automation

  1. Inventory: a list of APIs, versions and technical clients from the OpenAPI files and the gateway. Old versions that still run are a common source of flaws.
  2. A threat model for every financial operation: who can call it, with which consent, what happens on a double call.
  3. A gray box penetration test with accounts, test certificates and consents for several TPPs.
  4. A report with risk ratings and a retest of the fixes.
  5. Automation in the pipeline: authorization tests with two sets of accounts, contract tests and a gateway configuration scan on every release.

The architecture of the API layer is covered in A bank's API layer, and the general test and report flow in Web application penetration testing. This is how the test ran in the case study on an API for third-party providers in open banking: gray box per the OWASP API Security Top 10, with a focus on object authorization, consent scope and tokens. At B2Bnetwork this kind of security testing is done by engineers who work on banking systems.

Questions and answers

Is an API scanner enough for security testing in a bank?

No. A scanner finds configuration mistakes, missing headers and known component vulnerabilities. It will not check whether consent for one account grants access to another, or whether two parallel transfers go through against a balance that covers one. That takes an engineer with several sets of accounts and an understanding of the payment process.

Do we need to implement FAPI 2.0?

That depends on your market and your partners' requirements. FAPI 2.0 is an OAuth profile for high-value APIs, and it collects practices worth following even without a formal mandate: PKCE, PAR and tokens bound to the client's key. A test shows which of these are already in place.

Which environment should payment APIs be tested in?

A test environment or sandbox with the same API version, synthetic data and test certificates. Race condition and rate limit tests can load the core system, so they are not run in production. In production you check the gateway and certificate configuration.

How often should partner APIs be tested?

At least once a year and on every change that touches authorization: a new API version, a new consent type, a change of authorization server. Between tests, automated authorization tests run in the pipeline. Entities covered by DORA also have to run regular digital operational resilience tests.

What it looks like in a project

Want to check your application's security? Talk to an engineer.

Let's talk

Read more: Security

All in Security →