semgrep-solidity

Write and run custom Semgrep rules to detect Solidity smart contract vulnerabilities.

1|1|Updated May 21, 2026
One-click install
npx skills add https://github.com/naruto11eth/cryptoskills --skill semgrep-solidity-naruto11eth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: semgrep-solidity
Source: https://github.com/naruto11eth/cryptoskills/tree/main/skills/semgrep-solidity
Command: npx skills add https://github.com/naruto11eth/cryptoskills --skill semgrep-solidity-naruto11eth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Generic static analyzers miss project-specific bugs, and LLMs often hallucinate Semgrep's Solidity capabilities. This Skill provides accurate, verified guidance for writing custom Semgrep detection rules in YAML that catch reentrancy, access control flaws, unsafe delegatecall, and other vulnerabilities that generic tools overlook. ## Core Features & Use Cases - Custom Rule Authoring: Write YAML rules using pattern matching, metavariables, ellipsis operators, and taint tracking to detect protocol-specific anti-patterns and invariants. - Community Ruleset Integration: Run the decurity/semgrep-smart-contracts ruleset covering reentrancy, tx.origin auth, unchecked return values, and proxy issues against any contracts directory. - CI/CD and Testing Workflows: Set up GitHub Actions with SARIF upload, pre-commit hooks, rule testing with ruleid/ok annotations, and autofix rules. - Use Case: While auditing a DeFi vault, write a taint-tracking rule that traces user-supplied addresses flowing into delegatecall, test it against annotated Solidity fixtures, then gate pull requests on ERROR-severity findings in CI. ## Quick Start Ask the agent to write a Semgrep rule that detects block.timestamp used as randomness in your contracts directory and test it with semgrep --test.

Frequently Asked Questions about semgrep-solidity

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

FAQPage Schema
How do I write a custom Semgrep rule for Solidity?

Create a YAML file with a rules list containing id, patterns, message, languages set to solidity, and severity. Use metavariables like $X to capture expressions, ellipsis for intervening statements, and pattern-not-inside to exclude safe contexts such as nonReentrant functions.

How does Semgrep taint tracking work for smart contracts?

Set mode to taint and define pattern-sources (such as external function parameters) and pattern-sinks (such as delegatecall targets). Semgrep traces data flow from sources to sinks, and pattern-sanitizers like require checks break the taint chain for validated inputs.

Semgrep vs Slither for Solidity security analysis?

Slither provides 90+ built-in detectors with deep Solidity understanding including inheritance resolution and control flow analysis. Semgrep excels at custom YAML rules for project-specific patterns and fast CI gating. Use both together rather than choosing one.

Why does my Semgrep rule not match expected Solidity code?

The pattern's AST structure likely differs from the code. Common causes are missing ellipsis between statements, visibility mismatches like external versus public, or modifier ordering. Debug with semgrep --debug to inspect pattern matching behavior.

How do I run Semgrep in GitHub Actions for Solidity?

Install Semgrep via pip, clone the decurity/semgrep-smart-contracts ruleset, run semgrep with --sarif output, and upload results using github/codeql-action/upload-sarif. Gate merges by running a second pass with --error and --severity ERROR.

What are the limitations of Semgrep for Solidity?

Solidity support is community-maintained via tree-sitter-solidity and may lag behind new syntax. Semgrep matches patterns without symbolic execution or constraint solving, so it only finds what your rules define. The auto config registry has limited Solidity coverage.