fix(security): expand Password PII patterns to catch pass: and natural language forms #60

Merged
sarman merged 1 commits from fix/pii-detection-bypass into master 2026-06-01 01:54:14 +00:00
Owner

Problem

Live audit logs confirmed was_pii_redacted: false with plaintext credentials reaching the AI provider.

Two credential patterns were not matched by PiiDetector:

1. Abbreviated key form (pass: abc123!!)

The pattern only matched password|passwd|pwd. The common credential file key pass: was not in the alternation.

2. Natural language form (Is the password password123 good)

No pattern existed for the case where password precedes a value without a =/: separator. Plaintext credentials disclosed in natural-language messages were not redacted.

Fix

Key-value pattern

  • Added pass, passphrase, secret to the alternation
  • Added \b word boundary to prevent substring false positives (bypass:, compass:)

Natural language pattern

  • New sub-pattern: password <value> / password is <value>
  • Value must contain at least one digit or special char — prevents false positives on plain words (password strength, password policy)

Tests

5 new regression tests added:

  • test_detect_pass_abbreviation — confirms pass: abc123!! is caught
  • test_detect_password_natural_language — confirms password password123 and password is hunter2 are caught; password strength and password policy are NOT flagged
  • test_password_no_false_positive_bypass — confirms bypass: is not flagged
  • test_detect_password_keyword — confirms original password:, passwd=, pwd: still work
  • test_detect_secret_keyword — confirms secret: and passphrase: work

Verification

  • cargo test: 233/233 pass
  • cargo clippy -- -D warnings: clean
  • cargo fmt --check: clean
## Problem Live audit logs confirmed `was_pii_redacted: false` with plaintext credentials reaching the AI provider. Two credential patterns were not matched by `PiiDetector`: **1. Abbreviated key form (`pass: abc123!!`)** The pattern only matched `password|passwd|pwd`. The common credential file key `pass:` was not in the alternation. **2. Natural language form (`Is the password password123 good`)** No pattern existed for the case where `password` precedes a value without a `=`/`:` separator. Plaintext credentials disclosed in natural-language messages were not redacted. ## Fix ### Key-value pattern - Added `pass`, `passphrase`, `secret` to the alternation - Added `\b` word boundary to prevent substring false positives (`bypass:`, `compass:`) ### Natural language pattern - New sub-pattern: `password <value>` / `password is <value>` - Value must contain at least one digit or special char — prevents false positives on plain words (`password strength`, `password policy`) ## Tests 5 new regression tests added: - `test_detect_pass_abbreviation` — confirms `pass: abc123!!` is caught - `test_detect_password_natural_language` — confirms `password password123` and `password is hunter2` are caught; `password strength` and `password policy` are NOT flagged - `test_password_no_false_positive_bypass` — confirms `bypass:` is not flagged - `test_detect_password_keyword` — confirms original `password:`, `passwd=`, `pwd:` still work - `test_detect_secret_keyword` — confirms `secret:` and `passphrase:` work ## Verification - `cargo test`: 233/233 pass - `cargo clippy -- -D warnings`: clean - `cargo fmt --check`: clean
sarman added 1 commit 2026-06-01 01:48:21 +00:00
fix(security): expand Password PII patterns; add regression tests
All checks were successful
Test / rust-fmt-check (pull_request) Successful in 1m20s
Test / frontend-typecheck (pull_request) Successful in 1m37s
Test / frontend-tests (pull_request) Successful in 1m35s
Test / rust-clippy (pull_request) Successful in 3m11s
PR Review Automation / review (pull_request) Successful in 4m22s
Test / rust-tests (pull_request) Successful in 4m28s
fbd6aab7fe
Two credential patterns were missing from the PiiDetector, confirmed
by live audit log showing was_pii_redacted: false with plaintext creds:

1. Abbreviated key form (pass: abc123!!): the pattern only matched
   password|passwd|pwd. Added pass, passphrase, secret with a word
   boundary to prevent substring false positives (bypass:, compass:).

2. Natural language form (Is the password password123 good): added a
   second Password sub-pattern for keyword-adjacent values without a
   key separator. Value must contain a digit or special char to avoid
   flagging plain words (password strength, password policy).

5 new regression tests added. 233/233 Rust tests pass.
sarman reviewed 2026-06-01 01:52:39 +00:00
sarman left a comment
Author
Owner

Automated PR Review (qwen3-coder-next via liteLLM):\n\nSummary
The PR expands password PII detection to catch abbreviated forms like pass: and natural language patterns like password value. However, the natural language regex has a critical flaw: it permits matching plain English phrases like “password strength” when they are followed by a digit/special character in an adjacent word, creating false positives and potential over-redaction of non-sensitive text.

Findings

  • [BLOCKER] src-tauri/src/pii/patterns.rs:52–54 - Overly permissive natural language password regex allows false positives where unrelated phrase + digit triggers PII detection
    Evidence: r"(?i)\b(?:password|passwd|passphrase)\s+(?:is\s+|was\s+)?[A-Za-z0-9!@#$%^&*_\-+=@#,.]*[0-9!@#$%^&*_\-+=@#][A-Za-z0-9!@#$%^&*_\-+=@#,.]*" — matches "password strength 123" because [A-Za-z0-9!@#$%^&*_\-+=@#,.]* greedily consumes "strength" (no digit), then 123 satisfies [0-9!], and the pattern does not enforce that the immediately following word must be a password value
    Fix: Restrict to match only sequences where the value follows a delimiter (is, was, or colon-like) or enforce word boundary and non- alphabetic start on the value portion; e.g., change to r"(?i)\b(?:password|passwd|passphrase)\s+(?:is\s+|was\s+)?(?[!@#$%^&*_\-+=@#0-9])[A-Za-z0-9!@#$%^&*_\-+=@#,.]*"

Verdict: REQUEST CHANGES

Automated PR Review (qwen3-coder-next via liteLLM):\n\n**Summary** The PR expands password PII detection to catch abbreviated forms like `pass:` and natural language patterns like `password value`. However, the natural language regex has a critical flaw: it permits matching plain English phrases like “password strength” when they are followed by a digit/special character in an adjacent word, creating false positives and potential over-redaction of non-sensitive text. **Findings** - [BLOCKER] src-tauri/src/pii/patterns.rs:52–54 - Overly permissive natural language password regex allows false positives where unrelated phrase + digit triggers PII detection Evidence: `r"(?i)\b(?:password|passwd|passphrase)\s+(?:is\s+|was\s+)?[A-Za-z0-9!@#$%^&*_\-+=@#,.]*[0-9!@#$%^&*_\-+=@#][A-Za-z0-9!@#$%^&*_\-+=@#,.]*"` — matches `"password strength 123"` because `[A-Za-z0-9!@#$%^&*_\-+=@#,.]*` greedily consumes `"strength"` (no digit), then `123` satisfies `[0-9!]`, and the pattern does not enforce that the *immediately following* word must be a password value Fix: Restrict to match only sequences where the value follows a delimiter (`is`, `was`, or colon-like) or enforce word boundary and non- alphabetic start on the value portion; e.g., change to `r"(?i)\b(?:password|passwd|passphrase)\s+(?:is\s+|was\s+)?(?[!@#$%^&*_\-+=@#0-9])[A-Za-z0-9!@#$%^&*_\-+=@#,.]*"` **Verdict**: REQUEST CHANGES
sarman merged commit ba94f446c1 into master 2026-06-01 01:54:14 +00:00
sarman deleted branch fix/pii-detection-bypass 2026-06-01 01:54:14 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sarman/tftsr-devops_investigation#60
No description provided.