Skip to content

Add security hardening compiler flags for local development builds #2

@Plenvorik

Description

@Plenvorik

Summary

Add compiler security hardening flags to CMakeLists.txt for local development builds. While Fedora's RPM build system automatically adds these flags via %cmake macro, explicitly setting them ensures consistent security posture across all build environments.

Current State

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG")

Proposed Addition

# Security hardening flags
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -D_FORTIFY_SOURCE=2 -fstack-protector-strong")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro,-z,now")

Flags Explained

Flag Purpose
-fstack-protector-strong Detects stack buffer overflows
-D_FORTIFY_SOURCE=2 Runtime buffer overflow detection
-Wl,-z,relro,-z,now Full RELRO - protects GOT from overwrites

Priority

Low - This is a defense-in-depth improvement. RPM builds via rpmbuild or fedpkg already include these flags automatically.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions