The approve
function in the CapitalPool
contract lacks proper input validation, allowing any address, including invalid or malicious contracts, to be approved. This can lead to unexpected behavior and potential security risks.
The approve
function does not validate the tokenAddr
parameter, allowing any address to be passed. This can be exploited by an attacker to cause the contract to interact with unintended or malicious contracts.
forge test --match-path test/CapitalPoolTest.t.sol
[⠊] Compiling...
[⠰] Compiling 1 files with Solc 0.8.26
[⠔] Solc 0.8.26 finished in 1.30s
Compiler run successful!
Ran 1 test for test/CapitalPoolTest.t.sol:CapitalPoolTest
[PASS] testNoInputValidation() (gas: 10627)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 578.00µs (75.00µs CPU time)
Ran 1 test suite in 5.42ms (578.00µs CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
The contract may interact with unintended addresses, leading to unexpected behavior.
If a malicious contract is approved, it could exploit the lack of validation to perform unauthorized actions.
Invalid addresses can cause transaction failures, potentially leading to denial of service.
Manual review
Foundry
Make sure tokenAddr
is a valid contract address before proceeding with approval.
Add access control to ensure only tokenManager
can call the approve
function.
This is at most low severity, even though giving max approvals shouldn't be permisionless, the respective tokenManager address is retrieved from the TadleFactory contract whereby the trusted guardian role is responsible for deploying such contracts as seen [here](https://github.com/Cyfrin/2024-08-tadle/blob/04fd8634701697184a3f3a5558b41c109866e5f8/src/factory/TadleFactory.sol#L68). Since the user still has to go through the PreMarkets/DeliveryPlace contracts to perform market actions, this max approval cannot be exploited.
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.