Skip to content
SciTools Blog
Menu
  • Home
  • Blog
  • Support
  • Contact
  • Login
  • Pricing
  • Free Trial
Menu

Teaching Understand to Hunt (and Verify) Real Security Bugs — Locally

Posted on December 2, 2026

TL;DR

  • Understand + two local AI models found verified vulnerabilities in 80 of 241 DARPA Cyber Grand Challenge services (33.2%).
  • No compiling, no fuzzing, no code sent to the cloud. Everything ran on one MacBook Pro.
  • Works with any static analyzer that outputs SARIF, not just Understand’s Bug Finder.

Why Static Analysis + Local AI Needs a Real Code Database

Anyone who has run static analysis on a large C or C++ codebase knows the two classic frustrations:

  1. Too much noise on the things static analysis checks. A tool flags a null pointer dereference inside a switch statement without knowing that the callers or macros upstream make that branch impossible.
  2. Blind spots on the things static analysis doesn’t check. Multi-step protocol parsers, subtle integer wraparounds feeding calloc, off-by-one loop bounds, or odd callback tables.

The obvious modern temptation is to throw an LLM at the source tree and tell it to “find bugs.” On a real codebase (say, 40,000 functions across 242 services) that doesn’t work. You either blow past context limits, burn days of compute, or drown in hallucinated “theoretical issues.”

This is where Understand’s .und database changes the math. Understand already knows every function definition, caller (callby), callee (call), macro expansion, struct layout, complexity metric, and global variable write (setby/modifyby) across the entire project. Instead of asking an LLM to read everything, we let Understand do what it’s good at, finding the interesting slices, and let local AI do what it’s good at, reasoning about whether a specific slice is actually broken.


The Pipeline: Find, Slice, and Adversarially Verify

Here’s the pipeline we built and tested. It has zero external Python dependencies and runs directly under Understand’s bundled upython.

  1. Find candidates (unified SARIF from any static analyzer)
    • Understand Bug Finder, or any SARIF-producing static analyzer: The triage stage accepts any standard SARIF 2.1.0 file, whether it came from Understand’s Bug Finder/CodeCheck, Clang Static Analyzer, Coverity, CodeQL, Cppcheck, Semgrep, or your own custom checks. Pass multiple --sarif inputs to get a single deduplicated run.
    • Understand .und AI graph miners: Query the .und database to slice out the riskiest ~1–2% of code across 9 bug classes (taint, bounds, arithmetic, error_paths, callbacks, contracts, parser, lifetime, and concurrency). A fast local model (gemma-4-26b-a4b) proposes concrete SARIF candidates.
  2. Understand semantic slicing + two-stage triage
    • Both SARIF streams merge into a single triage pass. For each finding, Understand pre-fetches the enclosing function, linkage (static vs. public), caller call sites, called helper bodies, struct/typedef definitions, and guard macros. It also exposes live read-only .und tools (get_callers, get_function_definition, get_symbol_info, read_source_lines, search_code).
    • Stage 1 (fast local screener): Clears obvious false positives quickly, cutting 63.8% of Bug Finder noise on cb-multios and 97.4% on a llama.cpp fork.
    • Stage 2 (cross-family adversarial verifier): A stronger local model from a different model family (gpt-oss-safeguard-120b on MLX) actively tries to disprove the remaining findings using live .und tool calls.
  3. One interactive HTML report
    • Everything lands in a single offline HTML file filtered to actionable findings (true_positive and needs_review), with step-by-step code walkthroughs, Simplified Technical English explanations, and the AI’s full tool-call trail.
Interactive single-file HTML triage report showing verified findings, step-by-step replication walkthrough, and cross-family AI analysis
The single-file HTML report opens filtered to actionable findings (430 verified true positives + 135 needs review), with 575 dismissed false positives one click away.

A Quick Look at the 9 Understand .und Miners

Each miner queries Understand’s .und graph for a specific structural risk pattern and hands the AI only the relevant slice (call chain, callers, or function body) instead of the whole codebase.

