-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loss of funds when redeeming Decent tokens on chains that dont support ETH as gas token #505
Comments
raymondfam marked the issue as sufficient quality report |
Would indeed be a serious issue if the vulnerability is valid. |
raymondfam marked the issue as primary issue |
wkantaros (sponsor) confirmed |
The Warden demonstrates a discrepancy in the system concerning the I investigated the overall deployment system of the Sponsor and indeed validated that the The problem lies in the actual exploitability of the function paths defined. The entire system would not really behave as the Warden details. Specifically,
In relation to the While overall flawed, the described execution paths behave as expected and cannot be exploited to force fund loss for the system maliciously. Cross-chain transfers of the As a result of all this, I consider the submission invalid but the Sponsor should definitely re-evaluate how they have approached multi-chain deployments of their system as they are presently illegible and permit reverting functionality that should be inaccessible due to a more descriptive error message. I also invite the Sponsor to re-evaluate and whether they have detected a valid exploitation path based on the data supplied by the Warden. |
alex-ppg marked the issue as unsatisfactory: |
After discussions with the Sponsor, I stand by my original invalidation judgment due to the impossibility of exploiting the vulnerability. To note, for a user to be attacked the attacker would have to sacrifice an equal value of the funds they wish to damage the user of. This is not acceptable as a vulnerability of HM risk but rather a QA (L) issue of code misbehavior that should be prevented. Based on this, I will proceed with downgrading the submission to QA (L) as it details a valid problem in the code concerning |
alex-ppg removed the grade |
alex-ppg changed the severity to QA (Quality Assurance) |
I will award this submission a |
alex-ppg marked the issue as grade-b |
Lines of code
https://github.com/decentxyz/decent-bridge/blob/7f90fd4489551b69c20d11eeecb17a3f564afb18/src/DecentEthRouter.sol#L285-L291
https://github.com/decentxyz/decent-bridge/blob/7f90fd4489551b69c20d11eeecb17a3f564afb18/src/DecentEthRouter.sol#L275-L276
https://github.com/decentxyz/decent-bridge/blob/7f90fd4489551b69c20d11eeecb17a3f564afb18/src/DecentEthRouter.sol#L313-L319
Vulnerability details
Impact
High - imho the impact of this issue is should be classified as high due to its substantial likelihood, simplicity in execution (requiring only a single function call), and the potential for substantial financial losses. Users face a considerable risk, as demonstrated by scenarios such as swapping 1 Ethereum for 1 Matic, resulting in significant loss of funds.
Proof of Concept
In some chains, such as Polygon/AVAX, Ethereum is not recognized as their gas token. This distinction is addressed in the
DecentEthRouter
by configuring thegasCurrencyIsEth
variable as eithertrue
orfalse
. However, some sections of bothDecentEthRouter
andDecentBridgeExecutor
(as mentioned below) are mistaking Ethereum as the native chain token without checkinggasCurrencyIsEth
.DecentEthRouter::redeemEth:
When a user wants to redeem their Decent tokens (on Polygon/Avax) using this function, the user's Decent tokens are transferred to the contract, WETH is withdrawn (burned), and native chain tokens (e.g., Matic in the Polygon example) are sent to the user. This implies that if, for example, Alice decides to redeem her 10 dcntEth tokens, she will receive 10 Matic tokens, which are worth only 7 USD, resulting in the loss of all her 10 WETH (worth 22,000 usd)
DecentBridgeExecutor::_executeETH:
Also in this function, WETH is withdrawn and Matic/Avax are received which might be useless when calling the target.
this function results in loss of funds for user (
from
) and stuck funds inDecentBridgeExecutor
which can be withdrawn by a malicious actor.NOTE: there might not be enough MATIC/AVAX in router in order to be sent to user, however, a malicious actor is able to fund contract with enough MATIC/AVAX.
Code PoC:
while the issue is clear, i have decided to put a code PoC (Copy from next line to before
Tools Used
and paste in a new file, no additional settings needed)://SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {Test, console, console2} from "forge-std/Test.sol";
import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
import {ERC20Mock} from "@openzeppelin/contracts/mocks/ERC20Mock.sol";
interface IWETH {
function withdraw(uint amt) external payable;
}
contract MockRouter is Test {
IWETH polygon_weth = IWETH(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619);
IWETH wrappedMatic = IWETH(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270);
}
Tools Used
Manual review
Forge testing
Mitigation steps
While I don't have a clear solution in mind yet, I would suggest first checking
gasCurrencyIsEth
to determine whether the chain supports ETH as the gas token or not. If it does not (false), then proceed to swap WETH for the native chain token (e.g., WETH => MATIC) and sendMATIC
tokens to the user. Alternatively, consider not allowing certain functions to be executed if the chain does not support ETH as the native gas token.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: