Attacker can make claimed staking incentives irredeemable on Gnosis Chain
The GnosisDepositProcessorL1 contract allowed callers to set an arbitrarily low gas limit for cross-chain messages, so a message could fail on L2 due to out-of-gas. An attacker could repeatedly claim staking incentives with an insufficient gas limit, making them irredeemable on L2 and requiring governance intervention to recover.
Submitted by EV_om
https://github.com/code-423n4/2024-05-olas/blob/3ce502ec8b475885b90668e617f3983cea3ae29f/tokenomics/contracts/staking/GnosisDepositProcessorL1.sol#L77 https://github.com/code-423n4/2024-05-olas/blob/3ce502ec8b475885b90668e617f3983cea3ae29f/tokenomics/contracts/staking/GnosisDepositProcessorL1.sol#L90
Vulnerability details
The GnosisDepositProcessorL1 contract is responsible for bridging OLAS tokens and messages from L1 to the GnosisTargetDispenserL2 contract on Gnosis Chain. When calling claimStakingIncentives() or claimStakingIncentivesBatch() on the Dispenser contract for a nominee on Gnosis, it calls _sendMessage() internally to send the incentive amounts and any necessary funds to L2.
If the transferAmount has been reduced to 0 due to sufficient withheld funds on Gnosis, it only sends a message via the Arbitrary Message Bridge (AMB) to process the claimed incentives.
However, when sending this message, the caller provides a gasLimitMessage parameter to specify the gas limit for executing the message on L2. There is no lower bound enforced on this value, although it is required to be >= 100 internally by the AMB. If the caller sets gasLimitMessage too low, the message will fail to execute on L2 due to out of gas.
Because the Gnosis AMB provides no native way to replay failed messages, if a message fails due to insufficient gas, the claimed staking incentives will be irredeemable on L2. An attacker could intentionally grief the protocol by repeatedly claiming incentives with an insufficient gas limit, causing them to be lost.
While the protocol could call processDataMaintenance() on L2 with the data from the cancelled message to recover, this would require passing a governance proposal. Given that this attack can be carried out any number of times (e.g. as often as possible and with a different target each time), this can considerably impact the functioning of the protocol hence I believe Medium severity is justified.
Impact
An attacker can make legitimately claimed staking incentives irredeemable on L2 by setting an insufficient gas limit when claiming. This would require governance intervention each time to recover the lost incentives.
Proof of Concept
- Some amount of OLAS is withheld in the
GnosisTargetDispenserL2contract. - The amount is synced to the Dispenser on L1 via
GnosisTargetDispenserL2.syncWithheldtokens(). - Attacker calls
claimStakingIncentives()on theDispensercontract for a nominee on Gnosis Chain that has accumulated less rewards than the withheld amount, providing an insufficientgasLimitMessagein thebridgePayload. - Message is sent via AMB but fails to execute on L2 due to out of gas.
- Claimed staking incentives are now stuck and irredeemable on L2.
Recommended Mitigation Steps
Do not allow users to directly specify the gasLimitMessage. Instead, have the GnosisDepositProcessorL1 contract calculate the required gas based on the number of targets and stakingIncentives being processed. A small buffer can be added to account for any minor differences in gas costs.
Alternatively, implement a way to replay failed messages from the AMB, so that irredeemable incentives can be recovered without requiring governance intervention.
Olas mitigated:
The issue has been fixed due to the code re-writing and making the gas limit much higher by default compared to the warden’s concern. Even though there’s no specific PR, the issue is fixed in between all the relevant PRs.
Fixed.
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
Impact
An attacker could make legitimately claimed staking incentives irredeemable on L2, requiring governance intervention each time to recover them.
What the attacker needed
Withheld tokens synced to L1; attacker can call claimStakingIncentives
The fix
The issue was fixed by rewriting the code to set a much higher default gas limit, and the project confirmed it as fixed.
How it was found
- Some OLAS tokens are withheld in the GnosisTargetDispenserL2 contract.
- The withheld amount is synced to the Dispenser on L1.
- The attacker calls claimStakingIncentives() for a nominee with fewer rewards than the withheld amount, providing an insufficient gasLimitMessage.
- The message is sent via the AMB but fails to execute on L2 due to out of gas.
- The claimed staking incentives become stuck and irredeemable on L2.
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.
This report is about a bridge between two blockchains. When someone claims rewards, a message is sent to the other chain to process them. The sender can choose how much computing power (gas) that message gets. If they choose too little, the message fails and the rewards are stuck. An attacker can do this on purpose to cause trouble.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.