Security: redact PII from user-facing LLM error messages#141
Merged
dgarson merged 1 commit intodgarson/forkfrom Mar 3, 2026
Merged
Security: redact PII from user-facing LLM error messages#141dgarson merged 1 commit intodgarson/forkfrom
dgarson merged 1 commit intodgarson/forkfrom
Conversation
dgarson
commented
Feb 24, 2026
Owner
Author
dgarson
left a comment
There was a problem hiding this comment.
✅ Overall assessment: solid security improvement, ready to merge
Summary
This PR adds privacy-focused sanitization to user-facing LLM/API error text by redacting common PII (email, phone, SSN, likely card numbers) and suppressing long input/prompt echo payloads. It preserves useful troubleshooting context (HTTP code/type/request_id framing).
What I checked
- Redaction logic placement and call paths (
formatRawAssistantErrorForUi) - Card detection approach (Luhn check to reduce false positives)
- Existing UX/error-shape behavior preserved for non-sensitive errors
- New regression tests for PII redaction and prompt-echo suppression
Concerns / issues
- No blocking issues found.
Suggestions
- Optional follow-up: add a test case confirming
request_idformatting remains unchanged while message content is redacted. - Optional follow-up: add a test for card-like numeric strings that fail Luhn to document expected non-redaction behavior.
Blocking issues
- None.
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\n- redact common PII patterns (email, phone, SSN, payment card numbers) from user-facing provider error text\n- suppress long prompt/input echo payloads with a privacy-safe generic message\n- keep existing HTTP/type/request-id framing so debugging context remains useful\n\n## Testing\n- pnpm -C /Users/openclaw/.openclaw/workspace/clawdbot exec vitest src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts\n\n## Work Item\n- dgarson/clawdbot#20279\n