MinerWhat Understand ExtractsWhat the AI Looks For
taint1–3 hop call-graph paths (call/callby) from input primitives (recv, read, fgets, getenv) to sensitive sinks (memcpy, strcpy, calloc, sprintf, system).Unvalidated lengths/inputs reaching memory, format, or command sinks.
boundsLoop-bearing functions (Cyclomatic + CountLineCode) with direct array writes or pointer arithmetic, plus sample callers.Off-by-one loop writes, negative indices, and out-of-bounds array accesses.
arithmeticFunctions mixing narrowing casts (int, short, uint16_t), multiplication, or shifts with allocation/buffer sizing.Integer overflow/wraparound, unsigned underflow (0 - 1), and signed/unsigned bypasses.
error_pathsComplex functions (Cyclomatic >= 5) calling resource acquirers (malloc, fopen, socket, locks).Leaks, double-frees, or held locks on early return / goto / exception paths.
callbacksFunctions using function-pointer types ((*)) or indirect/indexed dispatch (tbl[i](...), p->fn(...)) plus callers.Out-of-bounds dispatch tables, NULL/uninitialized function-pointer calls, control-flow hijacking.
contractsFunctions with 4+ callers (callby), comparing return-value/NULL check patterns across call sites.Odd-one-out callers that skip checks or cleanup conventions other callers obey.
parserHigh-complexity switch/case dispatchers, protocol/VM parsers, and format-string callers (printf, snprintf, syslog).Format-string injection, missing opcode bounds checks, switch fall-through, state desync.
lifetimeCallers of free/realloc/delete/destroy/release primitives, bundled with their own callers.Use-after-free, double-free, mid-buffer frees, and dangling pointers after failed realloc.
concurrencyShared mutable globals/statics (setby/modifyby/useby) across functions with inconsistent locking.Data races, missing mutexes, and unsafe signal/thread flags (auto-skips single-threaded targets).

Example Command Lines

