@@ -97,7 +97,7 @@ Enables:
9797- ` DEBUG ` and ` _DEBUG ` preprocessor macros
9898- Debug symbols (` GCC_GENERATE_DEBUGGING_SYMBOLS: YES ` )
9999- No optimizations (` GCC_OPTIMIZATION_LEVEL: 0 ` )
100- - ` ASSERT_STATUS() ` macro checks (src/macros.h:140 )
100+ - ` ASSERT_STATUS() ` macro checks (src/macros.h)
101101
102102### Release Configuration (Default)
103103
@@ -114,9 +114,20 @@ Enables:
114114node-gyp rebuild --sqlite=/path/to/sqlite --sqlite_libname=sqlite3
115115```
116116
117- ### Specifying NAPI Version
117+ ### NAPI Version
118118
119- Prebuilt binaries are available for NAPI versions 3 and 6 (see ` package.json ` binary.napi_versions).
119+ The ` NAPI_VERSION ` define is set via ` napi_build_version ` variable in binding.gyp:
120+
121+ ``` python
122+ " defines" : [ " NAPI_VERSION=<(napi_build_version)" ]
123+ ```
124+
125+ ** How it works** :
126+ - The ` napi_build_version ` variable is automatically set by node-gyp based on the target Node.js version
127+ - For local builds, it's stored in ` build/config.gypi ` (e.g., ` "napi_build_version": "9" ` )
128+ - For prebuilds, the ` prebuild ` package passes it via ` --napi_build_version=<version> ` flag
129+
130+ ** Prebuilt binaries** : Available for NAPI versions 3 and 6 (see ` package.json ` ` binary.napi_versions ` ).
120131
121132## Assert Control
122133
@@ -172,6 +183,82 @@ yarn upload # Upload to GitHub releases
172183- NAPI versions: 3, 6
173184- Platforms: Linux, macOS, Windows (see prebuild configuration)
174185
186+ ## Security Hardening
187+
188+ The build system includes platform-specific security hardening flags to protect against common vulnerability classes.
189+
190+ ### Linux Hardening
191+
192+ Applied to all Linux builds (see ` binding.gyp ` ):
193+
194+ | Flag | Purpose |
195+ | ----------------------------| --------------------------------------------------------------------------------|
196+ | ` -fstack-protector-strong ` | Stack overflow protection - inserts canaries into functions with local buffers |
197+ | ` -fPIC ` | Position Independent Code - enables ASLR (Address Space Layout Randomization) |
198+
199+ Linker flags:
200+
201+ | Flag | Purpose |
202+ | ----------------| --------------------------------------------------------------------------------------|
203+ | ` -Wl,-z,relro ` | Read-Only Relocations - makes some ELF sections read-only after load |
204+ | ` -Wl,-z,now ` | Immediate binding - resolves all symbols at load time, prevents lazy binding attacks |
205+
206+ Release-only hardening:
207+
208+ | Flag | Purpose | Scope |
209+ | ------------------------| -------------------------------------------------------------------| -------------------|
210+ | ` _FORTIFY_SOURCE=2 ` | Source-level buffer overflow detection | All architectures |
211+ | ` -fcf-protection=full ` | Intel CET (Control Flow Guard) - protects against ROP/JOP attacks | x86_64 only |
212+
213+ ### Windows Hardening
214+
215+ Applied to all Windows builds (see ` binding.gyp ` ):
216+
217+ ** Compiler settings:**
218+
219+ | Setting | Purpose |
220+ | -------------------------------| ------------------------------------------------------|
221+ | ` ExceptionHandling: 1 ` | C++ exception handling support |
222+ | ` BufferSecurityCheck: "true" ` | Stack buffer overrun detection (/GS) |
223+ | ` ControlFlowGuard: "Guard" ` | Control Flow Guard - validates indirect call targets |
224+
225+ ** Linker settings:**
226+
227+ | Setting | Purpose |
228+ | ----------------| ----------------------------------------------------------------------|
229+ | ` /DYNAMICBASE ` | ASLR - randomizes base address at load time |
230+ | ` /NXCOMPAT ` | DEP (Data Execution Prevention) - marks stack/heap as non-executable |
231+
232+ Release-only hardening:
233+
234+ | Setting | Purpose |
235+ | ---------| -----------------------------------------|
236+ | ` /sdl ` | Additional security checks and warnings |
237+
238+ ### macOS Hardening
239+
240+ Applied to all macOS builds (see ` binding.gyp ` ):
241+
242+ | Flag | Purpose |
243+ | ------------------------------------| ---------------------------------|
244+ | ` -fstack-protector-strong ` | Stack overflow protection |
245+ | ` CLANG_CXX_LIBRARY: "libc++" ` | Use modern C++ standard library |
246+ | ` MACOSX_DEPLOYMENT_TARGET: "10.7" ` | Minimum deployment target |
247+
248+ ### Hardening Summary
249+
250+ | Platform | Stack Protection | ASLR | Control Flow | Buffer Checks |
251+ | ----------| ----------------------------------| -----------------------| --------------------------| ---------------------------|
252+ | Linux | Yes (` -fstack-protector-strong ` ) | Yes (` -fPIC ` + RELRO) | Yes (CET on x86_64) | Yes (` _FORTIFY_SOURCE=2 ` ) |
253+ | Windows | Yes (` BufferSecurityCheck ` ) | Yes (` /DYNAMICBASE ` ) | Yes (` ControlFlowGuard ` ) | Yes (` /sdl ` ) |
254+ | macOS | Yes (` -fstack-protector-strong ` ) | Yes (default) | No | No |
255+
256+ ### References
257+
258+ - [ OWASP Hardening Guide] ( https://owasp.org/www-project-web-security-testing-guide/ )
259+ - [ GCC Security Features] ( https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html )
260+ - [ MSVC Security Features] ( https://docs.microsoft.com/en-us/cpp/build/reference/security-best-practices )
261+
175262## Troubleshooting
176263
177264### Build Fails
@@ -196,3 +283,4 @@ yarn upload # Upload to GitHub releases
196283
197284- [ Project Overview] ( project-overview.md ) - Architecture and components
198285- [ Development Workflow] ( development.md ) - Testing and contributing
286+ - [ Decision Log] ( decisionLog.md ) - Technical decisions including hardening rationale
0 commit comments