Sushi Trident contest phase 1 - hack3r-0m's results

Community-driven DeFi platform

General Information

Platform: Code4rena

Start Date: 16/09/2021

Pot Size: $200,000 SUSHI

Total HM: 26

Participants: 16

Period: 14 days

Judge: alcueca

Total Solo HM: 13

Id: 29

League: ETH

Sushi

Findings Distribution

Researcher Performance

Rank: 8/16

Findings: 2

Award: $6,618.60

🌟 Selected for report: 4

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: hack3r-0m

Also found by: broccoli

Labels

bug
3 (High Risk)
sponsor confirmed

Awards

317.693 SUSHI - $3,971.16

External Links

Handle

hack3r-0m

Vulnerability details

https://github.com/sushiswap/trident/blob/9130b10efaf9c653d74dc7a65bde788ec4b354b5/contracts/libraries/MathUtils.sol#L22 the difference is computed incorrectly when a > b.

As it only used in within1 function, scope narrows down to where difference(a, b) <= 1; is exploitable.

cases where difference(a, b) <= 1 should be true but is reported false:

  • where b = a-1 (returned value is type(uint256).max)

cases where difference(a, b) <= 1 should be false but is reported true:

  • where a = type(uint256).max and b = 0, it returns 1 but it should ideally return type(uint256).max

within1 is used at the following locations:

It is possible to decrease the denominator and increase the value of the numerator (when calculating y) using constants and input to make within1 fail

Mitigation:

Add else condition to mitigate it.

unchecked { if (a > b) { diff = a - b; } else { diff = b - a; } }

(re-submitting this issue after withdrawing past one since I forgot to add more details and POC)

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter