Skip to main content
skill CX Codex

static-analysis · gmh5225 — Claude Code skill: what it does, how to install

Supplies code agents with LLVM static analysis patterns, pointer analysis techniques, and taint tracking logic. Useful when building security checkers or compiler passes.

MIT 1 installs ★ 893 updated 2026-10-01

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add gmh5225/awesome-llvm-security --skill static-analysis -a claude-code
Open on GitHub

What static-analysis does

This skill guides coding agents through static program analysis using the LLVM infrastructure. It provides C++ code patterns for standard LLVM analyses, including DominatorTreeAnalysis and alias tracking through AAManager.

A dedicated section covers source-sink taint propagation. The logic maps sources such as getenv or read to critical sinks like system and strcpy. It also includes implementations for buffer boundary checks on GetElementPtrInst and use-after-free detection flows.

Without working knowledge of C++ and LLVM IR representations, these compiler recipes remain difficult to apply. The reference material also links into analysis frameworks such as SVF and Phasar.

What it helps with

  • implement an LLVM pass for source-sink taint tracking
  • detect use-after-free bugs across function points
  • inspect GetElementPtrInst instructions for buffer overflows
  • construct a Data Dependence Graph to trace loop dependencies

Example prompts for the agent

  • Write a C++ LLVM analysis pass that flags data flow from getenv to system.
  • Show how to run DominatorTreeAnalysis and LoopAnalysis on a Function in LLVM.
  • Implement a points-to set tracking class for LLVM pointer values.

How to install static-analysis

1Skills CLI (Vercel)

npx skills add gmh5225/awesome-llvm-security --skill static-analysis -a claude-code

2Manually: put the files in place

~/.claude/skills/static-analysis/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/static-analysis/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about static-analysis

How to install static-analysis in Claude Code?

Run npx skills add gmh5225/awesome-llvm-security --skill static-analysis -a claude-code in your terminal.

What does static-analysis do?

It equips your coding assistant with reference patterns for control flow graphs, taint propagation, and pointer analysis using LLVM APIs.

What analysis frameworks are referenced in this skill?

The skill references tools such as Phasar, SVF, Joern, CodeChecker, clam, dg, and Semgrep.

Source text

SKILL.md · MIT
---
name: static-analysis
description: Expertise in LLVM-based static analysis including dataflow analysis, pointer analysis, taint tracking, and program verification. Use this skill when implementing security scanners, bug finders, code quality tools, or performing program analysis research.
---

# Static Analysis Skill

This skill covers static program analysis techniques using LLVM infrastructure for security research, vulnerability detection, and code quality assessment.

## Analysis Categories

### Dataflow Analysis
- **Forward Analysis**: Track values from definitions to uses
- **Backward Analysis**: Track from uses back to definitions
- **May/Must Analysis**: Conservative vs precise approximations

### Control Flow Analysis
- **Dominator Trees**: Identify code dominance relationships
- **Post-Dominator Trees**: Control dependence analysis
- **Loop Analysis**: Detect and characterize loops

### Pointer Analysis
- **Flow-Insensitive**: Andersen's, Steensgaard's algorithms
- **Flow-Sensitive**: Track pointer values at each program point
- **Context-Sensitive**: Distinguish calling contexts

## LLVM Analysis Infrastructure

### Using Built-in Analyses
```cpp
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/DominatorTree.h"

void analyze(llvm::Function& F, llvm::FunctionAnalysisManager& FAM) {
    // Get dominator tree
    auto& DT = FAM.getResult<llvm::DominatorTreeAnalysis>(F);
    
    // Get loop info
    auto& LI = FAM.getResult<llvm::LoopAnalysis>(F);
    
    // Get alias analysis
    auto& AA = FAM.getResult<llvm::AAManager>(F);
    
    // Check if two pointers may alias
    llvm::AliasResult AR = AA.alias(Ptr1, Ptr2);
}
```

### Implementing Custom Analysis
```cpp
class TaintAnalysis {
    std::set<llvm::Value*> taintedValues;
    
public:
    void markTainted(llvm::Value* V) {
        taintedValues.insert(V);
    }
    
    bool isTainted(llvm::Value* V) {
        return taintedValues.count(V) > 0;
    }
    
    void propagate(llvm::Instruction* I) {
        // Propagate taint through operations
        for (auto& Op : I->operands()) {
            if (isTainted(Op)) {
                markTainted(I);
                break;
            }
        }
    }
};
```

## Taint Analysis

### Source-Sink Model
```cpp
// Define taint sources (user input, network, files)
bool isTaintSource(llvm::CallInst* CI) {
    llvm::Function* F = CI->getCalledFunction();
    if (!F) return false;
    
    static const std::set<std::string> sources = {
        "read", "recv", "fread", "getenv", "gets", "scanf"
    };
    return sources.count(F->getName().str()) > 0;
}

// Define sensitive sinks (SQL queries, system calls, format strings)
bool isSensitiveSink(llvm::CallInst* CI) {
    llvm::Function* F = CI->getCalledFunction();
    if (!F) return false;
    
    static const std::set<std::string> sinks = {
        "system", "exec", "printf", "strcpy", "memcpy", "sql_query"
    };
    return sinks.count(F->getName().str()) > 0;
}
```

### Interprocedural Analysis
- Track taint across function boundaries
- Handle indirect calls via call graph analysis
- Context-sensitivity for precision

## Pointer Analysis Frameworks

