memory-scan

An AI-assisted security scan for memory-corruption bugs in compiled software. These bugs include writing past a buffer, using memory after it was freed, freeing memory twice, and treating data as the wrong type.

In plain words
What is it for?
Use it to scan a software module or a specific function, follow calls between functions to a chosen depth, and check suspected findings against the processor instructions.
Why use it?
It helps find flaws that can let software crash or behave unexpectedly, including flaws that may be difficult to spot by reading source or decompiled code alone.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/marcosd4h/deepextractruntime/memory-scan
Clone the repo
git clone --depth 1 https://github.com/marcosd4h/DeepExtractRuntime
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,350 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 86% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.04350
Opus 5 $0.00000 $0.02175
Sonnet 5 $0.00000 $0.00870
Haiku 4.5 $0.00000 $0.00435

Measured 2d ago against content hash cb7f54a62974, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memory-scan scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

86% identical to ai-logical-bug-scan — 123 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

commands/memory-scan.md · 423 lines

How it starts

The opening of the file, as written. The whole thing — 423 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory Scan

Overview

AI-driven scan for memory corruption vulnerabilities: buffer overflows, integer overflow/truncation, use-after-free, double-free, and type confusion. Uses LLM agents that navigate cross-module callgraphs, read decompiled code on demand, and verify findings against assembly ground truth.

Usage:

  • /memory-scan <module> -- scan top entry points for the module
  • /memory-scan <module> <function> -- scan from a specific function
  • /memory-scan <module> <function> --depth 3 -- limit callgraph depth

IMPORTANT: Execution Model

This command executes immediately. Run the full pipeline and deliver the completed report without pausing for confirmation. Use the workspace handoff pattern for all phases.

Status Messaging (MANDATORY)

Keep the user informed at every phase boundary. Output a plain-text status message before each phase starts and after it completes. Messages are 1-2 lines summarizing what is happening and what the phase produced. Do NOT suppress status messages to "save time."

Execution Context

IMPORTANT: Script invocations like python .claude/skills/.../script.py run from the workspace root. The scripts manage their own path setup.

Step 0: Preflight Validation

from helpers.command_validation import validate_command_args
result = validate_command_args("memory-scan", {
    "module": "<user_module>",
    "function": "<user_function_or_None>",
})
if not result.ok:
    # report errors and stop
db_path = result.resolved["db_path"]

Workspace Protocol

Create .claude/workspace/<module>_memscan_<function_or_all>_<timestamp>/ and pass --workspace-dir and --workspace-step to all skill scripts.

Steps

Subagent Compliance Checklist (MANDATORY)

Before proceeding past each phase, verify the following. Violations invalidate the scan.

  • Phase 2 (Triage): Launched a security-auditor subagent via the Task tool. Did NOT write triage/results.json from coordinator context.
  • Phase 3 (Deep Analysis): Launched the memory-corruption-scanner subagent via the Task tool. Did NOT perform adversarial analysis inline.
  • Phase 4 (Skeptic): For EACH finding, launched a SEPARATE subagent via the Task tool with fresh context. Did NOT verify findings in the same context that discovered them.
  • Every finding includes verification_subgraph with nodes, edges, must_read, and db_path.

Read the full file on GitHub · 423 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 423 lines · 0 tokens per session scan A cb7f54a62974

Subscribe to this mod's changes

memory-scan is a command published in the GitHub repository marcosd4h/DeepExtractRuntime (20 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,350 tokens. A static security scan graded it A with 0 findings. It is 86% identical to ai-logical-bug-scan, differing in 123 lines, and is treated as a copy.