GHSA-7mp4-25j8-hp5q: Sylius has a Promotion Usage Limit Bypass via Race Condition
ImpactA Time-of-Check To Time-of-Use (TOCTOU) race condition was discovered in the promotion usage limit enforcement. The same class of vulnerability affects three independent limits:**Promotion usage limit** - the global `used` counter on `Promotion` entities**Coupon usage limit** - the global `used` counter on `PromotionCoupon` entities**Coupon per-customer usage limit** - the per-customer redemption count on `PromotionCoupon` entitiesIn all three cases, the eligibility check reads the `used` counter (or order count) from an in-memory Doctrine entity during validation, while the actual usage increment in `OrderPromotionsUsageModifier` happens later during order completion — with no database-level locking or atomic operations between the two phases.Because Doctrine flushes an absolute value (`SET used = 1`) rather than an atomic increment (`SET used = used + 1`), and because the affected entities lack optimistic locking, concurrent requests all read the same stale usage counts and pass the eligibility checks simultaneously.An attacker can exploit this by preparing multiple carts with the same limited-use promotion or coupon and firing simultaneous `PATCH /api/v2/shop/orders/{token}/complete` requests. All requests pass the usage limit checks and complete successfully, allowing a single-use promotion or coupon to be redeemed an arbitrary number of times. The per-customer limit can be bypassed in the same way by a single customer completing multiple orders concurrently. No authentication is required to exploit this vulnerability.This may lead to direct financial loss through unlimited redemption of limited-use promotions and discount coupons.PatchesThe issue is fixed in versions: 1.9.12, 1.10.16, 1.11.17, 1.12.23, 1.13.15, 1.14.18, 2.0.16, 2.1.12, 2.2.3 and above.WorkaroundsDecoration of the `OrderPromotionsUsageModifier` service to use atomic operations based on actual database-synchronized values.The decorated service id in Sylius >=2.0 is `sylius.modifier.promotion.order_usage`, while <2.0 it's `sylius.promotion_usage_modifier`; The following instruction uses the latter, but it needs to be changed depending on the Sylius version.Step 1. Create the decorator service`src/Modifier/AtomicOrderPromotionsUsageModifier.php`:Step 2. Register the service**Option A:** If your app uses autowiring and supports the `#[AsDecorator]` attribute, uncomment it in the class and no further configuration is necessary.**Option B:** Manually register the service in `config/services.yaml`:Step 3. Update exception mapping (optional)Check if your `api_platform` configuration maps `OptimisticLockException` to a code and update it if not:Step 4. Clear cacheReportersWe would like to extend our gratitude to the following individuals for their detailed reporting and responsible disclosure of this vulnerability:Djibril Mounkoro (@whiteov3rflow)Bartłomiej Nowiński (@bnBart)For more informationIf you have any questions or comments about this advisory:Open an issue in [Sylius issues](https://github.com/Sylius/Sylius/issues)Email us at [security@sylius.com](mailto:security@sylius.com)
CVSS v3.1: 8.2