Earlier quoted context omitted.
1. Can't the process just scrub LD_PRELOAD from its environment? Linker already done it's job at that point. 2. I'd suggest against using `strings` (let alone with sudo) on attacker controlled inputs
Turns out (1) works: #include #include static void begin() __attribute__((constructor)); void begin() { unsetenv("LD_PRELOAD"); } Build with: gcc -shared -fpie -o library.so library.c Test: LD_PRELOAD=~/library.so env | grep LD_PRELOAD
Usually guarded with an #ifndef DEBUG. Disallow LD_PRELOAD in Release builds