The _withdrawFromEscrow
function is marked as internal, which means it can be called by any function within the same contract or derived contracts. However, there is no access control mechanism to restrict who can call this function. As a result, any contract or function that has access to _withdrawFromEscrow
can be exploited to withdraw tokens from escrow without proper authorization.
contracts that will be affected: https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Bridge.sol#L153-L215
An attacker identifies a function in the contract that calls _withdrawFromEscrow
.
The attacker calls this function, passing the necessary parameters to withdraw tokens from escrow to their own address.
The tokens are transferred from the escrow contract to the attacker's address.
forge test --match-path test/ExploitWithdrawTest.t.sol
[⠒] Compiling...
No files changed, compilation skipped
Ran 1 test for test/ExploitWithdrawTest.t.sol:ExploitWithdrawTest
[PASS] testExploitWithdraw() (gas: 26245)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.59ms (218.80µs CPU time)
Ran 1 test suite in 18.80ms (1.59ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
Attackers can steal tokens from escrow, leading to significant financial loss for legitimate users who have deposited their tokens.
Users may lose trust in the platform due to the potential for unauthorized withdrawals, damaging the platform's reputation.
The platform may face operational challenges in addressing the issue and compensating affected users, leading to potential downtime and increased support costs.
Manual review
Foundry
Use the onlyOwner
modifier or a similar access control mechanism to restrict who can call the _withdrawFromEscrow
function.
Implement role-based access control using OpenZeppelin's AccessControl
library on Starklane(Bridge) contracts to manage permissions more granularly.
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.