fix(security): sanitize sensitive query params in error logs and response urls - #355
Merged
David-patrick-chuks-02 merged 2 commits intoSep 6, 2026
Conversation
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.
Summary
This PR addresses issues #282 and #283 by unifying URL sanitization across application access logs, error middleware logs, and 404 / 405 error responses:
errorHandlernow passesrequest.originalUrl(orrequest.url) throughsanitizeRequestUrl(...)before writing structured log entries, ensuring tokens/keys/seeds in query strings are redacted in error logs.notFoundHandlerandattachMethodNotAllowedHandlersnow strip query parameters from error response messages (Route not found: GET <path>andMethod <method> not allowed for <path>) so sensitive query parameters are never echoed back in client-facing error payloads.request-logger.tsandapp.tsto use standardized uppercase[REDACTED]token and unified thesanitizeRequestUrlhelper across both access logging inapp.tsand error handling inerror.middleware.ts.seedto sensitive query parameter keys list alongsidewallet_seed,token,secret,api_key,key,access_token,authorization, etc.Tests Added & Verified
tests/sanitize-urls-and-logs.test.ts: verified errorHandler query parameter redaction, 404 message URL sanitization, and access log sanitization.npm testpasses 57/57 test files, 263 tests).npm run lint).Closes #282
Closes #283