Repository navigation
fix(security): redact refused input before writing security logs - #189
Open
rahul05ranjan wants to merge 1 commit into
Open
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
validateInput passed the raw refused input to logSecurity, so the blocked-pattern rules that exist to keep credentials out of a request persisted those credentials verbatim into the rotating plaintext logs under logs/ (14-day retention). Add redactForLog: a bounded, truncated view that masks password/api-key/token/secret assignments, Bearer headers and URL credentials, used by every security-event log call on the validation path. The command, pattern and error stay in the audit entry; the secret no longer does. Verified the redaction logic in isolation (8 cases incl. password assignment, JSON input, bearer token, URL credential, benign code text, truncation) with the system Node; the repo's own jest suite was not run since dependencies are not installed here. Fixes #188 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #188
Root cause
validateInputrefused input that matched a blocked pattern (one of which exists specifically to catch password exposure), but the same refusal path handed the raw input tologSecurity.logger.securityruns atwarn, which passes the daily-rotate file transport'sdebuglevel, so the full refused input — secret included — was written verbatim intologs/dhruv-YYYY-MM-DD.log(plaintext, 14-day retention). The security control was copying the exact value it refused to protect onto disk.Fix
SecurityManager.redactForLogturns the refused input into a bounded audit view:password = ...,api_key = ...,token: ...,secret,credentialassignmentsBearertokens and credentials embedded in URLsEvery security-event log call on the validation path (
blocked_command,invalid_input,blocked_pattern,validation_error, and the sanitize-step warning) now logs the redacted view. The command name, matched pattern and validation error are untouched, so refusals stay debuggable; only the credential-shaped content is masked.Verification
token:value, Bearer header,postgres://user:pass@hostURL credential, benign code question unchanged, 250-char truncation, non-serializable input) — all pass.Note: the same redaction is applied to the
Input was sanitizedwarning, which also carried raw input; that whole step is dead code (its result is never used) — separate issue for that coming next, and it is deliberately left untouched here so the two fixes stay reviewable on their own.