logic-error

Detects business logic vulnerabilities in Solidity smart contracts using calculation flow analysis.

66|17|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/BitterSecurity/Vigilo --skill logic-error-bittersecurity
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: logic-error
Source: https://github.com/BitterSecurity/Vigilo/tree/main/packages/claude/skills/vulnerability-patterns/logic-error
Command: npx skills add https://github.com/BitterSecurity/Vigilo --skill logic-error-bittersecurity

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Smart contract logic errors like precision loss, first depositor attacks, and missing slippage protection caused over $63.8M in losses, yet they are hard to spot with manual code review. This Skill gives auditors systematic detection patterns, search queries, and verification checklists to find these vulnerabilities before attackers do. ## Core Features & Use Cases - Calculation Flow Mapping: Trace every arithmetic operation from input validation through rounding direction to state updates, documenting risk in a structured table. - Six Detection Patterns: Covers division-before-multiplication, first depositor/inflation attacks, unchecked return values, overflow in unchecked blocks, missing slippage protection, and missing zero/address validation. - Ready-to-Run Search Queries: Provides Grep patterns for Solidity files to quickly locate suspect arithmetic, share calculations, and missing checks. - Use Case: While auditing an ERC4626 vault, use the first depositor pattern to check whether the initial share ratio can be manipulated via a donation attack, then verify rounding direction favors the protocol on both deposit and withdraw. ## Quick Start Ask the logic-auditor agent to analyze the vault contract for division-before-multiplication and first depositor vulnerabilities using the logic error detection patterns.

Frequently Asked Questions about logic-error

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect first depositor attacks in ERC4626 vaults?▼

Check what happens when totalSupply equals zero and whether assets can be donated directly to the vault without minting shares. Look for virtual share offsets or minimum deposit requirements, and verify the initial share ratio cannot be manipulated by an attacker depositing 1 wei then donating tokens.

What is division before multiplication in Solidity and why is it dangerous?▼

Solidity truncates integer division, so computing a / b * c loses precision when a is smaller than b, often yielding zero. Reordering to a * c / b preserves precision when overflow is not a risk, and any X / Y * Z pattern should be flagged during audit.

Does Solidity 0.8 prevent all integer overflow vulnerabilities?▼

No. Solidity 0.8 adds automatic overflow checks, but unchecked blocks and inline assembly bypass this protection entirely. Auditors should grep for unchecked and assembly blocks and verify that inputs cannot cause wraparound in those sections.

How do I check for missing slippage protection in swap functions?▼

Search for swap, exchange, or trade functions and verify they accept a minimum output parameter such as amountOutMin or minAmountOut. A swap that transfers whatever amount the calculation returns lets attackers sandwich the transaction for profit.

Why do rounding errors matter in smart contract audits?▼

Rounding errors accumulate across repeated calls and can be exploited at scale, as in the Bunni attack which caused $2.4M-$8.3M in losses. The rule is to round against the user: round down on withdrawals so users receive less, and round down on deposits so users pay more.

What edge cases should I test for value-handling functions?▼

Test zero, one, maximum uint256, first user, last user, and boundary values just above or below limits. These cases expose division by zero, rounding to zero, overflow in unchecked blocks, ratio manipulation on empty state, and off-by-one errors.