Agent skill
security/memory-safety
Memory Safety security skill
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/memory-safety
SKILL.md
Memory Safety
C's primary vulnerability class. Buffer overflows, use-after-free, and integer issues remain the top attack vectors in native code.
ikigai Application
talloc mitigates but doesn't eliminate: Hierarchical ownership prevents leaks but not overflows or UAF within a context's lifetime.
Critical patterns:
- Bounds check ALL array access before use
- Validate sizes before allocation:
if (n > SIZE_MAX / elem_size) return ERR(...) - Never trust size values from external sources
- Use
talloc_array()not manual multiplication
Integer overflow risks:
size_tmultiplication for buffer sizes- Signed/unsigned conversion in comparisons
- Off-by-one in loop bounds
Detection tools:
- ASan (
make BUILD=sanitize) - buffer overflow, UAF - UBSan - undefined behavior, integer overflow
- Valgrind - memory errors, leaks
Review red flags: Manual pointer arithmetic, memcpy with computed sizes, array indexing without bounds check.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?