Skip to content
Access control Audit finding Intermediate

BasePool.swap() Is Callable By Anyone

The BasePool.swap() function lacks an onlyRouter modifier, allowing anyone to call it directly and bypass the input validation performed by VaderRouter._swap(). An attacker could potentially exploit this to perform swaps without the necessary checks.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

Impact

The BasePool.swap() function differs from its implementation in BasePoolV2.swap() in which it lacks an onlyRouter modifier. This ensures that users cannot call this function directly as VaderRouter._swap() performs some necessary input validation which can be bypassed by directly calling BasePool.swap().

Proof of Concept

Tools Used

Manual code review.

Recommended Mitigation Steps

Consider adding an onlyRouter modifier to the BasePool.swap() functions to ensure users cannot directly call these functions.

SamSteinGG (Vader) disputed:

The pool contracts, similarly to Uniswap V2, are never meant to be interacted with directly.

alcueca (judge) commented:

That’s what the modifier would do.

SamSteinGG (Vader) commented:

@alcueca They are never meant however it should still be possible to do so. With Uniswap V2, it is possible to interact with the contracts directly however doing so (without using a smart contract) will result in the same vulnerabilities as described in the issue. This is not intended usage and as such does not constitute an issue unless it is implied that the Uniswap V2 implementation is incorrect.

The original report as published on Code4rena, by leastwood. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the BasePool.swap() function was not protected with an onlyRouter modifier, unlike BasePoolV2.swap(), so it can be called by any address.

Impact

An attacker could call BasePool.swap() directly, bypassing the router's input validation, though the project disputed that this constitutes a vulnerability because direct interaction is possible in Uniswap V2 as well.

What the attacker needed

None

The fix

The function should be fixed by adding an onlyRouter modifier to BasePool.swap() to prevent direct calls.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

In a decentralised exchange, a router contract normally checks that a swap request is valid before passing it to a pool contract. Here, the pool contract can be called directly, skipping those checks. This means someone could interact with the pool in ways the developers did not intend.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by leastwood

View all

70 more disclosed reports, best first.

More from Vader Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.