#1005
Your banking service processes withdrawals via withdraw(accountId, amount, currentBalance).
The current implementation performs no balance check — an attacker can withdraw more than their available balance, driving the account into a negative state and potentially extracting funds that don't exist.
This is a classic business logic flaw equivalent to an overdraft without an overdraft facility.
Missing balance checks in financial applications can cause real monetary losses. Race conditions can compound the problem when multiple withdrawal requests are processed concurrently.
'Invalid amount' if amount is less than or equal to zero.'Insufficient funds' if amount is greater than currentBalance.{ newBalance: currentBalance - amount } for valid withdrawals.withdraw('acc-1', 200, 100)// returns { newBalance: -100 } — negative balance!
withdraw('acc-1', 200, 100)// throws Error('Insufficient funds')