Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Reentrancy Vulnerability in Token Transfer Mechanism of `MarketMakingEngineConfiguration::distributeProtocolAssetReward` Function

Summary

The function distributeProtocolAssetReward in its current implementation uses safeTransfer to send tokens to fee recipients. If any of the recipients is a malicious contract, this could potentially lead to a reentrancy attack, where the recipient's fallback function might re-enter the contract and perform unintended operations before the state is updated. This could compromise the contract’s security and functionality.

Vulnerability Details

Reentrancy Attack: The function performs a state-changing operation safeTransfer by sending tokens to an address. If that address is a contract, it might call back into the contract during its fallback function, leading to a reentrancy vulnerability.
No Reentrancy Guard: The function does not use any reentrancy protection mechanisms, such as the nonReentrant modifier from OpenZeppelin’s ReentrancyGuard, which would prevent reentrancy attacks.

Impact

If a fee recipient is a malicious contract, it could exploit this vulnerability to manipulate the contract’s state or perform unauthorized actions.
An attacker could drain funds or disrupt the reward distribution process by repeatedly re-entering the contract during the token transfer.
Loss of Protocol Integrity.

Tools Used

Manual code review.

Recommendations

Implement Reentrancy Protection: Use OpenZeppelin's ReentrancyGuard contract to prevent reentrancy attacks by adding the nonReentrant modifier to the function.

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
function distributeProtocolAssetReward(Data storage self, address asset, uint256 amount) nonReentrant internal {
Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.