Part 2

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

"Reentrancy & Arithmetic Overflow Risks"

Summary

The createTradingAccount function and others contains vulnerabilities that can be exploited by attackers. These include:

  • Reentrancy vulnerability due to the modification of internal state while interacting with external contracts.

  • Arithmetic overflow vulnerability when incrementing IDs using a uint variable.

  • Denial-of-Service (DoS) attack potential if users are not properly checked for sufficient balance before creating accounts.

Vulnerability Details

  1. Reentrancy Vulnerability: The contract's use of the createTradingAccount function to create new trading accounts while interacting with external contracts (IReferral, IPerpetualsEngine) can lead to re-entrant attacks if not properly handled.

  2. Arithmetic Overflow Vulnerability: Incrementing IDs using a uint variable without proper checks or protections in place can cause arithmetic overflows, leading to unexpected behavior and crashes

Impact

If exploited by attackers:

  • Reentrancy vulnerability: Attackers could create accounts repeatedly while draining the contract's funds.

  • Arithmetic overflow vulnerability: The ID incrementation mechanism might fail due to an overflow error, causing unpredictable account creation outcomes.

Tools Used

The following tools can help identify vulnerabilities in smart contracts:

1. Truffle Suite: A popular development environment for Ethereum-based projects that includes the Truffle compiler.
2. OpenZeppelin's ReentrancyGuard library.

  1. Solidity documentation and resources from reputable sources like Etherscan or GitHub.

Recommendations

To mitigate these risks, consider implementing a reentrancy guard (e.g., using OpenZeppelin's ReentrancyGuard) around critical sections of code that modify state while interacting with external contracts. Use safe arithmetic operations to prevent overflows when incrementing IDs.Trading Account Branch Testnet: Reentrancy & Arithmetic Overflow Risks"

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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