native-memory-safety-and-ffi

native-memory-safety-and-ffi is a skill for Claude Code, Codex from makifbaysal/tasktrooper. It costs 93 tokens per session (2,165 once invoked), scanned A, original, Apache-2.0.

A security review guide for native code and interfaces between languages, such as C, C++, unsafe Rust, cgo, JNI, ctypes, native extensions, and unsafe pointers. It checks buffer limits, sizes, integer calculations, and object lifetimes when handling untrusted bytes.

In plain words
What is it for?
Use it when changing native parsers, loaders, plugins, unsafe code, foreign-function interfaces, or code that processes untrusted files, packets, images, documents, or other bytes.
Why use it?
A bad length or lifetime in native code can make the program read or write outside memory, use an object after it is released, or crash. The guide ties the risk to realistic inputs such as network data, files, plugins, or model files.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when changing native parsers, loaders, plugins, unsafe code, foreign-function interfaces, or code that processes untrusted files, packets, images, documents, or other bytes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi
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 makifbaysal/tasktrooper --skill native-memory-safety-and-ffi
Clone the repo
git clone --depth 1 https://github.com/makifbaysal/tasktrooper

Made for: Claude Code, Codex.

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 native-memory-safety-and-ffi

README.md
[![agentmods](https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi/github.svg)](https://agentmods.dev/skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi)
Your own site
<a href="https://agentmods.dev/skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi"><img src="https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi/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 native-memory-safety-and-ffi

Your own site · 80×15
<a href="https://agentmods.dev/skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi"><img src="https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/native-memory-safety-and-ffi.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,165 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.00093 $0.02165
Opus 5.5 $0.00037 $0.00866
Sonnet 5.5 $0.00019 $0.00433
Haiku 4.5 $0.00009 $0.00216

Measured 14d ago against content hash 85a86aa521ba, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

native-memory-safety-and-ffi 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 14d 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.

catalog/agents/security-agent/skills/native-memory-safety-and-ffi/SKILL.md · 110 lines

How it starts

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

Native Memory Safety and FFI

Overview

The hard exclusion on memory safety covers memory-safe languages. Native code is the opposite case: in C, C++, Objective-C, unsafe Rust, cgo, JNI and ctypes, one wrong length turns a packet, a save file, a mod, an image or a model file into a read or write outside the buffer. These bugs are in scope whenever untrusted bytes reach the code.

Core principle: re-derive every length, index and lifetime from the worst value the attacker can send — not from the value the tests use — and state the effect you can show (read, write, use-after-free, crash) without inflating it.

1. Who Sends the Bytes?

A finding needs a realistic untrusted source: a network peer, a file the user opens or downloads (save, replay, mod, asset, document, model), an IPC message from a less-trusted process, a plugin from a third party. A buffer bug reachable only from the program's own constant data, or from a developer's local CLI flag, is a bug, not a vulnerability.

2. Bounds (CWE-119, CWE-125, CWE-787)

// ❌ len comes from the packet; dst holds 64 bytes
uint16_t len = read_u16(pkt);
memcpy(dst, pkt->data, len);

// ✅ check against the destination AND what the source actually holds
if (len > sizeof(dst) || len > pkt->remaining) return ERR_MALFORMED;
memcpy(dst, pkt->data, len);

Check both sides of every copy. Recompute the room left after a header, a prefix, alignment padding or a terminator. strcpy, strcat, sprintf, gets and strncpy (no terminator when it truncates) on input are findings by shape; std::vector::operator[] and std::span do not check, .at() does.

3. Integer Arithmetic Before Allocation (CWE-190, CWE-191, CWE-681)

// ❌ both factors come from the wire: the 32-bit product wraps, the allocation is tiny,
//    and the loop still writes count records of rec bytes
uint32_t count = r.u32(), rec = r.u32();
uint8_t* buf = (uint8_t*)malloc(count * rec);
for (uint32_t i = 0; i < count; ++i) r.read(buf + (size_t)i * rec, rec);

// ✅ upper bounds, then checked multiplication in size_t
size_t bytes;
if (count > kMaxRecords || rec > kMaxRecordSize ||
    __builtin_mul_overflow((size_t)count, (size_t)rec, &bytes)) return Reject();

Read the full file on GitHub · 110 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. 14d ago First seen · 110 lines · 93 tokens per session scan A 85a86aa521ba

Subscribe to this mod's changes

native-memory-safety-and-ffi is a skill published in the GitHub repository makifbaysal/tasktrooper (120 stars, last pushed 8d ago), licensed Apache-2.0. It adds 93 tokens to every session and 2,165 once invoked, about $0.0004 per session on Opus 5.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-10-15.