Blog | G5 Cyber Security

Banker’s Rounding Exploit: Balance Manipulation

TL;DR

Yes, banker’s rounding can be exploited to maliciously increase balances in certain banking systems. This is because of how small fractional amounts are handled during calculations and updates. By carefully timing transactions with specific values, it’s possible to accumulate these tiny gains over time.

Understanding Banker’s Rounding

Banker’s rounding (also known as round-to-even) is a common method banks use to minimise bias when rounding numbers. Unlike always rounding up or down, it alternates based on the decimal part:

For example:

While fairer overall, this can create subtle discrepancies in individual transactions.

How the Exploit Works

  1. The Core Issue: When performing calculations with money, computers often represent decimal values as floating-point numbers. These aren’t always perfectly accurate. Banker’s rounding then operates on these slightly inaccurate representations.
  2. Small Gains Accumulation: Repeatedly adding small amounts (e.g., £0.01) to an account can result in tiny positive differences due to the combined effect of floating-point inaccuracies and banker’s rounding.
  3. Transaction Timing is Key: The exploit relies on making multiple transactions close together, ideally within a single processing cycle or before any balancing operations occur. This prevents the bank from correcting the accumulated errors.

Step-by-Step Exploitation (Illustrative)

Disclaimer: Attempting this exploit is likely illegal and unethical. This guide is for educational purposes only to demonstrate a potential vulnerability.

  1. Initial Setup: Open an account with the target bank.
  2. Automated Transactions: Create a script or program that repeatedly deposits small amounts (e.g., £0.01) into your account. The frequency should be high – several transactions per second if possible.
  3. Monitor Balances: Carefully track the balance after each transaction. You’ll likely see very small increases beyond what you expect (£0.00001 or similar).
  4. Repeat and Accumulate: Continue making deposits for an extended period (days, weeks, or even months). The accumulated gains will slowly increase your overall balance.

Example Python code snippet to illustrate repeated deposits (simplified):

import time

def deposit(amount):
  # Simulate a bank deposit - in reality this would involve API calls.
  print(f"Depositing £{amount:.2f}")
  time.sleep(0.1) # Simulate transaction delay

balance = 100.00
for i in range(1000):
  deposit(0.01)
  balance += 0.01
print(f"Final balance: £{balance:.2f}")

Note: This code is a simplified example and doesn’t account for API interactions, error handling, or the complexities of banking systems.

Mitigation Strategies for Banks

Conclusion

Banker’s rounding, while generally a fair method, can be exploited under specific circumstances to manipulate balances. Banks must implement robust mitigation strategies to prevent this type of attack and protect their customers’ funds. The key is precise monetary representation and regular reconciliation.

Exit mobile version