Objective 2.3: Explain various types of vulnerabilities

Security+ SY0-701 practice question

A penetration tester assesses a gift card API. The redemption endpoint first checks that a card has enough balance and then, in a separate database call, deducts the amount. When the tester sends two redemption requests for the same $50 card within a few milliseconds of each other, both succeed and the tester receives $100 of credit. When the same two requests are sent one second apart, the second request is correctly rejected. Which vulnerability did the tester exploit?

Explanation

A race condition exists when the result of an operation depends on the timing of concurrent events. The common form is time-of-check to time-of-use (TOC/TOU): the application checks a condition (the balance) and later acts on it (the deduction), and another request slips in between. The fix is to make check-and-update atomic, for example with a single conditional update, a transaction with proper locking, or an idempotency key.