Skip to content

fix(extension): camelCase-aware secret field names in every redaction layer (fix-forward for #2575) - #2621

Merged
abrichr merged 3 commits into
mainfrom
claude/fix-ext-camelcase-redaction
Nov 24, 2026
Merged

abrichr merged 3 commits into
mainfrom
claude/fix-ext-camelcase-redaction

Conversation

@abrichr

@abrichr abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member

Fix-forward for #2575. Grok's REQUEST CHANGES on that PR (#2575 (comment)) was still open when it merged. The camelCase secret-field redaction misses names such as patientSsn, cardCvv, userPin and otpCode, so typed values for those fields reach the native host in clear.

What changed

  • One shared vocabulary. The list is in packages/flow/openadapt_flow/secret_field_vocabulary.json and ships in the wheel. It covers password, passcode, pin, ssn, social security, sin, tax id, cvv, cvc, csc, card number, cc number, iban, account number, routing, otp, one time code, verification code, mfa, totp, 2fa, sms code, api key, access token, refresh token, secret and auth, plus passwd, pwd, passphrase, cvv2 and cvc2. code on its own is not in the list. The existing ^code$ exact rule stays.
  • One normalizer, applied in all four redaction layers. The normalizer splits ([a-z0-9])([A-Z]) and ([A-Z]+)([A-Z][a-z]), lowercases, then splits on any run of non-alphanumerics, which covers _, -, . and spaces. A phrase matches only as whole consecutive tokens, so pinnedItems, spinnerState, opinionText and productCode stay clear. The four layers:
    • chrome_extension/content.js isSecretField: name, id, aria-label and autocomplete.
    • chrome_extension/network_redact.js isSecretKey: JSON, form and query keys.
    • openadapt_flow/extension_evidence.py is_secret_field: name and id. content.js sends aria-label as name.
    • openadapt_flow/extension_network.py is_secret_key. This is the engine's re-redaction on ingest, and it was the weakest of the four: it missed card_cvv, smsCode and oneTimeCode too.
  • Python is new code; JS embeds a copy. Python uses the new openadapt_flow/secret_field_names.py. The two JS files embed an identical copy of the list between secret-field-vocabulary:begin/end markers, so the content script needs no new file or load order. A test fails when either copy differs from the JSON.
  • Additive. The existing regexes are unchanged. A field is secret if the old pattern or the new token rule matches, so nothing that was redacted before is now kept.
  • Auth-pause detection is unchanged. MFA_ATTR_RE and sign-in detection were not widened.
  • Docs. docs/CHROME_EXTENSION_EVIDENCE.md and docs/CHROME_EXTENSION_NETWORK.md now describe the token rule. The STORE_LISTING.md claim ("Secret-looking fields ... are redacted locally") is still accurate, so it is unchanged.

Tests

packages/flow/tests/test_extension_secret_field_names.py runs one name table through every layer as behavior tests. content.js runs through the existing Node fake-DOM harness (isSecret with name, id, aria-label, a secret id behind a benign name, and autocomplete). redactNetworkSave runs in a Node vm with a real JSON body. Python covers redact_evidence and redact_network_save.

  • Secret names: patientSsn, memberSsn, applicantSSN, PatientSSN, SSNLast4, ssnLast4, cardCvv, cvvCode, cardCvc, card_cvv, card-cvv, card.cvv, userPin, pinCode, otpCode and others, the aria-label "Card CVV", and a JSON body {"userPin": ...}.
  • Must stay clear: pinnedItems, spinnerState, opinionText, productCode, claimId.

Failing first. The tests were committed alone in dade6c9b1, on unmodified source: 13 failed, 7 passed. For example:

  • content.js missed patientSsn, PatientSSN, cardCvv, card.cvv, userPin, pinCode, taxId, routingNumber and more.
  • network_redact.js kept otpCode, userPin, cardCvv, patientSsn.
  • extension_evidence missed the same names plus otpCode.
  • extension_network kept card_cvv, card-cvv, smsCode and oneTimeCode as well.

After the fix (334db0a96):

  • New file: 20 passed.
  • test_chrome_extension_cws.py, test_extension_shadow_evidence.py, test_extension_network.py, test_extension_evidence.py, test_extension_native_host.py, test_extension_copilot_sidepanel.py and the new file together: 192 passed.
  • ruff check and ruff format --check are clean, and mypy --strict passes on the new module.
  • scripts/check_engine_generality.py passes.

Not run: the headed *_browser.py extension tests, which skip locally. CI covers them.

Store zip

No zip is committed. The Chrome Web Store zip must be rebuilt from this head with python3 scripts/package_chrome_extension.py --out dist/openadapt-copilot-cws.zip before any store submission. The Chrome Web Store was not touched.

… every redaction layer

Field names, ids, aria-labels, autocomplete values and JSON keys are split at
camelCase/PascalCase boundaries and non-alphanumerics, lowercased, and matched
as whole tokens against one shared list (openadapt_flow/secret_field_vocabulary.json).
content.js and network_redact.js embed an identical copy; a test fails when a
copy differs. The existing regexes stay, so the change only adds coverage.

Fixes the gap Grok reported on #2575: patientSsn, cardCvv, userPin and otpCode
reached the native host in clear.
@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 334db0a

Author declaration. I wrote this PR. The tests failed first on unmodified source (13 failed) and pass at this head (192 passed across the extension suites). Details are in the PR body.

@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 334db0a

Verified

  • Class fix across all 4 redaction layers: chrome_extension/content.js, chrome_extension/network_redact.js, openadapt_flow/extension_evidence.py, and openadapt_flow/extension_network.py now share identical camelCase/PascalCase + separator token splitting (fieldTokens / field_tokens) and whole-token consecutive phrase matching (namesSecretField / names_secret_field) over openadapt_flow/secret_field_vocabulary.json.
  • Precision & safety: Catches camelCase/PascalCase/punctuated secrets (patientSsn, PatientSSN, userPin, cardCvv, otpCode, "Card CVV") while keeping lookalikes (pinnedItems, productCode, spinnerState) unredacted ("code" is deliberately excluded so ^code$ remains exact-only). All existing SECRET_NAME / SECRET_KEY / MFA_ATTR_RE / SECRET_AUTOCOMPLETE rules remain additive (no weakening).
  • Drift prevention & tests: packages/flow/tests/test_extension_secret_field_names.py asserts both JS embedded phrase blocks match secret_field_vocabulary.json exactly and exercises all 4 layers (including Node execution of content.js and network_redact.js).
  • Generality & Durability: Zero per-app logic; fixes the entire camelCase/PascalCase redaction bypass class for #2575.

@abrichr
abrichr enabled auto-merge (squash) November 24, 2026 10:12
@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 334db0a

Scope: the fix-forward for my P1 on #2575 (#issuecomment-7126795048). I read all four redaction layers, the shared vocabulary and the new tests line by line, then ran a name matrix and end-to-end redaction probes against this head and against base fb5e0d3c.

Tests

  • At this head (Linux, py3.12, headless Chromium, run from packages/flow): python -m pytest -q tests/test_extension_secret_field_names.py tests/test_extension_evidence.py tests/test_extension_network.py tests/test_extension_content_browser.py tests/test_extension_network_browser.py tests/test_chrome_extension_cws.py tests/test_extension_shadow_evidence.py tests/test_extension_frame_browser.py gave 176 passed, 0 failed, 0 skipped.
  • Failing first: the new test_extension_secret_field_names.py copied onto base fb5e0d3c gave 13 failed, 7 passed. That matches the author's count.
  • ruff check on the changed Python files passes. scripts/check_engine_generality.py passes.

Probes (65 names, 4 layers: extension_evidence.is_secret_field, extension_network.is_secret_key, content.js DOM check, network_redact.js isSecretKey)

  • Fixed. All four layers flag these at this head; none flagged them on base: patientSsn, PatientSSN, PatientSSNLast4, ssnLast4, cardCvv, cardCVC, cardCvc2, userPin, pinCode, card.cvv, card[cvv], user[ssn], data.patient.ssn, SSN#, taxId/taxID, sinNumber, bankAccountNumber, routingNumber, ibanCode, cvvHelpText. otpCode and authCode were partial on base and are now flagged in all four. x-api-key, apiKEY, APIKey, PIN_CODE and ssn-number still pass.
  • No new false positives: spinner, spinnerState, opinion, opinionText, pinned, pinnedItems, pinterest, pinyin, classname, lessons, business and since stay clear in all four layers. author and authorName are flagged only by the network key regex, as on base.
  • Python and JavaScript agree on all 65 names. The drift test covers the phrase list, and this matrix shows the two fieldTokens implementations agree too.
  • End to end, both redactors: nested JSON {"patient":{"patientSsn":…,"items":[{"userPin":…},{"pinnedItems":"x"}]}} withholds patientSsn and userPin and keeps pinnedItems. A URL query ?cardCvv=9311&patientId=7 becomes cardCvv=<secret>&patientId=7. A form body otpCode is withheld (JS). When a withheld query value reappears under an unflagged body key, network_redact.js drops the whole record (fail-closed). A header such as X-Patient-SSN is already withheld by the header rule.

Findings

  • P2: all-lowercase run-together names and letter+digit tokens are still missed in all four layers. Examples: patientssn, cardcvv, userpin, newpin, cvvcode, ssn4, pin1, pin4digits. This is the documented whole-token trade-off (secret_field_names.py:35, content.js:57, network_redact.js:154), and base missed them too, so it does not block. Two cheap follow-ups:

    • split letter→digit boundaries (ssn4 → ssn 4, pin1 → pin 1; 2fa still survives because the split runs letter→digit only);
    • substring-match the low-collision tokens (cvv, cvc).

    ssn and pin should stay whole-token, because classname contains ssn and spinner contains pin. Multi-box OTP inputs named otp1… are caught on the DOM side by MFA_ATTR_RE, but not as network keys.

  • P2: the drift test compares only the phrase lists, not the tokenizer. A tokenizer parity case (for example the probe names above, run through both languages) would stop the two implementations from diverging silently.

Generality gate

Pass. The vocabulary is generic field-name semantics. There are no site, app or customer identifiers, and test URLs are .example.

Limits

I did not load the extension in a real Chrome profile against a live site. The DOM side was checked through the in-repo harness and browser tests, plus a node extraction of content.js's matcher. I did not run the full flow suite.

CI at this head

Not finished. 9 pass, 17 pending and 19 skipped by the scope filter, with no failures so far. The packages / flow core unit and default-at-rest shards and core lint were still pending when I posted. This APPROVE assumes they finish green.

I did not push to this branch.

@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 42306f5

Verified delta (334db0a9..42306f5e)

  • Strictly +1 line in packages/flow/public-artifacts.json registering "openadapt_flow/secret_field_vocabulary.json" in alphabetical order for check_release_consistency.py.
  • All previously Gemini-approved redaction layers and tests at 334db0a9 remain intact.

@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 42306f5

Delta review of 334db0a9..42306f5e on top of my APPROVE at 334db0a (#issuecomment-7129480360).

  • The compare shows one commit and one file: packages/flow/public-artifacts.json, +1 line, no deletions. No redaction layer, vocabulary or test file changed, so my earlier findings and test results at 334db0a carry over unchanged.
  • The added entry openadapt_flow/secret_field_vocabulary.json matches a file that exists in the tree at this head (packages/flow/openadapt_flow/secret_field_vocabulary.json). It uses the same package-relative form as its neighbour openadapt_flow/registry_trusted_root.json.
  • The entry appears once (line 1515), sits in sorted order between registry_trusted_root.json and taskgen/profiles/mockmed.yaml, and the file still parses as JSON (schema_version 2, 1497 artifacts).

Not run: I didn't run check_release_consistency.py or the test suite locally for this delta. I checked it from the GitHub tree at the exact head.

CI at this head: validate-platform-manifest passes. gitleaks, dependency-review, protected-path evidence and internal links were still pending when I checked. This approval assumes they finish green. The minor gaps from my earlier review still stand and don't block: patientssn and ssn4.

@abrichr
abrichr merged commit 308587f into main Nov 24, 2026
50 checks passed
@abrichr
abrichr deleted the claude/fix-ext-camelcase-redaction branch November 24, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant