Binary Hardening
Purpose
Guide agents through enabling and verifying binary security mitigations: checksec analysis, compiler and linker hardening flags (RELRO, PIE, stack canaries, FORTIFY_SOURCE, CFI), hardware shadow stack, and seccomp-bpf syscall filtering for defense-in-depth.
Triggers
- "How do I harden my binary against exploits?"
- "How do I check what security mitigations my binary has?"
- "What does checksec output mean?"
- "How do I enable RELRO, PIE, and stack canaries?"
- "How do I use seccomp to restrict syscalls?"
- "How do I enable CFI (control flow integrity)?"
Workflow
1. Analyze existing binary with checksec
2. Hardening compiler and linker flags
Flag reference:
3. Control Flow Integrity (CFI)
Clang's CFI prevents calling virtual functions through wrong types (vtable CFI) and indirect calls to mismatched functions:
4. Stack canaries in depth
5. FORTIFY_SOURCE
FORTIFY_SOURCE wraps unsafe libc functions (memcpy, strcpy, sprintf) with bounds-checked versions when the buffer size can be determined at compile time:
6. seccomp-bpf syscall filtering
7. Intel CET (Shadow Stack + IBT)
Requires hardware CET support (Intel Tiger Lake+ for SHSTK/IBT; AMD Zen 3+ for shadow stack on supported SKUs) and a kernel built with CET enabled.
8. ARM BTI and PAC (AArch64)
9. ARM Memory Tagging (MTE)
MTE assigns 4-bit tags to 16-byte granules — hardware detects tag mismatch on access.
10. glibc shadow stack (2.39+)
Shadow stack maintains a hardware-protected copy of return addresses separate from the data stack.
For the full hardening flags reference, see references/hardening-flags.md [blocked].
Related skills
- Use
skills/runtimes/sanitizersfor ASan/UBSan during development - Use
skills/observability/ebpffor seccomp-bpf program writing with libbpf - Use
skills/rust/rust-securityfor Rust's memory-safety hardening approach - Use
skills/binaries/elf-inspectionto verify mitigations in ELF binaries


