solidity-security

Implements defensive Solidity patterns preventing reentrancy, oracle manipulation, and vault inflation exploits.

6|20|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/andresdefi/cryptoskills --skill solidity-security-andresdefi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: solidity-security
Source: https://github.com/andresdefi/cryptoskills/tree/main/skills/solidity-security
Command: npx skills add https://github.com/andresdefi/cryptoskills --skill solidity-security-andresdefi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI-generated Solidity code often contains exploitable vulnerabilities like reentrancy, token decimal mismatches, and flash-loan-manipulable oracle reads that cause real fund losses in DeFi protocols. ## Core Features & Use Cases - Vulnerability Patterns with Fixes: Covers reentrancy, access control, ERC4626 vault inflation, oracle manipulation, proxy storage collisions, and EIP-712 signatures, each with wrong-vs-correct code examples. - Audit Tooling Guidance: Provides usage instructions for Slither, Mythril, Echidna, Foundry fuzzing, and Certora, plus a pre-deploy security checklist. - Attack Test Examples: Includes Foundry test suites demonstrating reentrancy attacks, flash loan oracle manipulation, access control exploits, and oracle failure mocking. - Use Case: Before deploying a lending protocol, use this Skill to verify CEI ordering, add Chainlink staleness checks, validate UUPS upgrade safety, and run the pre-deploy checklist. ## Quick Start Review my Solidity contract for reentrancy, oracle manipulation, and access control vulnerabilities using the solidity-security skill.

Frequently Asked Questions about solidity-security

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

FAQPage Schema
How do I prevent reentrancy attacks in Solidity?

Apply the Checks-Effects-Interactions pattern by updating state before external calls, and add OpenZeppelin's ReentrancyGuard with the nonReentrant modifier. CEI alone does not stop cross-function reentrancy, so use both defenses together.

How to protect against flash loan oracle manipulation?

Never use Uniswap slot0 or reserve ratios as price oracles since they can be manipulated in one transaction. Use a Uniswap V3 TWAP with a 30-minute window or Chainlink feeds with staleness, negative price, and round completeness checks.

What is the ERC4626 vault inflation attack?

A first depositor donates tokens directly to an empty vault to inflate share price, causing later depositors to mint zero shares. OpenZeppelin's virtual offset via _decimalsOffset() makes the attack cost 10^offset times more expensive.

Slither vs Mythril vs Foundry fuzzing for smart contract audits?

Slither is fast static analysis suited for CI on every PR. Mythril uses symbolic execution to find deep logic bugs but is slower. Foundry fuzzing tests with real EVM execution and should run during development with 10,000+ runs before deployment.

Why does USDT approve fail in my Solidity contract?

USDT requires resetting allowance to zero before setting a new value, and its approve returns no boolean. Use OpenZeppelin SafeERC20's forceApprove, which handles the reset and non-standard return values automatically.

What storage layout rules apply to upgradeable proxy contracts?

Never remove, reorder, or insert variables between existing storage slots; only append new ones and use __gap arrays to reserve slots. Include _disableInitializers() in the implementation constructor and protect _authorizeUpgrade with access control.