Summary
The addRoute
function in the contract increments the nRoutes
counter indefinitely without imposing any upper limit. This unbounded growth can result in gas exhaustion, operational inefficiencies, and potential denial-of-service (DoS) conditions. Without proper safeguards, the protocol is vulnerable to route flooding attacks or unintended operational constraints.
Technical Details
The addRoute
function continuously increments the nRoutes
counter and appends new routes to mappings (routes
, swapParams
, pools
) without enforcing a cap on the total number of routes. This design allows unrestricted addition of routes, leading to exponential gas consumption during route enumeration or processing.
Potential Attack Scenarios
Setup: A malicious Manager exploits their role to call addRoute
repeatedly, adding a large number of routes to the mappings.
Execution: The nRoutes
counter grows indefinitely, increasing storage usage and operational overhead.
Impact: Critical functions that depend on or iterate over routes (e.g., claimAndSwap
) fail due to gas constraints, effectively halting the protocol.
Setup: During operations, a function such as claimAndSwap
processes or references all routes added to the contract.
Execution: The gas cost of processing grows linearly with the number of routes, eventually exceeding block gas limits.
Impact: Transactions fail, user deposits and withdrawals are disrupted, and yield generation halts.
Setup: The contract accumulates a large number of inactive or obsolete routes over time.
Execution: Storage usage grows, leading to higher operational costs for all users interacting with the contract.
Impact: Reduced efficiency, increased transaction fees, and degraded user experience.
Impact
Operational Risk: Unrestricted growth in nRoutes
disrupts core functions, potentially leading to protocol downtime.
Gas Exhaustion: Iterative operations on excessively large route mappings become infeasible, risking DoS conditions.
Financial Risk: Users experience delayed or failed transactions, undermining trust in the protocol.
Mitigation Recommendations
Set a maximum limit on the number of routes that can be added, preventing unbounded growth:
Enable authorized roles to remove or deactivate unused routes:
Implement automated or administrative processes to clean up obsolete routes, ensuring efficient resource usage.
Proof of Concept (PoC)
Deploy the contract with the current addRoute
implementation.
Use a script or bot to call addRoute
repeatedly, incrementing nRoutes
indefinitely.
Attempt to execute a function that iterates over or relies on routes.
Observe the transaction failure due to gas exhaustion or increased storage usage.
Attempt to add more routes than the specified MAX_ROUTES
limit.
Observe a revert with the message: "Maximum number of routes reached."
Remove unnecessary routes and verify that mappings and storage are updated correctly.
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.