The primary goal of the refund
function is to facilitate the return of funds to the user.
The refund function has modifier nonReentrant
which is custom implementation for guard against the reetrancy attack, Unfortunitly this modifier has vulnerability because not set proprly locked
flag status - not protoct prperly agenst this attack. In the fuction refund
there are two inner functions _refundERC20
and _refundETH
which not follow the CEI pattern and are vulnerable for the reetrancy attack. In the function _refundERC20
the balances for tokens are set after safeTransfer
call.
Similar sitautaion has place in the _refundETH
which is the most dangerouse.
Please check POC
When a vulnerable client calls the refund
function, which in turn calls _refundETH
, the transfer is intercepted by the receive
function in the MaliciousContract
. The receive
function then calls refund()
again, allowing the attacker to drain all ETH funds."
All ETH founds from the protocl can be hacked.
manual review
Please follow the CEI pattern especialy for the _refundETH
function.
Alternatively, you can use OpenZeppelin's implementation for the nonReentrant
guard. OpenZeppelin's solutions are thoroughly tested and widely adopted in the industry, ensuring a high level of security and reliability for your smart contracts. Using their nonReentrant
modifier will help protect your contract from reentrancy attacks and avoid potential vulnerabilities.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.