A security analyst is auditing an e-commerce platform's microservice that processes promotional discount codes. During testing, the analyst discovers that when a user sends multiple concurrent asynchronous API requests utilizing the same single-use discount voucher, the application processes several of the requests simultaneously before updating the voucher's status flag to used in the persistent database. Which of the following application vulnerabilities is present, and what is the most effective code-level mitigation strategy?
- Race condition (Time-of-Check to Time-of-Use); implement atomic database transactions with thread synchronization or row-level locking.Cevap
- BBroken authentication; enforce step-up multi-factor authentication (MFA) prior to submitting discount codes.
- CImproper input validation; deploy web application firewall (WAF) rate-limiting rules on the discount endpoint.
- DInsufficient logging and monitoring; configure real-time SIEM alerts to notify operators when duplicate voucher IDs are detected.
Cevap
Race condition (Time-of-Check to Time-of-Use); implement atomic database transactions with thread synchronization or row-level locking.
The scenario describes a classic Time-of-Check to Time-of-Use (TOCTOU) race condition where concurrent requests exploit the time delta between verifying a voucher's validity and recording its usage. The proper solution is to enforce atomicity through thread synchronization, row-level database locking, or isolation levels that ensure only one thread can verify and modify the record at a time.
Adım Adım Çözüm
Anahtar Kavram
Race Conditions and TOCTOU Vulnerabilities
Tahmini Süre:2m 0s