Skip to content

FIX: enforce POSIX native binary hardening - #810

Draft
Sumit Sarabhai (sumitmsft) wants to merge 1 commit into
mainfrom
sumitsar/fix-cf041-native-hardening
Draft

Sumit Sarabhai (sumitmsft) wants to merge 1 commit into
mainfrom
sumitsar/fix-cf041-native-hardening

Conversation

@sumitmsft

@sumitmsft Sumit Sarabhai (sumitmsft) commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • default single-config POSIX builds to Release when no build type is supplied
  • enable stack protection for the native extension on POSIX
  • select _FORTIFY_SOURCE=3 when supported, otherwise level 2, excluding Debug builds
  • enable full RELRO, immediate binding, and non-executable stack declarations on Linux
  • add source-contract, ELF parser, and loaded-extension regression tests

The hardening options are private to ddbc_bindings; simdutf compilation is unchanged. macOS retains its existing dynamic-link behavior, and Windows behavior is unchanged.

Validation

  • Windows x64 native build
  • 37 passed, 4 expected platform skips
  • import, formatting, and diff checks
  • hosted CI will validate manylinux, musllinux, ARM64, macOS, and Clang coverage

AB#48377

AB#48377

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 23, 2026 18:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

ELF linker flags must be restricted to Linux targets to avoid unsupported options on other UNIX platforms.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This PR strengthens POSIX native-extension binary hardening and adds regression coverage.

Changes:

  • Defaults single-config builds to Release.
  • Adds compiler and linker hardening flags.
  • Adds source-contract and ELF validation tests.
File Summary
tests/​test_040_native_binary_hardening.py Verifies hardening configuration and Linux ELF properties.
mssql_python/​pybind/​CMakeLists.txt Configures build defaults and native hardening flags.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +426 to +430
target_link_options(ddbc_bindings PRIVATE
-Wl,-z,relro
-Wl,-z,now
-Wl,-z,noexecstack
)
@github-actions github-actions Bot added the pr-size: medium Moderate update size label Sep 23, 2026
@github-actions

Copy link
Copy Markdown

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

84%


📈 Total Lines Covered: 9054 out of 10697
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.performance_counter.hpp: 0.7%
mssql_python.pybind.logger_bridge.cpp: 57.9%
mssql_python.pybind.ddbc_bindings.h: 64.1%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 78.4%
mssql_python.pybind.connection.connection_pool.cpp: 82.3%
mssql_python.pybind.connection.connection.cpp: 82.5%
mssql_python.logging.py: 86.2%
mssql_python.pooling.py: 90.1%
mssql_python.pybind.fetch_temporal.hpp: 92.1%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: medium Moderate update size

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants