Native memory safety review
Reviews C, C++, unsafe Rust and FFI code for memory bugs an attacker can reach, so you fix the ones that matter.
What we improved
Made the skill stand alone: removed references to a diff review harness and its rules ("the hard exclusion", the needs-validation label name, a section number in another skill) and explained the same ideas in plain words. Rewrote the descri
Improved by YourAISkill from the original by makifbaysal, under its Apache-2.0 licence. The download includes the author's licence and a CHANGES.md listing every change. Both Claude reviews read the improved version.
Claude's review
8/10 Sharp native memory-safety and FFI review method with search patterns, accurate language specifics, severity guide and finding format.
We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.
In detail
Use when the diff changes C, C++ or Objective-C, Rust unsafe blocks, Go unsafe or cgo, JNI, Python ctypes/cffi or C extensions, Swift unsafe pointers, C# unsafe or Marshal code, or a native plugin, parser or loader that sees untrusted bytes - bounds, integer overflow before allocation, unit confusion, lifetimes, uninitialized memory, format strings, FFI ownership and library search order
How you use it
- Add it to your pack, then download your pack (1 credit).
- In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
- Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide
Safety check
Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.
An automated scan lowers risk but cannot promise zero risk. How we check skills
Preview
The first lines of SKILL.md
---
name: native-memory-safety-and-ffi
description: "Review C, C++, Objective-C, unsafe Rust, cgo and unsafe Go, JNI, Python ctypes, cffi and C extensions, Swift unsafe pointers, C# unsafe and Marshal code, or any native parser, plugin or loader that handles untrusted bytes, and report the memory-safety bugs an attacker can actually reach, with their real effect. Covers bounds, integer overflow before allocation, unit confusion, lifetimes and use-after-free, uninitialized memory and type confusion, format strings, FFI ownership, layout and unwinding, and library search order, plus a severity guide and a finding format. Use when reviewing a diff or file in native code, auditing a file format or network parser, checking an FFI boundary, or triaging a crash or sanitizer report for exploitability."
metadata:
category: security
tech_stack: Native code and FFI
source: "cloudflare/security-audit-skill (MIT) memory-safety, FFI/ABI and binary-loading attack classes, adapted to code review; own wording; CWE and SEI CERT C/C++ cited by name only"
---
<!-- Modified by YourAISkill (youraiskill.com) on 2 December 2026 from the original by makifbaysal. See CHANGES.md. -->
# Native Memory Safety and FFI
## Overview
Memory-safe languages (safe Go, Java, C#, Python, JavaScript) do not have this bug class, so do not hunt for it there. 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 matter 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.
## How to review
1. **Find where untrusted bytes enter** (section 1): sockets, file parsers, IPC handlers, plugin loaders, FFI entry points that take buffers.
2. **Search for the hot spots**, then read each hit in context:
```bash
rg -n 'memcpy|memmove|strcpy|strcat|sprintf|gets\(|strncpy|alloca|malloc\(|realloc\(' --type c --type cpp
rg -n 'printf\(|syslog\(|NSLog\(|String\(format:'
rg -n 'unsafe|from_raw_parts|get_unchecked|set_len|transmute|MaybeUninit|extern "C"' --type rust
rg -n 'unsafe\.(Pointer|Slice|String)|C\.(CString|GoBytes|free)|//export' --type go
rg -n 'Get\w*ArrayElements|GetStringUTFChars|GetPrimitiveArrayCritical|stackalloc|Marshal\.|fixed \(|LoadLibrary|dlopen'
```
3. **Trace the worst case** for each hit: which input controls the length, count, offset or lifetime, and what check (if any) stands between it and the access.
4. **Name the effect** the trace shows, then rate it with the severity guide. Drop anything with no realistic untrusted source.
5. **Write it up** in the finding format at the end.
## 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)
...From makifbaysal's repository, Apache-2.0 licence.
Related skills
-
Checked
Codebase quality audit
Audits a whole code repo for bugs, security holes, slow paths and dead code, ranked in plain English.
7/101 credit -
Checked
Security and CVE audit
Runs a security and CVE audit on code in any language and scores it out of 100, with false alarms filtered.
7/101 credit -
Checked
OWASP code review
Reviews code for security flaws using the latest OWASP Top 10 lists, including those for AI and agent apps.
7/101 credit -
Checked
Code security hardening
Hardens code that handles user input, logins and data against the OWASP Top 10, starting from a threat model.
7/101 credit -
Checked
Secure web backend code
Writes and reviews login, access control and input handling for web backends, so common attacks are blocked.
8/101 credit -
Checked
Android intent security
Audits Android components and incoming intents to fix redirection and unauthorised access holes in your app.
8/101 credit