detecting-memory-safety-bugs

detecting-memory-safety-bugs is a skill for Claude Code from UnboundCompute/security-agent-skills. It costs 124 tokens per session (1,428 once invoked), scanned A, original, MIT.

A method for finding memory-safety bugs in C, C++, Rust code with unsafe memory operations, CGo, and similar unmanaged code. It checks whether memory is still valid and whether reads and writes stay within bounds.

In plain words
What is it for?
Use it when reviewing allocators, parsers, serializers, buffers, reference counting, or pointer arithmetic. It helps trace an allocation, the state changes affecting it, and the later use that may be unsafe.
Why use it?
These bugs often depend on object lifetime and control flow rather than one obviously dangerous function. Finding the complete path can expose use-after-free, double-free, out-of-bounds access, uninitialized reads, and null-pointer dereferences.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the security-agent-skills plugin — 194 skills shipped together

Good fit Use it when reviewing allocators, parsers, serializers, buffers, reference counting, or pointer arithmetic. It helps trace an allocation, the state changes affecting it, and the later use that may be unsafe.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs
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.

Any agent
npx skills add UnboundCompute/security-agent-skills --skill detecting-memory-safety-bugs
Clone the repo
git clone --depth 1 https://github.com/UnboundCompute/security-agent-skills

Made for: Claude Code.

Or install security-agent-skills, the plugin that ships this one along with the rest of its 194 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for detecting-memory-safety-bugs

README.md
[![agentmods](https://agentmods.dev/badge/skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs/github.svg)](https://agentmods.dev/skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs)
Your own site
<a href="https://agentmods.dev/skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs"><img src="https://agentmods.dev/badge/skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for detecting-memory-safety-bugs

Your own site · 80×15
<a href="https://agentmods.dev/skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs"><img src="https://agentmods.dev/badge/skills/unboundcompute/security-agent-skills/detecting-memory-safety-bugs.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 124 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,428 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found 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.1 $0.00124 $0.01428
Opus 5 $0.00062 $0.00714
Sonnet 5 $0.00025 $0.00286
Haiku 4.5 $0.00012 $0.00143

Measured 4d ago against content hash 20a3447e01f8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

detecting-memory-safety-bugs 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 4d 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.

skills/detecting-memory-safety-bugs/SKILL.md · 116 lines

How it starts

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

Detecting memory-safety bugs

Temporal and spatial memory bugs are the ones a sink-based catalog usually doesn't model: there's no single "dangerous function" to grep - the bug is a relationship between a pointer's lifetime and its use, or between an index and a bound, spread across code paths. So you hunt them by reasoning about lifetime and bounds, not by matching a call. This skill covers the five workhorse classes and how to confirm each.

When to use

  • The target is C/C++/Rust-unsafe/CGo or any unmanaged memory, and you want the classes a catalog leaves out (hunting-bugs-with-a-code-graph flags these as out-of-catalog and sends you here).
  • You're reviewing allocators, parsers, serializers, ring buffers, refcounting, or anything doing pointer arithmetic.

Scope check

Authorized source only. If you can't name the authorization, stop.

The five classes and how to confirm each

For every candidate, the confirmation is a path: an allocation/definition site, the operation that changes its state, and the use - read the source at each.

  1. Use-after-free (UAF). A pointer is used after its object is freed. Hunt: for each free/delete/refcount-drop, ask what still holds this pointer and can any path reach a use after this point - including aliases stored in structs, callbacks, and error paths. Confirm: a live path free → … → deref with no reassignment in between. Watch the classic shapes: free-in-a-loop then use, free in an error branch then fallthrough use, and a cached pointer that outlives the object.

  2. Double-free. The same allocation freed twice. Hunt: two frees reachable in sequence on some path without a nulling/reassignment between them; ownership handed to a callee that also frees; error paths that free then fall into a cleanup that frees again. Confirm: both frees hit the same object on one path.

  3. Out-of-bounds read/write. An index or pointer crosses a buffer's bound. Hunt: every buffer access where the index/length is attacker-influenced or derived from a separate field (length prefixes are a hotspot). Confirm: trace the index/length source and the buffer's true size; the bug is any path where index/len can exceed size - off-by-one at <= size, unchecked memcpy length, integer-truncated length, signed/unsigned confusion at the check.

Read the full file on GitHub · 116 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. 4d ago First seen · 116 lines · 124 tokens per session scan A 20a3447e01f8

Subscribe to this mod's changes

detecting-memory-safety-bugs is a skill published in the GitHub repository UnboundCompute/security-agent-skills (5 stars, last pushed yesterday), licensed MIT. It adds 124 tokens to every session and 1,428 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

Other skills, from other repositories

ffuf-claude-skill

Skill "ffuf-claude-skill" from Agent-Threat-Rule/agent-threat-rules, covering ffuf claude skill, when to use this skill and instructions.

Agent-Threat-Rule/agent-threat-rules · 14 tokens

codeinspectus-fix-one

Investigate and remediate exactly one user-selected CodeInspectus finding with evidence-gated reproduction, a separately approved minimal patch, focused regression testing, and an exact-prior-scan rescan. Use when a user asks an agent to examine, reproduce, fix, or verify one CodeInspectus finding without batching…

Synvoya/codeinspectus · 76 tokens

gauntlex:doctor

Full GAUNTLEX environment health check — model reachable, ChromaDB writable, AVF fixtures pass, no unexpected outbound network (air-gap verification). Use before first run or when debugging failures.

sanjoy1234/gauntlex · 45 tokens

prodcheck-review

Review this codebase against the prodcheck pre-production checklists — security, performance, scale, integrations and post-launch readiness. Use when asked to check whether a project is ready to ship, to audit an area before launch, or to work through a specific checklist. Produces evidence with file:line citations…

FarzamHabibi/pre-production-checklist · 70 tokens

diagnose-bundle

Maintainer/dev skill that triages an anonymised diagnostic bundle (appsec-diag-.tgz, produced by scripts/diagnosticbundle.py) a user sent after a pipeline failure. Runs the deterministic inspect, then cross-references the plugin source (scripts/, compact runtimes, agents/, AGENTS.md) and known-bug history to produce a…

appsec-foundry/appsec-advisor · 96 tokens

diagnose-run

Find the plugin defects behind the issues a create-threat-model run recorded. Reads .run-issues.json, re-reads each symptom next to the plugin's own code, and reports a file:line root cause per issue, or classifies it as an environment or expected condition. Read-only against the plugin; writes only .run-bugs.json.…

appsec-foundry/appsec-advisor · 117 tokens