IBAN Validation Flaw in Subscription Payments: Risk Control Design Lessons
This article explains an incident in which an IBAN that passed format checks but had no verified account ownership was used to pay for a subscription through SEPA Direct Debit and unlock benefits. It covers why IBAN checks only confirm that a string is internally consistent, why asynchronous direct debit payments should not share entitlement logic with card payments, and how state-driven design, layered validation, and compliance-aware fallback measures can reduce this kind of risk.
1. The Core Issue: A Mismatch in State Models, Not a “Crack”
A subscription service enabled SEPA Direct Debit as a payment channel. Afterward, an IBAN that passed format validation, but whose account ownership could not be verified, was used to start a payment, and the payment successfully triggered benefit issuance. On the surface, this looks like a payment vulnerability. Technically, however, the incident involved neither cryptographic breaking nor a protocol bypass.
An IBAN is a self-checking string, so a valid format does not mean the account exists. SEPA Direct Debit uses a push model: a payment is initiated first and settled later. After creation, a transaction can stay in a processing state for several days.
The real problem is that the business treated “format check passed” and “payment instruction created” as “funds confirmed.” It also applied the same benefit issuance logic to both card payments and direct debit payments.
So the core of this kind of incident is not how to fabricate a number. It is how to avoid treating an asynchronous payment status as a synchronous authorization result. A risk control design must answer three questions:
- What can front-end validation prove, and what can it not prove?
- Are payment status and entitlement status decoupled?
- Under compliance constraints, are there interim measures that can be degraded, limited, and audited?
2. IBAN Validation Proves Internal Consistency, Not Account Existence
The IBAN check is a purely offline modulo operation. Move the first four characters (the country code and check digits) to the end. Convert letters to numbers, with A=10, B=11, up to Z=35. This produces a large integer N. The IBAN is valid when N mod 97 = 1.
When generating an IBAN, set the check digits to 00 first and compute the intermediate value N′. Then set the check digits to 98 − (N′ mod 97). These rules ensure the string is internally consistent. They do not require a network connection, and they do not check whether the bank account exists.
Pseudocode:
function mod97(iban_like):s = iban_like[4:] + iban_like[:4]digits = ""for ch in s:if ch is digit:digits += chelse:digits += str(ord(ch) - ord('A') + 10)return big_mod(digits, 97)function make_iban(country, bank_code, account):raw = country + "00" + bank_code + accountrem = mod97(raw)check = 98 - remreturn country + pad2(check) + bank_code + account
To validate, check whether mod97(iban) == 1.
Many teams treat “mod-97 check plus bank code allowlist” as complete account validation. That assumption is the problem. Take German IBANs as an example. They have a fixed length of 22 characters, and characters 5 through 12 hold the 8-digit bank code. Central banks publish bank code tables, so anyone can download them. An attacker can generate a number with a real bank code and a nonexistent account. This bypasses part of the lightweight validation.
Format checks and bank code allowlists only show that a number looks legitimate and that its bank code exists. They do not show that the account exists or that it is authorized for debit.
Validation should be layered:
- Layer 1, format and check digits: Catches obvious errors.
- Layer 2, bank code and reachability: Identifies invalid routing.
- Layer 3, account verification or settlement feedback: Confirms that a real debit is possible.
If the channel supports general mechanisms such as account verification, small test deposits, or receipt confirmation, use them for high-risk scenarios. If the channel does not support these mechanisms, compensate with delayed entitlements, transaction limits, and manual review.
3. SEPA Direct Debit Settles Asynchronously, So It Cannot Reuse Card Entitlement Logic
Card payments usually follow an authorization model. A successful authorization means the funds are largely reserved. SEPA Direct Debit follows a push model. A transaction enters a processing state after creation and can remain there for days. During that time, it can fail for many reasons, including insufficient balance, a closed account, a nonexistent branch, or a debit that was not authorized.
If both payment types use the same rule, “payment succeeded, so issue the entitlement,” asynchronous risk is hidden behind an appearance of immediate success.
A better approach is to separate the payment state machine from the entitlement state machine:
Payment state:CREATED -> PROCESSING -> SETTLED | FAILED | RETURNEDEntitlement state:NONE -> PENDING -> ACTIVE -> REVOKEDon payment_created(debit):entitlement = PENDINGset_deadline(processing_timeout)on payment_settled(debit):entitlement = ACTIVEon payment_failed(debit, reason):entitlement = REVOKEDenqueue_manual_review(reason)on timeout(debit):entitlement = PENDINGenqueue_manual_review("processing_timeout")
For direct debit channels, entitlements should start in a pending state. Issue only limited trial benefits or delayed-access benefits at this stage. After settlement is confirmed, convert the entitlement to a full one. If the payment fails or is returned, revoke the entitlement automatically and send the case to manual review.
For card payments, a successful authorization can move into a shorter confirmation window. The system still needs paths for cancellation and dispute handling.
The key point is that entitlement issuance must depend on the combination of payment method, payment status, and risk level. A single success event should not trigger it.
4. Compliance Constraints Narrow Risk Control Options, So the System Needs Interim States
Rules tied to the Single Euro Payments Area (SEPA) typically include an anti-IBAN discrimination requirement. A payee cannot require that a payer hold an account in a specific member state. The purpose of this rule is to open up the regional market. The risk control consequence is that a business cannot reject payments simply because an IBAN belongs to a certain country. It also cannot easily restrict one country while keeping others open.
If a system supports only “fully on” or “fully off,” emergency responses become blunt. During an abnormal spike, the whole channel may have to go offline.
A more engineered alternative is to build interim states that can be explained under compliance rules:
- Channel-level limits
- Entitlements delayed according to risk scores
- Actions that affect only new transactions
- Manual review of existing transactions
- Classification of failure codes and matching responses
- Gradual degradation and automatic rollback
Risk scores can use features such as account age, transaction history, amount and frequency, device and linked-account relationships, bank code reachability, account verification results, and historical dispute rates. Country can be one feature, but it cannot be the only reason to reject a payment. The decision process requires a compliance review and an explainable record. This approach avoids direct regional rejection and keeps fine-grained response options available during incidents.
5. Why Certain Jurisdictions Become Attack Surfaces: Low Probing Cost and Weak Forensics
From an attacker’s perspective, some member states have a lower cost of probing. Their IBANs have a fixed length and a simple structure, their bank codes are public, and the check can be computed offline. Using German IBANs as an example again, the fixed 22-character length and public bank code tables let an attacker generate numbers with real bank codes and nonexistent accounts.
Public documentation from some payment service providers also notes that, in some jurisdictions, privacy rules mean disputed transactions do not come with additional reason details. This weakens after-the-fact forensics. The front end can only check format, and the back end has limited dispute information. Together, these two gaps create an attack surface.
This shows that payment risk control cannot rely only on whether a number looks legitimate. For jurisdictions with limited dispute information, teams should store more complete local records. These include request context, state changes, operation audit logs, and device and linked-account information. Teams should also build a traceable chain using general capabilities such as logging, monitoring, and message queues. In general-purpose cloud environments such as Baidu AI Cloud, log services, monitoring and alerting, and message queues can form an audit and alerting loop. The implementation, however, should be built around the business state machine rather than simply adding more components.
6. Practical Recommendations: Move from Point Checks to State-Driven Risk Control
The improvements can be summarized as follows:
- Layered validation: Use four levels: format check, bank code check, account verification, and settlement feedback. Define what each level can and cannot prove.
- Entitlement decoupling: For direct debit, keep entitlements pending until settlement, activate them after settlement, and revoke them on failure. Card and direct debit payments should use different issuance policies.
- State machines and idempotency: Model payment events and entitlement events separately. Use idempotency keys to prevent duplicate issuance and duplicate revocation.
- Risk tiers: Base decisions on risk scores rather than country alone. Keep interim options such as limits, delays, and manual review.
- Gradual rollout and degradation: Use channel switches, limits, changes that affect only new transactions, automatic rollback, and pre-approved contingency plans. This avoids having to shut down an entire channel on a non-business day.
- Observability: Monitor processing duration, failure code distribution, dispute rates, entitlement redemption rates, and concentration by bank code. Set timeouts and alerts for sudden spikes.
- Audit and forensics: Store requests, state changes, timestamps, operators, and linked features. When dispute information is limited, rely more heavily on local audit records.
In conclusion, the IBAN validation flaw itself is not complicated. What makes it hard is how the business state model and compliance constraints interact. The security boundaries are clear. A valid format does not mean the account is real. An authorization does not mean funds have arrived. Compliance with a channel’s rules does not mean risk controls can be turned off. Entitlement issuance must be decoupled from settlement status.
Only when payment status, entitlement status, risk scores, and degradation plans are unified in an auditable state machine can teams avoid systemic risks like a valid-format number triggering benefit issuance.
