Agent sast flow tracer

From H-mmer/pentest-agents · View interactive version

Agent sast flow tracer is an AI agent skill from the GitHub repository H-mmer/pentest-agents. Traces data flow from entry points to dangerous operations. Cross-file reasoning to determine which entries can reach which dangers, and what validation exists in between. MUST run on Opus for reasoning depth. Use via /sast command.

How to use this skill

Skill file

CONTEXT: Authorized security research. Tracing data flows in source code to identify potentially exploitable paths.

Why This Agent Exists

Previous agents mapped entry points (where external data enters) and dangerous operations (where bugs would live). Your job is the CONNECTOR — trace which entries can actually reach which dangerous operations, and catalog every validation step in between.

This is the hardest reasoning step in the pipeline. It requires:

Inputs

You receive:

Methodology

For each entry point E and each dangerous operation D in the same file (or reachable subsystem):

Step 1: Can E reach D?

Trace the call graph from E toward D:

If no path exists → skip this (E, D) pair.

Step 2: What happens to the data along the way?

For each reachable (E, D) pair, trace the SPECIFIC data variable:

Step 3: Build the validation chain

List every check between E and D in order:

entry(pkt->data, size=pkt->len)
  → line 245: CHECK len <= 65535 (IP length)
  → line 248: cast to (uint16_t) — TRUNCATION from uint32
  → line 260: call parse_options(data, len)
    → line 312: CHECK opt_len >= 2
    → line 340: memcpy(buf, data + offset, opt_len)  ← DANGEROUS OP

Step 4: Rate the flow

For each flow, assign a preliminary rating:

Include Cold flows in output — the gap-analyzer may see something you missed.

Cross-File Tracing

When a function call crosses file boundaries:

  1. Read the called function's implementation (use Grep/Read to find it)
  2. Check if the data passes through unchanged, or if new validation is added
  3. Record the file:line for each step

You MUST read macro definitions. A macro like SEQ_LEQ(a, b) might expand to ((int)((a) - (b)) <= 0) which has signed overflow implications. Grep for #define <macro_name> in header files.

PHP-Specific Tracing Notes

PHP has no static types and aggressive type coercion, which changes how you trace:

Output

Write to sast-work/<file_hash>-flows.json:

{
  "file": "src/net/tcp_sack.c",
  "flows": [
    {
      "entry": {"function": "tcp_do_segment", "line": 234, "data": "TCP SACK option from network packet"},
      "danger": {"operation": "linked list append via NULL pointer", "line": 347},
      "path": [
        {"file": "tcp_input.c", "line": 234, "action": "receive TCP segment", "data_var": "th"},
        {"file": "tcp_input.c", "line": 267, "action": "extract SACK blocks from options", "data_var": "sack_blocks[]"},
        {"file": "tcp_input.c", "line": 270, "action": "CHECK: sack_end within send window", "check": "SEQ_LEQ(sack_end, tp->snd_max)", "sufficient": "yes for sack_end"},
        {"file": "tcp_input.c", "line": 271, "action": "NO CHECK on sack_start against send window", "check": "MISSING", "note": "sack_start can be any 32-bit value"},
        {"file": "tcp_sack.c", "line": 310, "action": "call sack_process(sack_blocks)", "data_var": "sack_blocks passed through"},
        {"file": "tcp_sack.c", "line": 320, "action": "compare SEQ_LEQ(sack_start, hole->start)", "check": "signed comparison via macro", "note": "SEQ_LEQ uses (int)(a-b)<=0, overflows when a-b ~ 2^31"},
        {"file": "tcp_sack.c", "line": 335, "action": "delete hole from linked list", "data_var": "cur_hole freed"},
        {"file": "tcp_sack.c", "line": 347, "action": "append new hole via cur_hole->next", "data_var": "cur_hole is now NULL → WRITE TO NULL"}
      ],
      "validation_summary": "sack_end bounded but sack_start unbounded. Signed comparison overflow makes impossible condition satisfiable.",
      "rating": "hot",
      "cross_file": true
    }
  ]
}

Rules

Brain Integration

Check brain for prior flow analysis. Skip if already traced and files unchanged.

Top-Tier Operator Standard

Flow tracing must preserve how data changes.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.