Skip to content
Smart contracts Audit finding Intermediate

Should use >= instead of >

A comparison in the VaultTracker contract used a strict greater-than instead of greater-than-or-equal, so removing or transferring notional could leave a tiny dust amount behind. An attacker could repeatedly trigger this to leak small amounts of value from the contract.

oyc_109 Follow

Originally disclosed on Code4rena

Submitted by oyc_109

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/VaultTracker/VaultTracker.sol#L86

https://github.com/code-423n4/2022-07-swivel/blob/fd36ce96b46943026cb2dfcb76dfa3f884f51c18/VaultTracker/VaultTracker.sol#L158

The comparison should be ‘a >= vlt.notional’ instead of a > vlt.notional.

Otherwise dust amounts will always be left in vlt.notional when calling removeNotional() or transferNotionalFrom().

JTraversa (Swivel) confirmed, but disagreed with severity and commented:

While the leakage is potentially … 1 wei, its leakage nonetheless and a frontend would surely provide the max amount most of the time leading to reverts.

Maybe a quick severity review from wardens but happy with where its at.

bghughes (judge) commented:

I agree that this is quite low stakes, given that there is non-zero potential leakage I think the warden should get credit for this as a Medium Risk vulnerability. Per the C4 juging criteria:

2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

robrobbins (Swivel) resolved:

Addressed: https://github.com/Swivel-Finance/gost/pull/423.


The original report as published on Code4rena, by oyc_109. 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 comparison used a strict greater-than operator where greater-than-or-equal was needed, so an exact balance match was not cleared.

Impact

Only a tiny amount (potentially one wei) could leak per call, and a frontend sending the maximum amount would often cause reverts instead.

What the attacker needed

Ability to call removeNotional or transferNotionalFrom

The fix

The comparison was changed to greater-than-or-equal and the issue was addressed in a pull request.

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.

Smart contracts track balances with numbers. When a check uses 'greater than' instead of 'greater than or equal to', a tiny leftover amount (called dust) can stay stuck in the contract. Over many calls, that leftover could add up to a small loss.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by oyc_109

View all

3 more disclosed reports, best first.

More from Swivel v3 contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.