Due to an incorrect approval check, the if condition will always lead to transaction reversal when withdrawal is requested for a holder (who is not msg.sender). This can lead to user unable to withdraw funds
Proof of Concept
Let us see the withdraw function
function withdraw(uint256 underlyingAmount, address receiver, address holder) external override returns (uint256 principalAmount){
...
// Transfer logic
// If holder is msg.sender, skip approval check
if (holder == msg.sender) {
...
}
else {
uint256 allowed = allowance[holder][msg.sender];
if (allowed >= previewAmount) {
revert Approvals(allowed, previewAmount);
}
allowance[holder][msg.sender] -= previewAmount;
...
}
}
Assume User A was approved amount 5 by User B such that
allowance[B][A] = 5;
User A calls the withdraw function with holder as B. Since holder is not msg.sender, this moves to else condition.
Lines of code
https://github.com/code-423n4/2022-07-swivel/blob/main/Creator/ZcToken.sol#L111
Vulnerability details
Impact
Due to an incorrect approval check, the if condition will always lead to transaction reversal when withdrawal is requested for a holder (who is not msg.sender). This can lead to user unable to withdraw funds
Proof of Concept
In this case lets assume previewAmount is 4
allowed is calculated as 5 as allowance[B][A] = 5;
Ideally User A should be able to withdraw since his allowance is greater than withdrawal amount but due to below incorrect condition withdraw fails
Other Occurences
The redeem function also suffers from same fate where approval is incorrectly checked and same recommendation needs to be applied
Recommended Mitigation Steps