omermaksutii/rugproof/integer-issues

Claude Code and agent skill by omermaksutii/rugproof

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Detect integer over/underflow in `unchecked` blocks, downcasting losses, fixed-point precision errors, division-before-multiplication, signed/unsigned mixing. Activate on any arithmetic in `unchecked { }`, `SafeCast`, `uintN(uintM(x))` casts, division and modulo, percentage/basis-points math, AMM share/asset math.

Install

npx vskill@latest install omermaksutii/rugproof/integer-issues

SKILL.md

The same SKILL.md was published earlier as iktok90-design/ai-smart-contract-auditor/integer-issues.

Integer issues detection

When this applies

  • unchecked { … } blocks (Solidity ≥0.8)
  • Downcasts: uint128(x), int256(uint256(x)), uint8(...)
  • Division and modulo
  • Fixed-point math with custom decimal scales
  • Share/asset math in vaults, lending, AMMs
  • Pre-0.8 Solidity code (no built-in overflow checks)
  • Vyper code with unbounded loops
  • Inline assembly arithmetic

Detection patterns

Unchecked overflow on user input (HIGH)
solidity
unchecked {
balance[to] += amount; // ← if amount controlled, can overflow back to 0
}

unchecked is fine for proven-safe accumulators (e.g. ++i in bounded loops), not for value math.

Division before multiplication (HIGH)
solidity
uint256 fee = (amount / 100) * feeBps; // ← truncation; do (amount * feeBps) / 100
Decimal mismatch (HIGH)

USDC = 6 decimals, WETH = 18, WBTC = 8. Mixing without scaling produces silent 1e10–1e12 errors.

solidity
uint256 wethValue = amountUsdc * price; // ← USDC 6dp × price 8dp = 14dp, need 18dp
Downcast loss (HIGH)
solidity
uint128 sharesU128 = uint128(shares); // ← silently truncates if shares > 2^128

Use OZ SafeCast.

Fixed-point precision loss (HIGH)

Compounding interest done as principal * (1 + rate)^t with too-few-decimal rate. Use ray (1e27) or wad (1e18) math via PRBMath / Solady.

Round-direction asymmetry (HIGH for vaults)

ERC-4626 must round shares down on deposit (favor vault) and up on withdraw (favor vault). Reversed direction = donations-style drain. Use OZ Math.mulDiv(_, _, _, Rounding.Down/Up).

Signed/unsigned mixing (HIGH)
solidity
int256 delta = int256(a) - int256(b); // a or b might be > 2^255, becomes negative silently
Modulo zero (revert, but…) (MEDIUM-HIGH if attacker can set divisor=0)
Block-time math on L2 (MEDIUM)

block.timestamp granularity differs (2s on Optimism, 250ms on Arbitrum). Slot-based deadlines can be off.

Sqrt / log integer approximations (MEDIUM)

Custom sqrt implementations are notorious. Use Solady/PRBMath.

Percentage in basis points without bounds (LOW)

fee_bps should be capped (fee_bps <= 10_000).

Severity rubric

PatternSeverity
Unchecked overflow on user inputHigh
ERC-4626 round-direction wrongHigh
Decimal-mismatch in price/balance mathHigh
Downcast losing high bits silentlyHigh
Division before multiplication on financial-critical pathHigh
Custom sqrt/log without overflow proofMedium
Bps fee with no capLow
Loop index underflow in pre-0.8 codeHigh
Modulo-zero on attacker-controlled divisorHigh

Remediation patterns

  • Solidity 0.8.x default checks; only unchecked proven-safe (e.g. ++i in for loops bounded by array length).
  • OZ SafeCast for downcasts.
  • Math.mulDiv (OZ) for multiply-then-divide without intermediate overflow.
  • PRBMath or Solady for fixed-point exp/log/pow.
  • Always scale to a common decimal base before doing math; document the scale.
  • ERC-4626: always use Math.mulDiv(..., Rounding.Down) on deposits, Rounding.Up on withdrawals; or use OZ's ERC4626Upgradeable which handles this.

False-positive notes

  • unchecked { ++i; } in for loops with i < arr.length is the canonical safe use — not a finding.
  • Pre-0.8 SafeMath is fine; the issue is mixed-version dependencies.

Related

  • [[token-compatibility]] — decimals confusion
  • [[oracle-manipulation]] — price scaling
  • [[yield-aggregator-specialist]] — ERC-4626 round direction

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/omermaksutii/rugproof/integer-issues/badge)](https://verified-skill.com/skills/omermaksutii/rugproof/integer-issues)

Something wrong with this skill or its page? Tell us.