GHSA-5gmm-hjfj-8ff7: Race Condition
Summary
The service downgrade implementation in app/Livewire/Services/Upgrade.php::doUpgrade() executes a proration calculation and a subsequent user credit refund without any transactional safety or database locks. The only concurrency check relies on an unisolated database query checking for existing pending upgrades. Because there is no active database transaction or pessimistic row-level lock spanning this validation and the subsequent credit update, concurrent downgrade requests can bypass the guard simultaneously. This allows a user to trigger multiple refunds for a single service downgrade.
Technical Details
The issue occurs because the application verifies eligibility using an unlocked read operation (Service::upgradable) which checks if a pending upgrade row exists. Since there is no enclosing DB::transaction or lockForUpdate(), multiple requests sent in parallel can all query the database at the same millisecond, observe that no pending upgrade exists, and pass the safety check.
Once passed, each concurrent request inserts its own pending upgrade record and executes $credit->increment('amount', abs($price)). Because the balance updates are not serialized against the initial check, the user's credit balance is cumulatively inflated by $N$ times the refund amount for a single legitimate downgrade.
Impact
This race condition allows any authenticated customer with an active, downgradable service to inflate their spendable credit balance to an arbitrary multiple of their legitimate refund amount.
Because the newly granted balance acts as real, spendable store credit, it can be immediately leveraged to settle future platform invoices or provision additional services, resulting in direct financial and resource loss to the operator.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/paymenter/paymenterto a version that resolves this vulnerability.Fixed in 1.5.7 - Configuration
Ensure the downgrade implementation in `app/Livewire/Services/Upgrade.php::doUpgrade()` uses transactional safety/locking so that the eligibility check (pending upgrade existence) and the credit refund update cannot be interleaved across concurrent requests.
Database transaction isolation / row-level locking = enclose downgrade flow in a DB transaction and acquire row-level locks (e.g., via `lockForUpdate()`) spanning the `Service::upgradable` eligibility check through the `$credit->increment('amount', abs($price))` credit update - Compensating control
Add concurrency control to the downgrade eligibility check and credit update (e.g., wrap the eligibility read and the subsequent pending-upgrade insert and credit increment in a single DB transaction, and use pessimistic locking such as `lockForUpdate()` on the relevant user/service rows) to prevent multiple parallel downgrade requests from bypassing the guard simultaneously.
Event History
Frequently Asked Questions
Who can exploit this issue?
An authenticated user with the ability to submit service downgrade requests can exploit it by sending multiple downgrade requests concurrently. The vulnerability does not require user interaction.
What is the impact of successful exploitation?
Concurrent requests can each pass the pending-upgrade check and trigger a credit increment, allowing multiple refunds for one service downgrade. The stated impact is integrity loss; confidentiality and availability are not affected.
How can I tell whether my deployment is affected?
Review the downgrade path in app/Livewire/Services/Upgrade.php::doUpgrade(). It is affected if the pending-upgrade eligibility check and subsequent credit update are not protected by a database transaction and pessimistic row-level locking.
What should be done if an update cannot be applied immediately?
The provided information identifies the missing transactional and row-locking protections as the cause. A mitigation should serialize the eligibility check, pending-upgrade creation, and credit update so concurrent downgrade requests cannot proceed independently.