Crafting Valid IBANs to Bypass Subscription Payment Validation: A Technical Analysis

    A recent discussion around generating format-valid German IBANs to slip through subscription payment validation highlights a common flaw: treating "format-valid" as "account usable" and "payment instruction created" as "funds confirmed." This article explains how IBAN mod-97 validation works, why German IBANs are an attractive target, and how coupling entitlement delivery to asynchronous direct debit payments creates the real vulnerability — along with engineering recommendations to fix it.

    A recent discussion around constructing format-valid German IBANs to bypass subscription payment validation has drawn attention. Stripped of the specific incident and product names, the underlying technique is not complicated: the attack surface is neither the cryptographic algorithm nor the payment network itself, but a business system that mistakes “format-valid” for “account usable,” and “payment instruction created” for “funds confirmed.” Ultimately, a string that merely passes a modulo check, combined with an asynchronous direct debit settlement channel, triggers a mismatch between instant entitlement delivery and a later failure callback.

    1. IBAN Self-Validation Proves Format, Not Account Existence

    IBAN validity is a purely offline computation. The rule can be summarized as follows: move the first four characters (country code and check digits) to the end, expand letters into numbers (A=10, B=11, through Z=35) to form a large integer N, and require N mod 97 = 1. To construct an IBAN in reverse, set the check digits to 00, compute the intermediate value N′, then derive the check digits as c = 98 - (N′ mod 97). This algorithm requires only a single modulo operation — no network access, and no query to a bank to verify whether the account exists.

    This means any online generator can produce a fully format-valid German IBAN in milliseconds. More importantly, German IBANs are a fixed 22 characters with a relatively simple structure, and the bank code directory is publicly downloadable. What many business systems call “IBAN validation” is often just mod-97 plus a bank code whitelist; once the generator uses a real bank code, this lightweight check fails. So a “fake IBAN” in this context is not fake in the validation sense — it is format-valid, possibly backed by a real bank code, but the account itself cannot be settled or has no valid mandate.

    Illustrative code, for demonstrating the format validation and generation logic only:

    1. def iban_mod97_ok(iban: str) -> bool:
    2. s = iban[4:] + iban[:4]
    3. digits = []
    4. for ch in s:
    5. if ch.isdigit():
    6. digits.append(ch)
    7. else:
    8. digits.append(str(ord(ch.upper()) - ord('A') + 10))
    9. return int(''.join(digits)) % 97 == 1
    10. def make_de_iban(bank_code: str, account: str) -> str:
    11. # bank_code is 8 digits, account is 10 digits; demonstrates format only,
    12. # does not guarantee the account actually exists
    13. bban = bank_code + account.zfill(10)
    14. tmp = bban + "DE00"
    15. digits = ''.join(
    16. str(ord(c.upper()) - ord('A') + 10) if c.isalpha() else c
    17. for c in tmp
    18. )
    19. check = 98 - (int(digits) % 97)
    20. return f"DE{check:02d}{bban}"

    This code illustrates the first layer of the problem: format validity has no necessary relationship with account settlability. If the business side only performs frontend or lightweight backend validation, it cannot distinguish between “a string that passes validation” and “a bank account that can actually be debited.”

    2. Why German IBANs Became the Target of Choice

    From an engineering perspective, the choice of German IBANs is no accident. First, German IBANs are a fixed 22 characters with a simple structure and publicly queryable bank codes, so generators can easily produce numbers whose bank codes are genuinely real — enough to bypass the lightweight “mod-97 plus bank code whitelist” check. Second, some jurisdictions offer fewer supplementary reason codes for disputed transactions, making post-incident forensics relatively weak and risk-tracing expensive. Third, under the eurozone direct debit scheme, the payee cannot reject a payment merely because the payer’s IBAN belongs to a particular member state. The anti-country-discrimination rule was originally designed to integrate the regional market, but from a risk-control perspective it narrows the space for granular handling.

    A direct consequence: when risk concentrates in a single jurisdiction, the business may not be able to shut down just that jurisdiction’s direct debit channel while keeping others open. Compliance constraints eliminate the “middle ground,” leaving only the options of fully open or fully closed. If the incident occurs during a period with long approval chains and thin on-call resources, taking the entire channel offline becomes a seemingly blunt but compliance-wise easiest option.

    3. The Real Problem: Payment State Machine Coupled with Entitlement Delivery

    Card payments and direct debits have different risk models. Card payments typically follow an authorization model — once authorization succeeds, fund availability can be confirmed quickly. Direct debits follow a push model: after a transaction is created, it enters a processing state that may last for days, during which failure codes such as insufficient funds, closed account, nonexistent branch, or unauthorized debit can be returned at any time. If both channels share the same entitlement delivery logic, the system will mistake “payment instruction accepted” for “payment succeeded.”

    A typical faulty flow looks like this:

    1. The user submits a subscription request, and the business creates a direct debit transaction;
    2. The transaction enters a processing state, with final settlement not yet complete;
    3. The system sees the transaction was created and immediately grants membership benefits;
    4. Days later, the bank returns a failure code and the transaction fails;
    5. The benefits have already been consumed, making recovery and banning costly.

    The problem is not direct debit itself, but the state machine design. Payment status, settlement status, and entitlement status should have clear boundaries. A processing state must not be treated as a success state; entitlement delivery should be tied to final confirmation, or at least use delayed delivery, capped delivery, gradual rollout, and failure rollback strategies.

    4. Engineering Recommendations

    First, model payment methods in layers. Card payments, direct debits, and other asynchronous payment methods should use independent state machines and entitlement policies, rather than sharing a single “success means deliver” logic. Second, decouple entitlement delivery from settlement. For asynchronous payments, set up an observation period: grant restricted benefits first, then upgrade after settlement is confirmed; on failure, automatically downgrade and trigger risk controls. Third, add account authenticity verification. Beyond format validation, introduce account name matching, mandate validity checks, a first small-value verification debit, risk scoring, and transaction limits. Fourth, build a jurisdiction-level risk view. For high-risk jurisdictions, raise verification strength, shorten benefit cycles, and add manual review — rather than relying solely on country-based rejection. Fifth, improve monitoring and alerting. Focus on metrics such as the proportion of transactions in processing state, failure code distribution, the time gap between entitlement delivery and settlement, multiple accounts per device, and abnormal concentration on a single bank code.

    On the compliance side, anti-country-discrimination rules should be factored into risk-control strategy design, with fallback plans prepared in advance for when country-level granular shutdown is not possible — for example, limits across all channels, delayed settlement, stronger authorization verification, and manual review. Emergency procedures should also cover non-working hours, so that approval chains do not become a risk exposure.

    5. Conclusion

    The technical lesson from this incident: IBAN mod-97 validation only answers “is the string valid,” not “is the account usable”; the asynchronous nature of direct debit is not a vulnerability either. The real vulnerability is a business system that conflates format validation, payment acceptance, and entitlement delivery. For subscription services, the more asynchronous the payment channel, the more conservative the state machine must be; the stronger the compliance constraints, the more the risk-control strategy must design intermediate states in advance. Only by separating “format-valid,” “instruction accepted,” “settlement succeeded,” and “entitlement available” into distinct states can a valid string be prevented from piercing through business logic.