Skip to content

fix(http): fall back to metadata logging in strictmode - #4440

Open
stevenvegt wants to merge 2 commits into
masterfrom
fix/strictmode-body-logging
Open

fix(http): fall back to metadata logging in strictmode#4440
stevenvegt wants to merge 2 commits into
masterfrom
fix/strictmode-body-logging

Conversation

@stevenvegt

Copy link
Copy Markdown
Member

In strictmode, http.log: metadata-and-body is now reset to metadata at startup, with a warning. Bodies on the OAuth endpoints contain credentials (client_assertion, VP tokens, authorization codes, issued access tokens) and the body logger's loggable content types (application/json, application/x-www-form-urlencoded) are exactly the token endpoint's request and response types, so full body logging must not be possible on a strictmode node.

Startup is deliberately not failed. This follows the existing warn-and-override precedent for valid-but-unsafe configuration values: auth.accesstokenlifespan is overridden with a warning in strictmode (auth/services/oauth/authz_server.go), and cpuprofile is ignored with a warning (cmd/root.go). A misspelled key leaves the operator's intent unknowable, but a valid-but-unsafe value has a known safe alternative to fall back to.

Documentation: the strictmode summary in configuration.rst now lists this override, and the http.log flag description mentions it (with server_options.rst regenerated, which re-padded the whole generated table).

Testing: TestEngine_LoggingMiddleware gains a subtest bodyLogger is disabled in strict mode that POSTs a JSON body containing very-secret-request to a strictmode-configured engine returning very-secret-response, and asserts that a metadata entry is logged (msg="HTTP request", status=200), that neither secret string reaches the log, that the effective config is reset to metadata, and that the startup warning is emitted. Before the fix this test showed both bodies logged in full at Info. The pre-existing bodyLogger subtest now sets Strictmode = false explicitly, since NewServerConfig() defaults to strictmode and it tests the non-strict behavior.

http.log=metadata-and-body logs full request and response bodies at
Info severity. The loggable content types include application/json and
application/x-www-form-urlencoded, which are exactly the OAuth token
endpoint's request and response types, so client assertions, VP
tokens, authorization codes and issued access tokens all reach the
log in full.

In strictmode the value is now reset to metadata with a warning at
startup, following the existing warn-and-override precedent for
unsafe-but-valid configuration values (auth.accesstokenlifespan,
cpuprofile). Startup is not failed: remediation for the operator is
removing a single config value, and a security patch must be safe to
apply without reading release notes.

Assisted-by: AI
@qltysh

qltysh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: B Coverage rating: B
http/engine.go100.0%
Coverage rating: A Coverage rating: A
http/cmd/cmd.go100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

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