fix(redact): strip controls before masking secrets - #58079
Closed
tianma-if wants to merge 1 commit into
Closed
Conversation
Collaborator
Duplicate of #55321 — both strip C0/C1/DEL control characters from |
Contributor
Author
|
Closing as duplicate of #55321 per triage; the earlier PR covers the same mask_secret control-character fix. Thanks. |
thatssoheil
added a commit
to thatssoheil/hermes-agent
that referenced
this pull request
Aug 3, 2026
…ch#55319, NousResearch#55321) A masked secret's visible head/tail could carry control bytes (newline, NUL, DEL, C1 0x80-0x9F, zero-width) into config/status/dump output. Strip every control incl. \n/\t (display differs from redact_sensitive_text, which preserves \n/\t as line structure) before slicing; all-control values return the configured empty fallback. Consolidates the previously-closed NousResearch#58079 approach (strip controls before masking) - supersedes it.
kshitijk4poor
pushed a commit
to kshitijk4poor/hermes-agent
that referenced
this pull request
Aug 7, 2026
…ch#55319, NousResearch#55321) A masked secret's visible head/tail could carry control bytes (newline, NUL, DEL, C1 0x80-0x9F, zero-width) into config/status/dump output. Strip every control incl. \n/\t (display differs from redact_sensitive_text, which preserves \n/\t as line structure) before slicing; all-control values return the configured empty fallback. Consolidates the previously-closed NousResearch#58079 approach (strip controls before masking) - supersedes it.
kshitijk4poor
pushed a commit
that referenced
this pull request
Aug 7, 2026
…5321) A masked secret's visible head/tail could carry control bytes (newline, NUL, DEL, C1 0x80-0x9F, zero-width) into config/status/dump output. Strip every control incl. \n/\t (display differs from redact_sensitive_text, which preserves \n/\t as line structure) before slicing; all-control values return the configured empty fallback. Consolidates the previously-closed #58079 approach (strip controls before masking) - supersedes it.
ma1138569845
pushed a commit
to ma1138569845/dechnicAuditor-agent
that referenced
this pull request
Aug 10, 2026
…ch#55319, NousResearch#55321) A masked secret's visible head/tail could carry control bytes (newline, NUL, DEL, C1 0x80-0x9F, zero-width) into config/status/dump output. Strip every control incl. \n/\t (display differs from redact_sensitive_text, which preserves \n/\t as line structure) before slicing; all-control values return the configured empty fallback. Consolidates the previously-closed NousResearch#58079 approach (strip controls before masking) - supersedes it.
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…ch#55319, NousResearch#55321) A masked secret's visible head/tail could carry control bytes (newline, NUL, DEL, C1 0x80-0x9F, zero-width) into config/status/dump output. Strip every control incl. \n/\t (display differs from redact_sensitive_text, which preserves \n/\t as line structure) before slicing; all-control values return the configured empty fallback. Consolidates the previously-closed NousResearch#58079 approach (strip controls before masking) - supersedes it.
sanshi2018
pushed a commit
to sanshi2018/hermes-agent
that referenced
this pull request
Aug 18, 2026
…ch#55319, NousResearch#55321) A masked secret's visible head/tail could carry control bytes (newline, NUL, DEL, C1 0x80-0x9F, zero-width) into config/status/dump output. Strip every control incl. \n/\t (display differs from redact_sensitive_text, which preserves \n/\t as line structure) before slicing; all-control values return the configured empty fallback. Consolidates the previously-closed NousResearch#58079 approach (strip controls before masking) - supersedes it. (cherry picked from commit e9d1551)
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.
What does this PR do?
Fixes display-time secret masking so
agent.redact.mask_secret()strips C0/C1/DEL control characters before applying the existing visible head/tail mask.Before this change, malformed pasted credentials could produce masked output containing newlines or invisible control bytes when those bytes landed in the preserved prefix/suffix. Printable secrets keep the same mask shape.
Fixes #55319
Type of Change
Changes
_is_display_control_char()helper covering C0, DEL, and C1 controls.mask_secret()input before the existing floor/head/tail masking logic.Duplicate check
Checked open PRs for #55319,
masked secret display,mask_secretcontrol characters, redaction control characters, C1, and DEL masking. The only nearby open PR is #58074, which targets save-time credential normalization insave_env_value(); this PR targets display-time masking inagent.redact.mask_secret().How to Test
.venv/bin/python -m pytest tests/agent/test_redact.py -q -k TestMaskSecretDisplay.venv/bin/python -m pytest tests/agent/test_redact.py -q.venv/bin/python -m ruff check agent/redact.py tests/agent/test_redact.pygit diff --checkPlatform: macOS, Python 3.13, local
.venv.