crytic / crytic/slither

[False-Positive]: incorrect-shift and incorrect-exp produce 24 High-severity false positives on lib/solady

Open
#3,054 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

## Description

Running Slither on any DeFi project that uses Solady (which is most of them) produces a flood of \incorrect-shift\ and \incorrect-exp\ High-severity findings — all false positives.

## Reproduction

Clone 3FLabs/grunt (https://github.com/3FLabs/grunt), run Slither, observe:

- 19x \incorrect-shift\ — all in \lib/solady/src/utils/FixedPointMathLib.sol\, \lib/solady/src/utils/LibString.sol\, \lib/solady/src/utils/EnumerableSetLib.sol\, \lib/solady/src/auth/OwnableRoles.sol\
- 5x \incorrect-exp\ — all in the same library files

Total: 24 High-severity findings, all in the Solady dependency, all false positives.

## Root cause

Solady uses bitwise XOR (\^\) for operations that have nothing to do with exponentiation — it is an intentional assembly-level pattern for efficient bit manipulation. Slither's \incorrect-exp\ detector treats \^\ as the exponentiation operator (Python semantics), which is incorrect in this context.

Similarly, Slither's \incorrect-shift\ fires on Solady's low-level shift operations that use non-obvious operand ordering for gas optimization.

Both detectors are unable to distinguish between:
1. Code that naively misused \^\ thinking it was an exponent (the actual bug)
2. Code that uses \^\ correctly for XOR or deliberately uses shift ordering (Solady's case)

## Impact

Solady is used by hundreds of production DeFi protocols. Every project that includes it as a dependency gets 20+ High-severity false positives. This significantly degrades the signal-to-noise ratio of Slither and makes it harder to spot real vulnerabilities.

## Suggested fix

Add a library-exclusion mechanism or at minimum document that \--filter-paths lib/\ is necessary when analyzing projects with Solady. A detector-level fix would check whether the contract file has been previously analyzed and accepted into a known-safe registry.

## Environment

- Solady version: current (tested via 3FLabs/grunt, updated 2026-06-30)
- Full analysis: https://github.com/holistis/bug-bounty-intelligence-mcp/blob/main/BENCHMARK.md

Contributor guide

Open the contributing guide

Research direction

Run Slither against 3FLabs/grunt and inspect the incorrect-shift and incorrect-exp detector results in the listed Solady files: FixedPointMathLib.sol, LibString.sol, EnumerableSetLib.sol, and OwnableRoles.sol. Determine how the detectors distinguish genuine misuse from Solady's intentional XOR and shift patterns; done means the 24 reported false positives are suppressed without hiding real findings.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
devtools, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.