Skip to content

Add security hardening flags for variable initialization and code separation - #12

Open
assisted-by-ai wants to merge 1 commit into
Whonix:masterfrom
assisted-by-ai:claude/secure-compile-options-YFM9a
Open

Add security hardening flags for variable initialization and code separation#12
assisted-by-ai wants to merge 1 commit into
Whonix:masterfrom
assisted-by-ai:claude/secure-compile-options-YFM9a

Conversation

@assisted-by-ai

Copy link
Copy Markdown
Contributor

Summary

This change enhances the security posture of the build by adding three additional compiler and linker hardening flags to prevent information leaks and mitigate code reuse attacks.

Key Changes

  • -ftrivial-auto-var-init=zero: Zero-initializes all local variables to prevent information leaks from uninitialized stack memory
  • -fzero-call-used-regs=used-gpr: Zeros out general-purpose registers before function returns to mitigate ROP (Return-Oriented Programming) attacks and prevent register-based information leaks
  • -Wl,-z,separate-code: Separates code from data pages in the ELF binary, improving exploit mitigation by preventing code execution from data sections

Implementation Details

  • Added the three flags to the FORTIFY_CFLAGS variable for compiler-level hardening
  • Added the linker flag to LDFLAGS for binary-level hardening
  • Updated comments in the Makefile to document the purpose of each new flag
  • Reformatted the LDFLAGS definition for improved readability while maintaining the same functionality

https://claude.ai/code/session_0142B2pFVbeUUMQtjProiL6q

Add three additional compile-time security options:
- -ftrivial-auto-var-init=zero: zero-initializes local variables to prevent
  information leaks from uninitialized stack memory
- -fzero-call-used-regs=used-gpr: zeros registers before function return to
  mitigate ROP gadgets and register-based info leaks
- -Wl,-z,separate-code: separates code pages from data pages in the ELF binary,
  ensuring code pages are truly non-writable

https://claude.ai/code/session_0142B2pFVbeUUMQtjProiL6q
@ArrayBolt3

Copy link
Copy Markdown
Contributor

Accepted with tweaks in ArrayBolt3@377dbac.

adrelanos pushed a commit that referenced this pull request May 10, 2026
Re-applies session work lost during rebase: explicit ANTHROPIC_API_KEY
secret in .github/workflows/claude-code.yml (replacing secrets:
inherit), explicit COVERITY_SCAN_TOKEN/COVERITY_SCAN_EMAIL secrets in
.github/workflows/coverity.yml, and corrects the coverity project-name
from Whonix-kloak to Whonix/kloak (the URL renders / as -, but the API
form parameter requires the slash).

Co-authored-by: claude-code <claude-code@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants