-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add binary hardening compile and link flags #4603
Conversation
Awesome! Thanks for adding this, @thejohnfreeman! I wanted to add this for a really long time. |
Suggested commit message:
|
@thejohnfreeman can you bring this up-to-date with develop? I don't have permission to apply a merge commit to your branch. (This can wait for Monday, of course) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a grand change!
Enhance security during the build process: * The '-fstack-protector' flag enables stack protection for preventing buffer overflow vulnerabilities. If an attempt is made to overflow the buffer, the program will terminate, thus protecting the integrity of the stack. * The '-Wl,-z,relro,-z,now' linker flag enables Read-only Relocations (RELRO), a feature that helps harden the binary against certain types of exploits, particularly those that involve overwriting the Global Offset Table (GOT). * This flag is only set for Linux builds, due to compatibility issues with apple-clang. * The `relro` option makes certain sections of memory read-only after initialization to prevent them from being overwritten, while `now` ensures that all dynamic symbols are resolved immediately on program start, reducing the window of opportunity for attacks.
Enhance security during the build process: * The '-fstack-protector' flag enables stack protection for preventing buffer overflow vulnerabilities. If an attempt is made to overflow the buffer, the program will terminate, thus protecting the integrity of the stack. * The '-Wl,-z,relro,-z,now' linker flag enables Read-only Relocations (RELRO), a feature that helps harden the binary against certain types of exploits, particularly those that involve overwriting the Global Offset Table (GOT). * This flag is only set for Linux builds, due to compatibility issues with apple-clang. * The `relro` option makes certain sections of memory read-only after initialization to prevent them from being overwritten, while `now` ensures that all dynamic symbols are resolved immediately on program start, reducing the window of opportunity for attacks.
Enhance security during the build process: * The '-fstack-protector' flag enables stack protection for preventing buffer overflow vulnerabilities. If an attempt is made to overflow the buffer, the program will terminate, thus protecting the integrity of the stack. * The '-Wl,-z,relro,-z,now' linker flag enables Read-only Relocations (RELRO), a feature that helps harden the binary against certain types of exploits, particularly those that involve overwriting the Global Offset Table (GOT). * This flag is only set for Linux builds, due to compatibility issues with apple-clang. * The `relro` option makes certain sections of memory read-only after initialization to prevent them from being overwritten, while `now` ensures that all dynamic symbols are resolved immediately on program start, reducing the window of opportunity for attacks.
Add full RELRO and stack canary when compiling with GCC or Clang.