Everything runs directly under Understand’s bundled upython against a local LM Studio server (http://localhost:1234/v1) or any OpenAI-compatible endpoint.

# 1. Hunt for bugs using Understand .und graph miners + fast local MoE -> SARIF
PYTHONPATH=src /Applications/Understand.app/Contents/MacOS/upython -m bugfinder_hunt \
  --db ~/src-examples/cb-multios/cb-multios.und \
  --src ~/src-examples/cb-multios \
  --checks contracts,taint,error_paths,bounds,arithmetic,lifetime,parser,callbacks \
  --max-per-check 0 \
  --max-per-dir 2 \
  --min-confidence 0.85 \
  --base-url http://localhost:1234/v1 \
  --model google/gemma-4-26b-a4b-qat \
  --max-tool-rounds 0 \
  --workers 2 \
  -o cb-multios-customer-d2-hunt.sarif
# 2. Adversarially verify & merge ANY SARIFs (e.g. Bug Finder + AI Hunter) -> HTML report
PYTHONPATH=src /Applications/Understand.app/Contents/MacOS/upython -m bugfinder_triage \
  --db ~/src-examples/cb-multios/cb-multios.und \
  --sarif ~/src-examples/cb-multios/bugfinder-results.sarif \
  --sarif cb-multios-customer-d2-hunt.sarif \
  --src ~/src-examples/cb-multios \
  --base-url http://localhost:1234/v1 \
  --model google/gemma-4-26b-a4b-qat \
  --max-tool-rounds 0 \
  --escalate-model gpt-oss-safeguard-120b-mlx \
  --escalate-below 0.90 \
  --escalate-tool-rounds 2 \
  --escalate-reasoning-effort medium \
  --workers 2 \
  -o cb-multios-customer-d2-triage.html

For a multithreaded C/C++ project like llama.cpp, use --checks all so concurrency runs too, or scope a daily PR check with --git-diff main.


Testing Against a Known Benchmark: DARPA CGC (cb-multios)

To test this against known ground truth rather than cherry-picked toy files, I pointed the pipeline at Trail of Bits’ cb-multios, which contains 242 C/C++ services from the DARPA Cyber Grand Challenge. 241 of them have official #ifdef PATCHED blocks marking the exact seeded vulnerabilities.

Everything ran on a single 128 GB M5 Max MacBook Pro using local US-origin models in LM Studio (MLX). No binaries were compiled, executed, or fuzzed.

Here’s how the unified static pipeline compares with published results on DARPA CGC:

Tool / ApproachOfficial CGC Challenges HitMethod
Traditional static analyzers (Clang SA, Cppcheck, CodeQL)~2% – 20%Purely static
Understand .und + local US AI (single run: 26b-a4b → gpt-oss-120b)21.6% (52 / 241)Purely static, 100% local, 0 errors
Understand unified static pipeline (Bug Finder + AI miners combined)33.2% (80 / 241)Purely static, zero execution
DARPA CGC finals autonomous systems (Mayhem, Mechanical Phish, etc.)~20% – 35%Dynamic fuzzing + symbolic execution
Offline fuzzing + hybrid symbolic (hours per binary)~40% – 65%Heavy dynamic execution + harnesses

A few things stood out in the data:

  • Every part of the pipeline pulled its weight. Understand Bug Finder contributed 128 verified bugs (after 63.8% false-positive reduction), including 3 unique official CGC PATCHED challenges (Finicky_File_Folder, Mount_Filemore, commerce_webscale) that the AI miners didn’t hit. All 8 single-threaded AI miners also contributed official CGC PATCHED hits (taint: 14, error_paths: 13, bounds: 12, arithmetic: 11, callbacks: 6, contracts: 5, parser: 3, lifetime: 1).
  • The bugs it found weren’t trivial lint issues. They included:
    • Remote code execution via attacker-controlled function pointers (Game_Night, CableGrind) and an arbitrary memory write treating a string-parsed value as a pointer (greeter).
    • Attacker-controlled format strings (Checkmate, CNMP) and an overlong UTF-8 path-traversal bypass (UTF-late).
    • Classic stack/heap overflows (CTTP copying 2 MB into a 4 KB stack buffer, CGC_Hangman_Game, Casino_Games, The_Longest_Road, FISHYXML).
    • Subtle logic and lifetime bugs: a Y-bounds check using && instead of || (CGC_Image_Parser), a negative-price balance bypass (Music_Store_Client), a list-iterator use-after-free (QuadtreeConways), and a double-free on key replacement (One_Vote).
  • Why zero race conditions on cb-multios? DARPA CGC’s DECREE OS had only 7 syscalls and no threads, so the 9th miner (concurrency) skipped it automatically. When we pointed the same pipeline at a real multithreaded C++ inference engine (llama-cpp-turboquant), concurrency found 5 verified data races, including one in the new TurboQuant quantization code (ops.cpp ↔ ggml-turbo-quant.c).

Two Practical Lessons From Running This Locally

Building this for real engineering teams, not just a demo, taught us a couple of things:

  1. Don’t let a model family grade its own homework. Early on, I hunted with gemma-4-26b-a4b and verified with gemma-4-31b. On 247 shared findings, 31b rubber-stamped 114 false positives at 1.00 confidence while barely calling any Understand tools. Switching Stage 2 to a different model family (gpt-oss-safeguard-120b on MLX) broke that confirmation bias immediately. It made 465 live Understand tool calls across the run and cut 575 of 1,140 hunter candidates (50.4%) as false positives, at roughly 10× the speed of heavier reasoning models we tested.
Stage 2 adversarial verification terminal output showing live Understand tool calls, measured ETA, and final summary
Stage 2 (gpt-oss-safeguard-120b-mlx) finishing with live measured ETA, Understand tool calls, 55.8 tok/s throughput, and zero errors.
  1. Local tooling has to hold up in real-world use. Running 1,100+ items locally shows you fast what a real product needs: file-first .und indexing (so scanning 40,000 functions takes seconds, not minutes), disk-cached .und contexts, atomic cache writes, endpoint preflight checks, default token caps against runaway repetition loops, and graceful Ctrl-C handling that still writes a usable partial report.
Stage 1 instant cache resume showing 1,140 cached findings completed in 0.0 seconds
Incremental disk caching means interrupted runs resume in 0.0s across already-verified Stage 1 findings, even if you switch to a renamed model with --reuse-any-model-cache.

Where We’re Taking This

The big takeaway for me isn’t that AI replaces static analysis. It’s that static analysis plus a rich semantic code database (.und) makes local AI dramatically smarter, faster, and quieter.

Understand already holds the graph and cross-reference data needed to slice a massive codebase down to the ~1% that matters, and to give a verifier the ground truth to prove or disprove a bug. Because it consumes standard SARIF 2.1.0 (including multiple SARIF files at once), teams can feed in any static analyzer they already run alongside Understand’s Bug Finder and .und AI miners, and get one verified, low-noise report privately on their own machine.

If you want to try this on your own codebase, contact [email protected] and we’ll get it to you. And let us know which codebases or static analyzers you’d like to see us test next.

Learn more about Understand's Features

  • Dependency Graph
    View Dependency Graphs
  • Comply with Standards
  • View Useful Metrics
  • Team Annotations
  • Browse Depenedencies
  • Edit and Refactor

Related

  • AI
  • Annotations
  • API
  • Architectures
  • Business
  • Code Comparison
  • Code Comprehension
  • Code Navigation
  • Code Visualization
  • Coding Standards
  • Dependencies
  • Developer Notes
  • DevOps
  • Getting Started
  • Legacy Code
  • Licensing
  • Metrics
  • Platform
  • Plugins
  • Power User Tips
  • Programming Practices
  • Useful Scripts
  • User Stories
  • December 2026
  • November 2026
  • October 2026
  • September 2026
  • August 2026
  • June 2026
  • May 2026
  • December 2025
  • November 2025
  • August 2025
  • June 2025
  • May 2025
  • January 2025
  • December 2024
  • November 2024
  • August 2024
  • June 2024
  • May 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • April 2023
  • January 2023
  • December 2022
  • November 2022
  • September 2022
  • August 2022
  • May 2022
  • April 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

©2026 SciTools Blog | Design: Newspaperly WordPress Theme