The Fees contract in the provided Solidity code snippet contains an open access vulnerability in the sellProfits method, which could potentially allow any user or contract to swap the contract's balance into any desired token.
The sellProfits method is set as public and without any restrictions or access control mechanisms. This means that any external actor (individuals, contracts) can call this method and initiate a token swap, converting all available _profits tokens to WETH, which could result in unauthorized and possibly malicious transactions.
This method, when called, swaps the _profits token for WETH (Wrapped Ether). The code lacks any mechanism to prevent unauthorized users from executing this function, resulting in a potential vulnerability.
If exploited, this vulnerability can lead to unauthorized and potentially malicious token swaps, it could allow an attacker to manipulate the contract for their own advantage.
Manual review.
It is highly recommended to incorporate access control mechanisms into the sellProfits method. The OpenZeppelin library provides simple and effective solutions for role-based access control. A modifier that checks if the caller has the appropriate role before executing the function could prevent unauthorized usage. Implementing an onlyOwner or onlyAuthorized modifier could be an effective way to restrict access to this function. Here is a simple example:
The onlyOwner modifier checks that the sender of the transaction is the owner before the execution of the function continues. The owner address could be set at the contract's deployment.
Please note that this is a simple solution and your exact implementation might require more complex access control. For instance, you might want to use OpenZeppelin's AccessControl contract to create more granular roles and permissions.
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.