You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specs/tasks/M7-v2-cleanup/TASK-068.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,12 @@ Two acknowledged residual gaps at `connection_state.hpp:122, 130`:
10
10
2. CWE-14 — the current clear path uses `memset(…, 0, …)`, which an optimizer may dead-code-eliminate. Replace with `explicit_bzero` (or a portable equivalent) so the zeroing is observable.
11
11
12
12
**Action Items:**
13
-
-[ ] In `connection_state::reset()` (or whatever clears the arena between requests), zero the entire used-bytes prefix unconditionally. Document the trade-off (cycles vs. CWE-226 mitigation) in the header.
14
-
-[ ] Replace the `memset` call with `explicit_bzero` on glibc/musl/macOS, `SecureZeroMemory` on Windows, or a hand-rolled `volatile`-pointer loop where neither is available. Centralize the helper in `src/httpserver/detail/secure_zero.hpp`.
15
-
-[ ] Update the inline comments at lines 122 and 130 to reference the fix.
16
-
-[ ] Add a unit test (compile-time + runtime) that pins the helper is not dead-code-eliminated under `-O2` (using a memory barrier and a `volatile` sink to observe the write).
13
+
-[x] In `connection_state::reset_arena()`, zero the entire `initial_buffer_` unconditionally via the new `httpserver::detail::secure_zero` helper. The trade-off (a few thousand cycles per keep-alive request for a non-elidable byte-wise clear vs. the CWE-14 + CWE-226 mitigation) is documented in the rewritten comment block at lines 106-148.
14
+
-[x] Replace the `memset` call with the `secure_zero` helper centralized in `src/httpserver/detail/secure_zero.hpp`. The helper dispatches at compile time to `explicit_bzero` (glibc/musl/BSD), `RtlSecureZeroMemory` (Windows), or a portable `volatile`-pointer loop + `asm __volatile__("" ::: "memory")` clobber fallback (macOS + any lane without `explicit_bzero`). Note: `memset_s` was evaluated and skipped -- its `__STDC_WANT_LIB_EXT1__` include-order requirement is incompatible with a transitively-included internal header, so macOS takes the portable fallback (same security guarantee without the preprocessor-order coupling).
15
+
-[x] Updated the inline comments at the formerly-line-122 / formerly-line-130 sites (now lines 106-148 of `connection_state.hpp`) to reference the `secure_zero` helper and the CWE-14 / CWE-226 posture. Also updated the cross-reference comment at `src/detail/webserver_callbacks.cpp:124`.
16
+
-[x] Added `test/unit/secure_zero_dce_test.cpp` -- compiled at `-O2 -DNDEBUG` (per-target `CXXFLAGS` override), prefills a 256-byte buffer with 0xA5, calls `secure_zero`, then reads every byte through a `volatile unsigned char sink` and asserts each is zero. Also pinned `secure_zero(nullptr, 0)` and `secure_zero(p, 0)` no-op contracts.
17
+
-[x] Added `test/unit/connection_state_sentinel_test.cpp` -- prefills the full 8 KiB arena with 0xDE, calls `reset_arena()`, and asserts every byte is zero (CWE-226 unit pin). A companion test confirms that a sentinel pattern written into a 512-byte arena allocation is scrubbed after `reset_arena()` + same-size re-allocation.
18
+
-[x] Added `test/integ/connection_state_body_residue_test.cpp` -- the acceptance-criterion integ test. Two `GET /peek` requests over a single curl-keep-alive connection; the first carries a `DEADBEEFCRED_SENTINEL_USERNAME_FROM_REQUEST_1` basic-auth username (decoded into the arena-backed `http_request_impl::username` pmr::string), the second carries no Authorization header. The handler peeks `connection_state::initial_buffer_` via a new `HTTPSERVER_COMPILATION`-gated `http_request::underlying_connection_for_testing()` accessor. Sanity: request 1's handler observes the sentinel; headline: request 2's handler does not. Belt-and-braces: a server-wide `connection_opened` hook fires exactly once across both requests.
17
19
18
20
**Dependencies:**
19
21
- Blocked by: None
@@ -29,4 +31,4 @@ Two acknowledged residual gaps at `connection_state.hpp:122, 130`:
0 commit comments