Reentrancy in withdraw function #148
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
This issue or pull request already exists
Lines of code
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/Shelter.sol#L52-L59
Vulnerability details
Description
The contract was found vulnerable to Reentrancy attack. It was noticed that the function
withdraw
makes an external call to another untrusted address or a contract before it resolves any effects at line https://github.com/code-423n4/2022-02-concur/blob/main/contracts/Shelter.sol#L57If the attacker controls the untrusted contract, they may be able to call back to the original function, repeating interactions that would have otherwise not run after the effects were resolved.
Impact
Reentrancy vulnerabilities can lead to various critical outcomes such as token stealing and burning. Adversaries may exploit the bug to mint tokens without any limitations or extract all the tokens out of the contract.
PoC
Check the
withdraw
function and we will notice it is missingnonReentrant
modifier.https://github.com/code-423n4/2022-02-concur/blob/main/contracts/Shelter.sol#L52-L59
Recommended Mitigation Steps
Introduce a modifier
nonreentrant
to prevent Reentrancy vulnerabilities by implementing a Check-Effects-Interactions pattern.The text was updated successfully, but these errors were encountered: