fix(security): neutralize CR/LF in rendered log records (CWE-117) - #1332
fix(security): neutralize CR/LF in rendered log records (CWE-117)#1332groupthinking wants to merge 1 commit into
Conversation
StructuredFormatter.format() now escapes every str.splitlines() boundary (LF, CR, VT, FF, FS, GS, RS, NEL, LS, PS) plus ESC in the final rendered record via a shared sanitize_log_record() table. Escapes are JSON-valid \uXXXX sequences with backslash escaped first, so the transform is unambiguous and reversible and JSON logs stay parseable. Covers message text, exc_info tracebacks, logger.exception, and structured extra fields. Lands PR #1270. Generated with [Linear](https://linear.app/myxstack/issue/GRV-295/land-pr-1270-fixsecurity-neutralize-crlf-in-rendered-log-records-cwe#agent-session-930110d5) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
Agent Completion Truth Gate: NOT_APPLICABLEEvidence agrees. Machine-readable verdict{
"details": {},
"reasons": [],
"verdict": "not_applicable"
} |
Closing in favour of #1270 — the patches are byte-identicalThis branch is a re-land attempt of #1270. Comparing the two diffs against their merge bases, ignoring only Both are 2 files, +215 / −1. There is no content difference to choose between, so the tiebreak is review evidence: #1270 already carries CodeRabbit approval, a resolved review thread, and a READY preview (verified at This re-land only exists because #1270 could not clear the merge gate. That root cause — the truth gate being unsatisfiable for PRs with no linked dispatch contract — is fixed in #1377, so #1270 no longer needs a re-land to get through. Closing this; #1270 is canonical for the CWE-117 CR/LF log-injection fix. Branch retained and will be archive-tagged before any deletion. Generated by Claude Code |
Canonical issue
Closes #1271. Relands #1270 on a branch based on current
main.Outcome
Every rendered log record emits as a single physical line. Attacker-controlled line separators can no longer forge, corrupt, or split downstream log entries — including via
logger.error(..., exc_info=True),logger.exception(...), and structuredextrafields — and JSON logs stay parseable.Scope
src/youtube_extension/backend/config/logging_config.py—StructuredFormatter.format()escapes everystr.splitlines()boundary (LF, CR, VT, FF, FS, GS, RS, NEL, LS, PS) plus ESC in the final rendered record via a sharedsanitize_log_record()/_UNSAFE_LOG_CHARStable. Escapes are JSON-valid\uXXXXsequences; backslash is escaped first so the transform is unambiguous and reversible.tests/unit/test_logging_config_crlf.py— regression tests against rendered handler output.Risk
\uXXXXescapes; content is fully preserved and losslessly reversible.Verification
Tied to head
ca889eb.pytest tests/unit/test_logging_config_crlf.py→ 9 passedruff checkclean on both changed filesProduction evidence
Not applicable: Python-only logging change with no web surface; correctness is proven by the rendered-output regression suite.