The redeem related functions are likely to be blocked
The PirexGmx contract's redeem functions can be blocked because GMX's GlpManager enforces a cooldown period after deposits, during which redemptions fail. An attacker could repeatedly deposit tiny amounts to keep the cooldown active, preventing users from retrieving their funds.
KingNFT Follow with xiaoming90, ladboy233 and 3 others
Originally disclosed on Code4rena
Submitted by KingNFT, also found by xiaoming90, ladboy233, 0x52, rvierdiiev, and HE1M
Impact
The following redeem related functions are likely to be blocked, users will not be able to retrieve their funds.
function _redeemPxGlp(
address token,
uint256 amount,
uint256 minOut,
address receiver
);
function redeemPxGlpETH(
uint256 amount,
uint256 minOut,
address receiver
);
function redeemPxGlp(
address token,
uint256 amount,
uint256 minOut,
address receiver
);
Proof of Concept
The GlpManager contract of GMX has a cooldownDuration limit on redeem/unstake (\_removeLiquidity()). While there is at least one deposit/stake (\_addLiquidity()) operation in the past cooldownDuration time, redemption would fail. Obviously this limitation is user-based, and PirexGmx contract is one such user.
Current setting of `cooldownDuration` is 15 minutes, the max value is 2 days.
https://arbiscan.io/address/0x321f653eed006ad1c29d174e17d96351bde22649#readContract
Due to the above limit, there are 3 risks that can block redemption for Pirex users.
- The normal case
Let’s say there is 10% GMX users will use Pirex to manage their GLP.
By checking recent history of GMX router contract, we can find the average stake interval is smaller than 1 minute https://arbiscan.io/address/0xa906f338cb21815cbc4bc87ace9e68c87ef8d8f1
Let’s take
averageStakeIntervalOfGMX = 30 seconds
So if Pirex has 10% of GMX users, then
averageStakeIntervalOfPirex = 30 ÷ 10% = 300 seconds
The probability of successfully redeeming is a typical Poisson distribution: https://en.wikipedia.org/wiki/Poisson_distribution.
With
λ = cooldownDuration ÷ averageStakeIntervalOfPirex = 15 * 60 ÷ 300 = 3
k = 0
So we get
P ≈ 1 ÷ (2.718 * 2.718 * 2.718) ≈ 0.05
Conclusion
If Pirex has 10 % of GMX users, then the redemption will fail with 95% probability.
A full list of % of GMX users versus failure probability of redemption
1% : 26%
5% : 78%
10% : 95%
20% : 99.75%
30% : 99.98%
- The attack case
If an attacker, such as bad competitors of similar projects, try to exploit this vulnerability.
Let’s estimate the cost for attack.
An attacker can deposit a very small GLP, such as 1 wei, so we can ignore the GLP cost and only focus on GAS cost.
By checking the explorer history https://arbiscan.io We are safe to assume the cost for calling
depositGlpETH() or depositGlp is
txCost = 0.1 USD
To block redemption, attacker has to execute a deposit call every 15 minutes, so
dailyCost = 24 * (60 / 15) * 0.1 = 9.6 USD
yearCost = 365 * 9.6 = 3504 USD
Conclusion
If an attacker wants to block Pirex users funds, his yearly cost is only about 3.5k USD.
- GMX adjusts protocol parameters
If GMX increases cooldownDuration to 2 days, it will obviously cause redemption not working.
Tools Used
VS Code
Recommended Mitigation Steps
Reserve some time range for redemption only. e.g. 1 of every 7 days.
kphed (Redacted Cartel) confirmed
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the PirexGmx contract does not account for GMX's user-based cooldown on redemptions, so any deposit by any user resets the cooldown for the whole contract.
Impact
Users may be unable to redeem their funds with high probability, and an attacker could block redemptions for about 3.5k USD per year; the text also notes that if GMX increases the cooldown to 2 days, redemption would stop working.
What the attacker needed
PirexGmx holds GLP; GMX cooldown active; attacker can deposit small GLP
The fix
The text recommends reserving a time range for redemption only, such as one day out of every seven.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you put money into a shared pool, you usually expect to take it out whenever you want. Here, the pool has a rule: after any deposit, nobody can withdraw for a short period. Because many people use the same pool, frequent small deposits can keep that waiting period active almost all the time, so ordinary users cannot get their money back.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.