The x86-64 movaps Alignment Trap
- libc functions (e.g.
system) use SSE instructions likemovapsthat require RSP to be 16-byte aligned. - If
RSP % 16 != 0at thecall, you crash inside libc with aSIGSEGVon amovaps XMMWORD PTR [rsp...]. - Symptom: your chain looks perfect but dies deep inside libc, not in your gadgets.
- Fix: burn one extra
retgadget to shiftRSPby 8 and restore alignment:
rop.raw(rop.ret) # a bare 'ret' gadget = +8 to RSP, realigns to 16
rop.system(binsh)
{ Rule of thumb: if a 64-bit ret2libc mysteriously crashes in
libc, add one ret and try again.}