Ability to use emergencyWithdraw
in RdpxDecayingBonds.sol
may raise red flags for Investors
#687
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-2031
low quality report
This report is of especially low quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/decaying-bonds/RdpxDecayingBonds.sol#L89-L107
Vulnerability details
Impact
emergencyWithdraw
allows to withdraw all the existing tokens from the contract by users withDEFAULT_ADMIN_ROLE
role.Even if the
DEFAULT_ADMIN_ROLE
is trustworthy, having a rug-vector in the contract may have a negative impact on the protocol's reputation. Multiple online tools report contract with rug-pulls vector as a high-risk: (e.g.: https://twitter.com/RugDocIO/status/1411732108029181960). Even this function had been created with good intentions, it's often associate with rug pull, especially that rug pulls are not uncommon in DeFi. Rug pull vectors increases a risk for investors to lose their hard earn money, thus it has a negative impact on the smart contract's reputation.Similar findings which had been classified at Code4rena as Medium:
Having this function available is not only a huge red flag for the Investors (malicious admin can withdraw tokens whenever he/she wants), but it is also huge centralization risk.
The
DEFAULT_ADMIN_ROLE
is being set inconstructor
and it's a single EOA.Having a single EOA as a single
DEFAULT_ADMIN_ROLE
role is a large centralization risk and a single point of failure. A single private key may be taken in a hack, or the sole holder of the key may become unable to retrieve the key when necessary.User with
DEFAULT_ADMIN_ROLE
role holds a lot of power within the contract. Compromise of account with this role puts the contract's integrity at risk.The very similar issue had been evaluated during a previous Code4rena audit as an issue with Medium severity:
Proof of Concept
File: contracts/decaying-bonds/RdpxDecayingBonds.sol
While calling
emergencyWithdraw
by user withDEFAULT_ADMIN_ROLE
, every token inside the contract will be sent tomsg.sender
. This function should be considered as rug-pull vector, since it allows to drain the whole contract's balance. Moreover, in a contrary to what the documentation of this function says:File: contracts/decaying-bonds/RdpxDecayingBonds.sol
not only the owner of the contract, but everyone with
DEFAULT_ADMIN_ROLE
can call this function. SinceRdpxDecayingBonds
inherits fromAccessControl
- there's agrantRole()
function available which allows to create more than one user withDEFAULT_ADMIN_ROLE
role. This makes this function to violate its documentation, since more than just a contract's owner can callemergencyWithdraw
- everyone withDEFAULT_ADMIN_ROLE
can call this function. This increases the risk, since in a group of accounts (withDEFAULT_ADMIN_ROLE
role), the more users, the higher the risk is that one of them will become malicious or will become a victim to a hack (e.g. got their private key stolen) - due to previously mentioned centralization risk.Tools Used
Manual code review
Recommended Mitigation Steps
Multi Sig Address should be hardcoded into the contract to ensure the fund move to a safe wallet whenever
emergencyWithdraw
needs to be called.Moreover, critical admin functions should be protected by timelock - to give users a chance to react when something malicious would be happening.
Severity Evaluation
Impact - High
Users funds are being at risk as
emergencyWithdraw
can rug-pull the whole contract balance.Likelihood - Low
The attack vector is available for
DEFAULT_ADMIN_ROLE
. However, due to centralization risk, and the ability to create multiple of admins bygrantRole
function (more admins means that it's more likely that one of them may become malicious) the risk should be consider as non-negligible.Assessed type
Rug-Pull
The text was updated successfully, but these errors were encountered: