Skip to content

CWE-117: StructuredFormatter does not neutralize NUL (0x00) after #1270/#1255 consolidation #1421

Description

@groupthinking

Summary

The CWE-117 log-forging hardening merged via #1270 (now on main, _UNSAFE_LOG_CHARS in src/youtube_extension/backend/config/logging_config.py) covers the full str.splitlines() boundary set (LF, CR, VT, FF, FS, GS, RS, NEL, LS, PS) plus ESC — but omits NUL (0x00).

How it regressed

The 6-PR CWE-117 cluster consolidation on #1270 explicitly noted that #1270 does not neutralize NUL and that #1255 was the only PR carrying it, with the instruction to add ord("\x00") before merging so that closing #1255 would not regress NUL coverage. In the event, #1255 was closed (2026-08-04) and #1270 merged (2026-08-07) without the codepoint ever being carried over. NUL coverage is therefore absent on main.

Impact

A raw NUL reaching a C-based log shipper (or any length-prefixed/strlen-based consumer) can truncate the record, dropping or corrupting the tail of a log line — the same class of downstream log integrity failure the rest of _UNSAFE_LOG_CHARS defends against.

Evidence

origin/main @ 5934cbf_UNSAFE_LOG_CHARS has no 0x00 entry (verified by reading the merged file).

Acceptance criteria

  • _UNSAFE_LOG_CHARS escapes 0x00 to a JSON-valid `` sequence, consistent with the existing table.
  • A NUL in message text, exc_info, or extra fields does not reach the sink raw.
  • The escape round-trips (reversible) and keeps JSON logs parseable.
  • Regression test covering NUL neutralization.

Scope

  • src/youtube_extension/backend/config/logging_config.py
  • tests/unit/test_logging_config_crlf.py

Activity

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions