Skip to content
Skills Library
Security · Analysis

cpg-analysis

/cpg-analysis

This skill should be used when the user asks about "Code Property Graph", "CPG analysis", "Joern queries", "CPGQL", "data flow verification", "taint tracking with Joern", "semantic code analysis", or needs to understand how CPG-based verification works for vulnerability detection.

Repository
vuln-scout ↗
Licence
MIT
Last repository change
12.06.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.06.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

This skill should be used when the user asks about "Code Property Graph", "CPG analysis", "Joern queries", "CPGQL", "data flow verification", "taint tracking with Joern", "semantic code analysis", or needs to understand how CPG-based verification works for vulnerability detection.

Triggers from the description

Code Property GraphCPG analysisJoern queriesCPGQLdata flow verificationtaint tracking with Joernsemantic code analysis
Original author description

This skill should be used when the user asks about "Code Property Graph", "CPG analysis", "Joern queries", "CPGQL", "data flow verification", "taint tracking with Joern", "semantic code analysis", or needs to understand how CPG-based verification works for vulnerability detection.

How it works

  1. What is a Code Property Graph?
  2. When to Use CPG vs Pattern Matching
  3. Joern Overview
  4. CPGQL Query Language
  5. Confidence Scoring
  6. Skill References
  7. Related Skills
Original SKILL.md headings · 111 lines, 469 words
SKILL.md preview
---
name: cpg-analysis
description: This skill should be used when the user asks about "Code Property Graph", "CPG analysis", "Joern queries", "CPGQL", "data flow verification", "taint tracking with Joern", "semantic code analysis", or needs to understand how CPG-based verification works for vulnerability detection.
version: 1.0.0
---

# Code Property Graph (CPG) Analysis

## What is a Code Property Graph?

A Code Property Graph (CPG) is a unified data structure that combines three representations of code:

1. **Abstract Syntax Tree (AST)** - Structural representation
2. **Control Flow Graph (CFG)** - Execution paths
3. **Program Dependence Graph (PDG)** - Data and control dependencies

This combination enables powerful semantic queries that pattern-matching tools cannot achieve.

## When to Use CPG vs Pattern Matching

| Approach | Use When | Example |
|----------|----------|---------|
| **Pattern Matching** (Semgrep) | Known vulnerability patterns, syntax-level issues | Finding dynamic code execution calls |
| **CPG Analysis** (Joern) | Data flow tracking, cross-function analysis | Proving request input reaches database query through 5 functions |

**Rule of thumb**: Use CPG when you need to prove data flows between points, especially across function boundaries.

## Joern Overview

Joern is the primary tool for CPG analysis. It:
- Parses source code into CPG representation
- Provides CPGQL (Scala-based) query language
- Supports JavaScript, TypeScript, Python, Java, C/C++, Go, PHP

### Basic Joern Workflow

```bash
# 1. Parse codebase into CPG
joern-parse /path/to/code --output cpg.bin

# 2. Start Joern REPL or run scripts
joern --script analysis.sc --params cpgFile=cpg.bin

# 3. Or use Joern REPL interactively
joern
> importCpg("cpg.bin")
> cpg.method.name(".*login.*").l
```

## CPGQL Query Language

CPGQL uses Scala syntax with CPG-specific operations.

### Core Concepts

**Nodes**: Represent code elements
- `cpg.method` - All methods/functions
- `cpg.call` - All function calls
- `cpg.parameter` - Function parameters
- `cpg.literal` - Literal values
- `cpg.identifier` - Variable references

**Traversals**: Navigate the graph
- `.name("pattern")` - Filter by name (regex)
- `.code("pattern")` - Filter by code content
- `.argument` - Get call arguments
- `.caller` - Get calling methods
- `.callee` - Get called methods

**Data Flow**: Track how data moves
- `.reachableBy(source)` - Find if source reaches this point
- `.reachableByFlows(source)` - Get full paths

### Common Query Patterns

**Find all calls to a function:**
```scala
cpg.call.name("query").l
```

**Find parameters that reach dangerous sinks:**
```scala
val sources = cpg.parameter.name("req.*|request.*")
val sinks = cpg.call.name("query|execute|run")
sinks.argument.reachableBy(sources).l
```

**Get full data flow paths:**
```scala
val sources = cpg.parameter.name("userInput")
val sinks = cpg.call.name("executeQuery")
sinks.argument.reachableByFlows(sources).p
```

## Confidence Scoring

After CPG verification:

| Verification Result | Confidence | Meaning |
|---------------------|------------|---------|
| Data flow confirmed | HIGH (0.9+) | CPG proves exploitability |
| Partial flow found | MEDIUM (0.6-0.9) | Some path exists, manual review needed |
| No flow found | LOW (0.3-0.6) | May be false positive or complex flow |
| Verification failed | UNKNOWN | Query error, manual analysis required |

## Skill References

- `references/cpgql-patterns.md` - Common vulnerability query patterns
- `references/joern-cheatsheet.md` - Quick Joern/CPGQL reference

## Related Skills

- **data-flow-tracing** - Manual source-to-sink analysis
- **dangerous-functions** - Sink identification by language
- **vuln-patterns** - Pattern-based vulnerability knowledge
Files in this package (5)
  • SKILL.md 4 KB
  • references/cpgql-patterns.md 4 KB
  • references/false-positive-patterns.md 7 KB
  • references/joern-cheatsheet.md 5 KB
  • references/joern-setup.md 5 KB

Versions

The database has no other skills named cpg-analysis.

Database snapshot: 13.11.2026 · package version f2dc58beecd1 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100codeql-expert
    Expert-level CodeQL for static analysis, vulnerability detection, and security code scanning. Use when the user mentions static analysis, SAST, vulnerability detection, or github security, or when the task involves writing CodeQL queries, building a CodeQL database, taint…
  • 100cpg-101-plan-evaluation
    Evaluates an Emergency Operations Plan against FEMA's CPG 101 standards and identifies compliance gaps, missing elements and improvement areas, with exact plan citations, CPG 101 references and prioritized recommendations presented in tables (compliance assessment, findings by…
  • 100codeql
    Scans a codebase for security vulnerabilities using CodeQL's interprocedural data flow and taint tracking analysis. Triggers on "run codeql", "codeql scan", "build codeql database", "SAST scan", "taint analysis", "dataflow analysis", or "find vulnerabilities in this repo".…
  • 100security-audit
    Phased risk-centric security assessment framework. Trigger when: - Auditing code for vulnerabilities, checking SQL injection, access control, or buffer overflows. - Prompt contains: /security-audit, security audit, taint analysis, threat model, vulnerability.
  • 100codebase-recon
    Work out what an unfamiliar or legacy codebase actually does, and what is safe to change. Use for legacy modernization, replatforming, a rewrite or strangler migration, onboarding onto an inherited system, technical-debt assessment, documenting what a system does, dead-code…
  • 100semgrep
    Run Semgrep static analysis across a codebase, optionally using Semgrep Pro for cross-file taint analysis. Use when Semgrep or a static-analysis scan is requested; use security-review for a manual audit.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.