Beyond Format Validation: Understanding SEPA Direct Debit Risk Control Through a Fake IBAN Vulnerability

    This article analyzes a payment bypass incident in an AI subscription service where attackers used a structurally valid but fake German IBAN. It explores the local mod-97 validation mechanism of IBANs, the specific reasons why German IBANs were targeted, and the fundamental root cause: sharing the same entitlement logic between synchronous card payments and asynchronous SEPA Direct Debit settlements. Finally, it provides engineering recommendations to fortify payment systems against such risks.

    Incident Background: An Attack Without “Hacking”

    Recently, an overseas AI subscription service experienced a typical payment bypass. When upgrading to a premium membership, users could obtain subscription benefits without actually paying by submitting a constructed, structurally valid German IBAN. The entire process required no vulnerability discovery, reverse engineering, or protocol cracking—the attacker simply submitted a “legitimate but hollow instruction,” and the rest was automatically completed by a business-side risk control failure.

    The value of such incidents for developers lies in exposing a common but often overlooked blind spot in payment system design: format validation does not equal payment success, and instruction acceptance does not equal fund arrival. Let’s break this down from three perspectives: technical principles, institutional constraints, and engineering practices.

    The Legitimacy of IBANs: A Purely Local Modulo Operation

    To understand this incident, we must first understand the validation mechanism of IBANs (International Bank Account Numbers). An IBAN is a self-checking string whose legitimacy is determined entirely locally without network queries or contacting the bank. It is essentially a modulo 97 operation.

    The validation process is as follows:

    1. Move the first four characters of the IBAN (2-letter country code + 2-digit check digits) to the end of the string;
    2. Expand letters into numbers according to the rule: A=10, B=11, …, Z=35;
    3. Obtain a large integer N, which must satisfy N mod 97 = 1.

    Conversely, forging an IBAN that is “100% legitimate” in format is equally simple: set the check digits to 00, calculate the intermediate value N’ using the same expansion rule, compute the check digits c = 98 - (N’ mod 97), and insert them back. The sample code is as follows:

    1. def iban_checksum(country_code, bban):
    2. # Move the country code to the end and append "00" as a placeholder check digit
    3. rearranged = bban + ''.join(str(ord(ch) - 55) for ch in country_code) + '00'
    4. numeric = int(''.join(str(ord(c) - 55) if c.isalpha() else c for c in rearranged))
    5. check = 98 - (numeric % 97)
    6. return f"{country_code}{check:02d}{bban}"

    This means any online generator can produce mod-97 valid numbers in milliseconds. Passing format validation only proves the string is self-consistent; it does not mean the account actually exists, has sufficient funds, or that the holder authorized the deduction.

    Why German IBANs?

    The attackers’ choice of Germany was no accident, but rather the result of the “lowest attack cost, highest tracing difficulty” combination within SEPA (Single Euro Payments Area). This can be understood from three dimensions.

    First, regular and public structure. German IBANs are fixed at 22 characters, with characters 5 to 12 being the 8-digit Bank Code (BLZ). The complete list of BLZs is publicly published by the central bank and downloadable by anyone. This means generators can produce numbers where even the bank code genuinely exists. Many in-house “IBAN validation” systems are just mod-97 plus a bank code whitelist, which fails directly against such constructions.

    Second, weak post-event forensics. Due to local privacy regulations, disputed transactions in Germany often do not provide detailed chargeback reasons. For merchants, this makes attribution difficult after a chargeback: was the account non-existent, the balance insufficient, or the authorization missing? Low front-end verifiability and low back-end traceability both favor the attacker.

    Third, compliance constraints weaken granular handling. EU SEPA rules include an explicit “anti-IBAN discrimination” clause: payees cannot refuse a payment simply because the payer’s bank is located in a specific member state. While intended to unify the European internal market, its side effect on risk control is that as long as the SEPA Direct Debit channel is enabled, merchants cannot implement granular country-level switches like “disable Germany, keep others.” This explains why the emergency response was rather blunt: the entire channel was temporarily taken offline. Compliance eliminated the middle ground, leaving only all-on or all-off options. The incident also occurred over a weekend when the approval chain was longest and on-call staff was thinnest, further amplifying the response delay.

    The Core Issue: Two Payment Models Sharing the Same Entitlement Logic

    Stripping away all details, the technical root cause of this incident can be summarized in one sentence: Credit cards operate on an “authorization equals confirmation” model, while SEPA Direct Debit operates on a “initiate first, settle later” model. Both channels shared the same entitlement logic.

    Card payments use an authorization model: when the payment gateway returns “succeeded,” the funds are essentially locked, and failures are returned as explicit failure statuses within a very short time. Therefore, “receive success callback -> immediately grant entitlement” is generally safe for card channels.

    SEPA Direct Debit, however, uses a batch settlement model. After the merchant submits the deduction instruction, it enters the interbank clearing network. Actual fund transfer and failure receipts (account non-existent, insufficient funds, authorization revoked, etc.) may not arrive until several business days later. During this period, there is a natural asynchronous window between “instruction accepted” and “funds received.” If the entitlement logic misinterprets “accepted” as “deducted,” this window becomes a zero-cost arbitrage space—attackers consume membership benefits before the settlement failure receipt arrives.

    Engineering-Level Hardening Recommendations

    To address such issues, payment system improvements should focus on “explicitly modeling asynchronicity into the business state machine”:

    1. Decouple entitlement from settlement status. Introduce an intermediate state for direct debit payments, such as PENDING_SETTLEMENT. After the instruction is accepted, only grant restricted entitlements (or just record the intent), and upgrade to full entitlement only after the settlement confirmation callback arrives.
    2. Differentiated trust levels. The “success” semantics differ across payment channels; entitlement strategies should be tiered by channel risk. Authorization-based channels can grant immediate access, while deferred settlement channels should delay access or add quota limits.
    3. First-payment protection mechanisms. For the first direct debit of a new account, use pre-authorized micro-validation, set a cooling-off period, or restrict high-value operations within the first cycle to compress the arbitrage window.
    4. Chargeback monitoring and automatic circuit breaking. Establish real-time statistics for chargeback rates by country, bank code, and registration batch. When anomalies rise, automatically tighten the entitlement speed for the corresponding channel rather than just taking the entire channel offline.
    5. Upgrade validation. mod-97 is merely syntax validation. Businesses should combine account verification services, historical transaction reputation, and device/behavioral risk control signals for comprehensive judgment, avoiding a “valid format means pass” approach.

    Conclusion

    This incident required no profound technical threshold but precisely hit the most common cognitive misunderstanding in payment integration: treating channel-level “instruction acceptance” as financial-level “payment success.” For any business integrating multiple payment methods, especially those involving delayed settlement channels, the correct approach is to explicitly model the settlement semantics of each channel, aligning entitlement strictly with fund confirmation rather than API returns. The line of defense for risk control is often built upon this very reverence for “asynchronicity.”