← Back to Blog
Pure ASM - simpler to exploit?
2026-11-24 03:10 · 57f289cd
Generalc/cppasm
# Pure ASM + 64-bit: Is It "Simpler" to Exploit?
Good question. The short answer: a little easier, but not dramatically. Here's why:
If you hand-write assembly, you skip these C-compiler features:
| Protection | Source | ASM-only? |
|---|---|---|
| Stack canary |
| FORTIFY_SOURCE |
| CFI / Shadow Stack |
| Bounds checks on arrays | C compiler | ❌ Not generated |
So yes — no canary to check before
This is the critical point:
| Protection | Who enforces it | Survives ASM-only? |
|---|---|---|
| NX / DEP | Kernel (page tables) | ✅ Still ON |
| ASLR (48-bit) | Kernel at
| PIE | Linker (
| Full RELRO | Linker | ✅ Still ON |
| CET / Shadow Stack | CPU (Intel/AMD) + kernel | ✅ Still ON (newer hardware) |
| SECCOMP / Landlock | Kernel (sandbox) | ✅ Still ON |
| Kernel hardening | Kernel | ✅ Still ON |
> The OS doesn't care whether your binary is C, Rust, or hand-written ASM. NX, ASLR, and PIE are enforced at
``
Good question. The short answer: a little easier, but not dramatically. Here's why:
What You Lose (Compiler-Generated)
If you hand-write assembly, you skip these C-compiler features:
| Protection | Source | ASM-only? |
|---|---|---|
| Stack canary |
gcc -fstack-protector | ❌ Not generated || FORTIFY_SOURCE |
gcc -D_FORTIFY_SOURCE=2 | ❌ Not generated || CFI / Shadow Stack |
clang -fstack-protector-strong | ❌ Not generated || Bounds checks on arrays | C compiler | ❌ Not generated |
So yes — no canary to check before
ret, no _chk_ wrapper functions. A simple OOB write that corrupts the saved rip/rsp is less guarded.What You Don't Lose (OS / Kernel / Linker)
This is the critical point:
| Protection | Who enforces it | Survives ASM-only? |
|---|---|---|
| NX / DEP | Kernel (page tables) | ✅ Still ON |
| ASLR (48-bit) | Kernel at
execve() | ✅ Still ON || PIE | Linker (
-pie is default) | ✅ Still ON || Full RELRO | Linker | ✅ Still ON |
| CET / Shadow Stack | CPU (Intel/AMD) + kernel | ✅ Still ON (newer hardware) |
| SECCOMP / Landlock | Kernel (sandbox) | ✅ Still ON |
| Kernel hardening | Kernel | ✅ Still ON |
> The OS doesn't care whether your binary is C, Rust, or hand-written ASM. NX, ASLR, and PIE are enforced at
execve() / page-fault time.So What Actually Gets Easier?
``
C binary: [canary check] → [NX blocks exec] → [ASLR randomizes]
→ need leak → need ROP → need gadgets
ASM binary: [no canary] → [NX blocks exec] → [ASLR randomizes]
→ need leak → need ROP → need gadgets
↑
(one fewer gate, but the rest is identical)
`
The exploit chain is the same:
1. Leak an address (format string, OOB read, UAF) — still needed
2. Build a ROP/JOP chain — still needed
3. Defeat NX — still needed (ROP uses existing code)
What changes is step 1 → step 2: with no canary, a simple OOB write that hits the saved rip is more likely to succeed before you even need ROP. But you still need the leak to defeat ASLR.
When It
Actually* Gets Much Easier
| Scenario | Why |
|---|---|
| Static, non-PIE binary (-static -no-pie) | No ASLR randomization of your own binary's base; GOT entries writable |
| 32-bit ASM on 64-bit OS | 32-bit ASLR space is much smaller; stack smashing is easier |
| Embedded / RTOS (no ASLR, no NX) | Classic jmp $rip shellcode works |
| Older OS (pre-ASLR kernels) | No randomization at all |
| CET / Shadow Stack disabled | ROP is trivial |
TL;DR
| | C (hardened) | C (plain) | Pure ASM |
|---|---|---|---|
| Stack canary | ✅ | ⚠️ (if not compiled with -fno-stack-protector) | ❌ |
| NX / DEP | ✅ (kernel) | ✅ (kernel) | ✅ (kernel) |
| ASLR | ✅ (kernel) | ✅ (kernel) | ✅ (kernel) |
| PIE / RELRO | ✅ (linker) | ✅ (linker) | ✅ (linker) |
| Classic overflow → shellcode | ❌ | ❌ | ❌ |
| Overflow → ROP (after leak) | ⚠️ | ⚠️ | ⚠️ (slightly fewer gates) |
> Writing in ASM removes ~1–2 compiler-level gates, but the OS-level defenses (NX, ASLR, PIE, CET) are still fully in place. The exploit is marginally easier, but the same core challenge remains: you still need an information leak to defeat ASLR, and NX to block raw shellcode.
In 2025, a 64-bit Linux system with default settings will stop a pure-ASM buffer overflow exploit just as reliably as it stops a C one. The "easy" days of overflow → shellcode` are over regardless of language.
Comments
0 comments