#0603
Your payment endpoint parses a JSON body and immediately uses the `amount` field — trusting that JSON parsing enforces the type.
But JSON allows `amount` to be a string, null, or negative number. Without explicit type validation, a string like `'100; DROP TABLE orders'` can reach downstream SQL builders, and a negative amount can result in credits instead of charges.
Type confusion bugs are among the easiest to exploit — an attacker just changes the JSON value type. They've caused real-world payment bypasses and SQL injections at scale.
processPayment('{"amount":"100; DROP TABLE"}')// throws: 'Invalid amount'
processPayment('{"amount":99.99}')// returns: {status:'ok', charged:99.99}