Skip to content

fix(redaction): harden URL, literal and line-break redaction - #17

Merged
brianvarskonst merged 5 commits into
mainfrom
fix/low-redaction-hardening
Nov 16, 2026
Merged

brianvarskonst merged 5 commits into
mainfrom
fix/low-redaction-hardening

Conversation

@brianvarskonst

Copy link
Copy Markdown
Member

Problem

Three Low findings from the 2026-11-15 security audit:

  1. Secrets in URL paths – failed WP HTTP API requests were logged with their full URL (WordPressHttpApiLogger::context()). ContextSanitizer::sanitizeText() strips query and userinfo but keeps the path, where Slack/Discord webhooks and Telegram bot<id>:<token> carry the credential.
  2. Record-wide scrubbing without minimum length – values under sensitive context keys (password, nonce, token …) were str_replaced across the whole record. Code that logs request input under such a key let an attacker erase their IP/user name from the entry or garble it (password => 'e').
  3. Log line forgery with include_stacktraces – Monolog then keeps inline line breaks, and CR/LF in messages or context strings survived sanitization.

Fix

  • WordPressHttpApiLogger logs only scheme://host[:port] and replaces any path/query with /[path redacted] (unparsable URLs become [url redacted]).
  • ContextSanitizer::withSensitiveContext() collects values for record-wide scrubbing only from 8 characters on. Shorter values stay redacted at their own key. The full literal is still matched exactly.
  • ContextSanitizer::sanitizeText() escapes CR/LF as literal \r/\n as its last step, which covers messages, context/extra strings and sanitized exception messages. Stack trace frames are unaffected.
  • docs/handlers.md describes the new rules.

Behaviour change: a short (< 8 chars) value under a sensitive key that also appears unlabelled elsewhere in the record is no longer masked there. The old test testActualShortPasswordsRemainRedacted asserted exactly the behaviour flagged by the audit and was replaced.

Tests

  • New WordPressHttpApiLoggerTest (Slack, Discord, Telegram, origin-only, unparsable): 5/5 failed before, pass after.
  • testShortSensitiveValuesAreRedactedOnlyAtTheirKey: failed before ('user' => '[r[redacted]dact[redacted]d]'), passes after.
  • testLineBreaksCannotForgeEntriesWhenStackTracesAreEnabled (LineFormatter with includeStacktraces()): failed before (3 line breaks instead of 1), passes after.
  • composer validate --strict, composer cs, composer static-analysis (PHPStan level 8) and composer tests (50 tests, 367 assertions) are green locally.

Release

Patch release 1.1.8 (chore(release): prepare 1.1.8): CHANGELOG entry and plugin header. The header had stayed at 1.1.5 and is corrected. The entry also mentions the unreleased CI pin to sympress/workflows v1.3.2.

Values found under sensitive context keys were replaced in the whole
record regardless of length. Code that logs request input under such a
key let an attacker erase arbitrary text from the entry (their IP, user
name) or garble it completely with a one-character "password".

Only values of at least 8 characters are now scrubbed across the record.
Shorter values are still redacted at their own key.
Failed WP HTTP API requests were logged with their full URL. Redaction
dropped query and userinfo but kept the path, where Slack and Discord
webhooks and Telegram bot tokens carry their credential. Anyone reading
the log could post to the channel or control the bot.

The http channel now logs scheme, host and port and replaces any path
or query with a placeholder.
With include_stacktraces, Monolog keeps inline line breaks, so CR/LF
in messages or context strings (database errors, HTTP error messages,
third-party input) produced lines that look like separate log entries.

The sanitizer now escapes CR and LF as literal \r and \n in all text it
returns. Stack traces are appended by the formatter afterwards and stay
multi-line.
Document the minimum length for record-wide scrubbing, escaped line
breaks and origin-only URLs for failed HTTP requests, so docs/handlers.md
stays exact.
Bump the plugin header, which had stayed at 1.1.5 since that release,
and add the changelog entry.
@brianvarskonst
brianvarskonst merged commit 8a1bf84 into main Nov 16, 2026
3 checks passed
@brianvarskonst
brianvarskonst deleted the fix/low-redaction-hardening branch November 16, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant