Strip CR/LF from user-supplied logical_date before stdlib logging#67500
Merged
Conversation
``action_logging`` passed the raw ``logical_date`` query parameter into
``logger.exception("... %s", value)`` via Python's standard logging
module on parse failure. On deployments configured with a non-JSON
(plain-text) log formatter, an attacker could supply a value containing
newline characters to forge fake log entries (CWE-117 log injection).
The path is bounded — only exploitable on non-default plain-text
formatters and only when the user actually triggers a parse failure —
but the fix is cheap: replace ``\r`` and ``\n`` with spaces before
formatting.
Extract the sanitisation into ``_sanitize_for_stdlib_log()`` so the
guard is testable in isolation. ``logger.exception`` is left in place
on the stdlib logger (rather than swapped for ``structlog``) to keep
the change minimal and avoid coupling the audit-log path's other
behaviour changes into a security fix.
Member
Author
|
defense-in-depth |
bugraoz93
approved these changes
May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
action_loggingpasses the rawlogical_datequery parameter intologger.exception("... %s", value)via Python's standard logging module on parse failure. On deployments configured with a non-JSON (plain-text) log formatter, an attacker could supply a value containing newline characters to forge fake log entries (CWE-117 log injection).The path is narrow — only exploitable on non-default plain-text formatters AND only when the user triggers a parse failure — but the fix is cheap.
Reported as F-018 in the
apache/tooling-agentsL3 ASVS sweep0920c77.Change
Add
_sanitize_for_stdlib_log()that replaces\rand\nwith spaces, and apply it before formatting thelogical_datevalue into thelogger.exceptionmessage. The helper is extracted so the guard is testable in isolation.logger.exceptionstays on the stdlib logger (rather than swapping tostructlog) to keep the change minimal and avoid coupling unrelated behaviour changes into a security fix.Test plan
TestSanitizeForStdlibLog::test_strips_cr_and_lfcovers\n,\r,\r\n, multi-line, empty, and the no-op case.prek run ruffclean.prek run mypy-airflow-coreclean.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.7) following the guidelines