Rescuable::_safe_transfer_from
function lacks thorough token transfer verification, potentially allowing successful calls without actual token transfersSummary:
The _safe_transfer_from
function in the Rescuable contract only checks if the call to transferFrom was successful, without verifying if tokens were actually transferred. While the current risk is low due to admin control over token selection, this could potentially lead to issues if non-standard or malicious tokens are introduced to the system.
Vulnerability Details:
The _safe_transfer_from
function in the Rescuable.sol
contract uses a low-level call to execute the transferFrom function on the token contract:
This implementation only checks if the call was successful (success boolean), but doesn't verify the actual return value of transferFrom
or check if tokens were moved. This could lead to a situation where the function considers a transfer successful even when no tokens have actually been transferred.
Impact:
Proof of Concept:
To demonstrate this vulnerability, we created a mock vulnerable token and a test scenario. File was named RescuableTest3.t.sol
in the test
directory of the project.:
To run the test, we used the following command; forge test --match-path test/RescuableTest3.t.sol -vvvv
The test results showed that the testVulnerableTransferFrom
test passed. The transferFrom
function was called and returned true without actually transferring any tokens. Both balance checks (for the attacker and the user) returned 0, confirming that no actual transfer occurred, yet the function considered the transfer successful.
The current impact is low because:
The admin controls which ERC20 tokens are used in the system, likely choosing reputable, standard-compliant tokens.
The vulnerability would only be exploitable with non-standard or malicious tokens, which are unlikely to be selected by the admin.
However, if a non-standard token were to be introduced, it could potentially lead to:
Incorrect accounting within the protocol
Inconsistencies between expected and actual token balances
Potential for exploits in other parts of the system that rely on this function
Tools Used:
Manual review, Foundry, AI for troubleshooting
Recommended Mitigation:
While the current risk is low, improving the function can enhance the contract's robustness:
Use OpenZeppelin's SafeERC20 library for safer token transfers:
Alternatively, implement a balance check before and after the transfer:
I believe the issues and duplicates do not warrant low severity severity as even if the call to transfers returns false instead of reverting, there is no impact as it is arguably correct given there will be insufficient funds to perform a rescue/withdrawal. This will not affect `tillIn()` as there are explicit balance [checks that revert accordingly](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/core/TokenManager.sol#L255-L260) to prevent allowing creation of offers without posting the necessary collateral
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.