The Pot contract currently lacks robust handling for ERC20 tokens that do not behave according to the ERC20 standard. This can lead to situations where the contract's functions, such as transferring tokens, fail silently, potentially allowing for a Denial of Service (DoS) attack.
The Pot contract uses transfer
and transferFrom
functions to handle token transfers. If a malicious or non-standard ERC20 token is used, these functions may return false, causing the transfer to fail without reverting the transaction. This could lead to a situation where the contract is unable to operate as intended, blocking the execution of critical functions like claiming rewards or closing the pot.
Deploy a malicious ERC20 token that always fails on transfer
.
Deploy the Pot contract and attempt to fund it using the malicious token.
Attempt to claim rewards or close the pot, which should fail due to the token's behavior.
Denial of Service (DoS): The contract can be rendered inoperable if a malicious or non-standard token is used.
Loss of Funds: Users might lose their staked funds or rewards if the contract fails to handle the token properly.
Security Risk: The integrity of the entire system could be compromised, leading to potential exploitation by malicious actors.
Manual code review
Fuzz testing with various ERC20 token implementations
Use SafeERC20: Implement the SafeERC20 library for all token transfers to ensure that any failure in token operations is handled correctly and that the transaction reverts on failure.
Validation Checks: Add validation checks for the token before accepting it in the contract.
The SafeERC20
library should be used for all token transfers to ensure that any failure in token operations is handled correctly. This prevents the contract from being vulnerable to Denial of Service (DoS) attacks caused by non-standard or malicious ERC20 tokens.
Modified Function:
Test Case:
Ensure that the contract validates that the token behaves according to the ERC20 standard before accepting it. This prevents non-standard tokens from being used within the contract.
Modified Constructor:
Test Case:
Ensure that the claim process properly checks for the validity of the claim, ensuring that players can only claim their rightful rewards.
Modified Function:
Test Case:
When closing the pot, ensure that the rewards are distributed correctly, and the remaining rewards are set to zero to prevent re-entrancy or double-spending issues.
Modified Function:
Test Case:
During this audit, we identified critical vulnerabilities in the handling of ERC20 tokens, particularly concerning malicious token behavior. By integrating the SafeERC20
library and enhancing key functions, we mitigated these risks, ensuring that your contract is now both secure and robust. These improvements not only protect against potential exploits but also reinforce the integrity and trustworthiness of your project.
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.