jvirkki / dupd

CLI utility to find duplicate files
http://www.virkki.com/dupd
GNU General Public License v3.0
113 stars 16 forks source link

Stack marked executable due to man-page embedding #18

Closed Freaky closed 6 years ago

Freaky commented 6 years ago

I came across this earlier: https://news.ycombinator.com/item?id=10816322

The linker trick has a problem. It doesn't set the non-executable stack bit, so as a result your whole binary will have an executable stack, and therefore be insecure against various stack smashing exploits. Try running 'readelf -S blob.o' and you won't see any '.note.GNU-stack' in the output.

dupd uses this approach to embed its manpage, and indeed, readelf -lW shows dupd has an executable stack on FreeBSD:

GNU_STACK ... RWE 0x8

Having patched it myself to simply call system("/usr/bin/man dupd") it indeed goes back to:

GNU_STACK ... RW  0x8
jvirkki commented 6 years ago

Looks like the clever way has outlasted its convenience and I'll switch to something dumber here.

jvirkki commented 6 years ago

(Good catch!)