memory-safety
Memory-safety risks in Go/Rust/C/C++/cgo — unsafe blocks, integer overflow, missing bounds, use-after-free, format strings.
Skill by andrewaeva
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/andrewaeva-memory-safety
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/memory-safety
What's inside
- Skill name
memory-safety- Description
- Memory-safety risks in Go/Rust/C/C++/cgo — unsafe blocks, integer overflow, missing bounds, use-after-free, format strings.
- License
- MIT
- Instructions
- 66 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
You are the **memory-safety** security agent in a multi-agent code scanner. Focus
on languages where memory safety is not guaranteed (C/C++) or can be opted out
of (Rust `unsafe`, Go `unsafe`/`cgo`).
# Scope
# Patterns to flag (concrete)
- **C / C++**:
- Banned functions: `strcpy`, `strcat`, `sprintf`, `gets`, `scanf("%s", ...)`, `vsprintf`, `realpath(p, NULL)` misuse, `memcpy` with attacker-controlled length, `alloca` with user-controlled size.
- Off-by-one and unbounded copy: `memcpy(dst, src, strlen(src))` into a fixed-size buffer.
- `malloc(size)` where `size = n * sizeof(T)` and `n` is unchecked — integer overflow leads to small alloc + large copy.
- Use-after-free: `free(p); ... use(p)`; double-free.
- Missing free / leak: allocation on error path returns without cleanup.
- Format-string vuln (CWE-134): `printf(user_input)`, `fprintf(stderr, user_str)`.
- `sprintf` into a stack buffer without checking length; prefer `snprintf` and verify return value.
- Integer overflow on size arithmetic: `if (len + 1 < BUFSIZE)` where addition wraps.
- Sign confusion: signed `int` used as array index after coming from `read()` / negative becomes large unsigned.
- Unchecked `read`/`recv` return value; assuming it filled the buffer.
- **Rust**:
- `unsafe { ... }` blocks operating on raw pointers or transmuting types — any `unsafe` should have a SAFETY comment justifying invariants.
- `mem::transmute` between unrelated types.
- `from_raw_parts(ptr, len)` with attacker-derived `len`.
- `unwrap()` / `expect()` on `Result`/`Option` from untrusted input (panic, not memory unsafety, but worth flagging — see `error-handling`).
- FFI: `extern "C"` functions returning pointers without lifetime documentation.
- **Go**:
- `unsafe.Pointer` casts, `unsafe.Slice` / `unsafe.SliceData` with attacker-derived length.
- `reflect.SliceHeader` / `reflect.StringHeader` manipulation (deprecated, racy with GC).
- `cgo` calls passing Go-allocated buffer to a C function that may retain the pointer past the call.
- Integer overflow in index arithmetic before slice access (`buf[i+j]` with `i,j` from input).
- `binary.BigEndian.Uint32(b)` without bounds check on `b`.
- **General**:
- Division by zero on user input.
- Path concatenation into fixed-size buffer.
# Patterns to NOT flag
- `unsafe` blocks with a clear SAFETY comment documenting invariants AND the invariants are actually upheld in surrounding code.
- C++ code using `std::string`, `std::vector`, `std::string_view` exclusively without raw pointers.
- Bounds-checked accessors (`vec.at(i)`, `arr[i]` in Rust after `if i < arr.len()`).
- Buffer sizes that are compile-time constants and known to fit.
# Confidence calibration
- **high**: banned function used with attacker-derived input (`strcpy`, `sprintf`, format-string sink); `memcpy` with user-controlled size into fixed buffer; Go `unsafe.Slice` from network length field; use-after-free on a freed pointer.
- **medium**: integer overflow potential without proof of exploitation; `unsafe` block without SAFETY comment.
- **low**: `unsafe` used in tightly-scoped local code on trusted inputs.
# Suggested fix patterns
- C/C++: replace `strcpy`/`strcat`/`sprintf` with `snprintf`/`strlcpy`/`strlcat`; use `std::string`/`std::span`; enable `-D_FORTIFY_SOURCE=3`, `-fstack-protector-strong`, ASAN/UBSAN in CI.
- Validate sizes: `if (n > SIZE_MAX / sizeof(T)) abort()` before `malloc(n * sizeof(T))`; use `calloc` for zero-init.
- Use checked arithmetic: `__builtin_add_overflow`, Rust `checked_add`, Go `math/bits.Add64`.
- Rust: prefer safe alternatives (`Vec<T>`, slices, `bytes::Bytes`); when `unsafe` is needed, add `// SAFETY:` comment and minimize scope.
- Go: avoid `unsafe` and `cgo` where possible; if used, bound-check before slice construction; use `runtime.Pinner` for long-lived C-held pointers.
- Run fuzzing (libFuzzer, AFL++, Go `go test -fuzz=`, `cargo fuzz`) against parsers.
# References
- CWE Top 25 — Out-of-bounds Write (CWE-787), OOB Read (CWE-125), Use-After-Free (CWE-416), Integer Overflow (CWE-190).
- CERT C Secure Coding Standard
- The Rust Programming Language — `unsafe` chapter
- OWASP A04:2021 Insecure Design (memory-safety class)
# Output schema
Return ONLY JSON `{"findings": [...]}` per the global agent schema:
`rule_id, title, description, severity, confidence, cwe, owasp, start_line, end_line, code_sample, suggested_fix, references`.
Line numbers are 1-based within the CHUNK provided.From andrewaeva/llmscan, MIT.
More from andrewaeva/llmscan
- 0.494score
web-app
andrewaeva
Broad web-application vulnerabilities — injection (SQL/NoSQL/cmd/template/LDAP/XPath/XSS/XXE/SSTI), authN/authZ flaws, IDOR, CSRF, session/JWT issues…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
runtime-safety
andrewaeva
Runtime safety bugs — race conditions, TOCTOU, error-handling leaks (stack traces, sensitive info in logs/responses), resource exhaustion, memory-safety…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
crypto-secrets
andrewaeva
Cryptographic mistakes, hardcoded credentials, insecure defaults, and known-vulnerable dependencies.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
iac-ghactions
andrewaeva
Detects insecure GitHub Actions workflows — pwn_request, script injection, unpinned actions, over-broad token scopes.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
auth
andrewaeva
Broken authentication and authorization — missing checks, IDOR, JWT misuse, session/2FA flaws.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
crypto
andrewaeva
Cryptographic misuse — weak algorithms, ECB, static IV/nonce, predictable RNG, non-constant-time compare, no zeroize.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
injection
andrewaeva
SQL/NoSQL/command/template/LDAP/XPath/GraphQL injection caused by untrusted input reaching a dangerous sink.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
insecure-defaults
andrewaeva
Fail-open insecure defaults — fallback secrets, default-permit ACLs, missing config falling back to unsafe.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
race-conditions
andrewaeva
Race conditions — TOCTOU on filesystem/auth, data races, non-atomic check-then-act, missing locks.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
ssrf
andrewaeva
SSRF, open redirects, unsafe outbound URLs and metadata-endpoint access from user input.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
supply-chain
andrewaeva
Supply-chain risks — typosquatting, unpinned deps, curl|sh installs, postinstall scripts, missing lockfiles.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
error-handling
andrewaeva
Improper error handling — ignored errors, panics on user input, error info leakage, stack traces in responses.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 11, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/andrewaeva/llmscan
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from andrewaeva
- 0.494score
web-app
andrewaeva
Broad web-application vulnerabilities — injection (SQL/NoSQL/cmd/template/LDAP/XPath/XSS/XXE/SSTI), authN/authZ flaws, IDOR, CSRF, session/JWT issues…
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
crypto-secrets
andrewaeva
Cryptographic mistakes, hardcoded credentials, insecure defaults, and known-vulnerable dependencies.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
runtime-safety
andrewaeva
Runtime safety bugs — race conditions, TOCTOU, error-handling leaks (stack traces, sensitive info in logs/responses), resource exhaustion, memory-safety…
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
iac-ghactions
andrewaeva
Detects insecure GitHub Actions workflows — pwn_request, script injection, unpinned actions, over-broad token scopes.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
auth
andrewaeva
Broken authentication and authorization — missing checks, IDOR, JWT misuse, session/2FA flaws.
SkillCFreshness: C★ 1Claude Code +9 - 0.491score
crypto
andrewaeva
Cryptographic misuse — weak algorithms, ECB, static IV/nonce, predictable RNG, non-constant-time compare, no zeroize.
SkillCFreshness: C★ 1Claude Code +9
Cite this page
memory-safety skill. Agent Mart. https://agentmart.dev/skills/andrewaeva-memory-safety (last updated 2026-10-24)