The QuantAMM storage contract has severe issues with sign bit handling, leading to sign flips, value corruption, and inconsistent treatment of negative numbers. This is more severe than initially thought, as it can lead to complete reversal of intended operations.
Testing reveals multiple critical issues:
Sign Bit Flips:
Negative values can become positive
No warning when sign changes
Affects small and large values differently
Value Corruption:
Small values (both + and -) -> 0
Large values -> clamped to ±2e9
Negative values -> sometimes flipped positive
Inconsistent Handling:
Zero preserves its sign
Some negatives preserve sign, others don't
Large negatives get corrupted values
Interest Rate Inversion:
Set negative interest rate (-2%)
Rate gets sign-flipped
Protocol charges +2% instead
Penalty Reversal:
Apply negative penalty (-5 tokens)
Value gets sign-flipped
User receives +5 tokens instead
Balance Manipulation:
User with negative balance (-100)
Balance gets sign-flipped
User now has positive balance
Severity: CRITICAL
Technical Impact:
Sign bit losses
Value corruptions
Inconsistent negative handling
Silent sign flips
Economic Impact:
Interest rate reversals
Penalty reversals
Balance manipulations
Mathematical operation inversions
Implement Strict Sign Checking:
Add Sign Preservation Checks:
Emit Events for Sign Changes:
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.