### Using Andersen's Analysis
```cpp
#include "llvm/Analysis/CFLAndersAliasAnalysis.h"

// Check may-alias relationship
void checkAlias(llvm::AAResults& AA, llvm::Value* P1, llvm::Value* P2) {
    switch (AA.alias(P1, P2)) {
        case llvm::AliasResult::NoAlias:
            // Definitely don't alias
            break;
        case llvm::AliasResult::MayAlias:
            // Might alias
            break;
        case llvm::AliasResult::MustAlias:
            // Always alias
            break;
    }
}
```

### Points-To Sets
```cpp
// Track what each pointer may point to
class PointsToAnalysis {
    std::map<llvm::Value*, std::set<llvm::Value*>> pointsTo;
    
public:
    void addPointsTo(llvm::Value* ptr, llvm::Value* target) {
        pointsTo[ptr].insert(target);
    }
    
    const std::set<llvm::Value*>& getPointsTo(llvm::Value* ptr) {
        return pointsTo[ptr];
    }
};
```

## Dependency Analysis

### Data Dependency Graph (DDG)
```cpp
#include "llvm/Analysis/DDG.h"

void buildDDG(llvm::Function& F, llvm::FunctionAnalysisManager& FAM) {
    auto& LI = FAM.getResult<llvm::LoopAnalysis>(F);
    
    for (auto* L : LI) {
        llvm::DataDependenceGraph DDG(*L, FAM.getResult<llvm::AAManager>(F));
        
        for (auto& Node : DDG) {
            // Analyze data dependencies in loop
        }
    }
}
```

### Program Slicing
- Forward slicing: Find all statements affected by a variable
- Backward slicing: Find all statements affecting a variable
- Use for debugging, testing, and security analysis

## Major Static Analysis Tools

### Comprehensive Frameworks
- **Phasar**: Industrial-strength LLVM-based analysis framework
- **SVF**: Scalable pointer analysis and value-flow analysis
- **Joern**: Code analysis platform with graph queries
- **CodeChecker**: Clang-based static analysis integration

### Specialized Tools
- **clam**: Abstract interpretation framework
- **dg**: Dependence graph construction
- **Semgrep**: Pattern-based multi-language analysis

## Security Analysis Applications

### Vulnerability Detection
```cpp
// Buffer overflow detection
void checkBufferAccess(llvm::GetElementPtrInst* GEP) {
    // Get array size if available
    llvm::Type* SourceType = GEP->getSourceElementType();
    if (auto* AT = llvm::dyn_cast<llvm::ArrayType>(SourceType)) {
        uint64_t arraySize = AT->getNumElements();
        
        // Check if index might exceed bounds
        llvm::Value* Index = GEP->getOperand(2);
        // Perform range analysis on index
    }
}
```

### Use-After-Free Detection
- Track allocation/deallocation points
- Build reaching definitions for pointers
- Flag uses after free calls

### Information Flow
- Track sensitive data (passwords, keys, PII)
- Detect leaks to logs, network, or untrusted sinks
- Implement declassification rules

## Best Practices

1. **Soundness vs Completeness**: Understand trade-offs
2. **Scalability**: Use summaries for large codebases
3. **Path Sensitivity**: Balance precision and performance
4. **False Positive Management**: Prioritize actionable findings
5. **Incremental Analysis**: Cache results for faster re-analysis

## Integration with IDEs

### Clangd/LSP Integration
- Provide real-time analysis feedback
- Integrate with editor diagnostics
- Support quick-fix suggestions

### CI/CD Integration
- Run analysis on pull requests
- Block merges on critical findings
- Track analysis trends over time

## Resources

See Static Analysis and Clang Plugins sections in README.md for comprehensive tool listings and research references.

## Getting Detailed Information

When you need detailed and up-to-date resource links, tool lists, or project references, fetch the latest data from:

```
https://raw.githubusercontent.com/gmh5225/awesome-llvm-security/refs/heads/main/README.md
```

This README contains comprehensive curated lists of:
- Static analysis frameworks (Static Analysis section)
- Pointer analysis and taint tracking tools
- Program verification and bug finding tools
- Clang-based code analysis plugins

© gmh5225 · MIT · gmh5225/awesome-llvm-security

Similar skills

All skills for Security →

static-analysis by other authors comes first.

static-analysis mohitmishra786 Guides static analysis configuration for C and C++ projects using clang-tidy, cppcheck, and scan-build. It helps filter warnings and triage false positives. CX Codex +1 1,300installs gitnexus-taint-analysis abhigyanpatwari gitnexus-taint-analysis explains the taint-analysis subsystem inside GitNexus: CFG, reaching definitions, sources, sinks. Useful when you need to explain a finding or add a new source or sink. CX Codex +1 421installs dart-run-static-analysis dart-lang dart-run-static-analysis runs dart analyze to catch errors and dart fix --apply to resolve mechanical linter issues. Helps verify Dart code quality during development and before commits. CX Codex +1 21,200installs semgrep-rule-creator trailofbits semgrep-rule-creator is a Claude Code skill that builds custom Semgrep rules to detect security vulnerabilities and bug patterns. It writes tests first, then the rule, and optimises last. CX Codex +1 6,400installs eastsword-dfyx-code-security-review reason-machines The eastsword-dfyx-code-security-review skill runs white-box security audits by tracking data flows and spotting authorization or injection flaws. It suits projects preparing code for production. CX Codex +1 331installs cpg-analysis alinaqi cpg-analysis uses Joern CPG and CodeQL to inspect control flow, data flow, and taint paths. Built for deep refactoring work and security audits. CX Codex +1 175installs Lachesis UnboundCompute Lachesis builds a compiler-grade property graph for C, Python and TypeScript, then answers questions about calls and data flow. Useful when you need to trace a value or check whether outside input reaches something risky. CX Codex +1 ★ 6repo stars

Project sponsors

Companies that keep this analytics open