Skip to content

fix(flow): keep pixel checks off withheld credential fields - #2367

Open
abrichr wants to merge 12 commits into
mainfrom
claude/no-pixel-check-over-withheld-field
Open

abrichr wants to merge 12 commits into
mainfrom
claude/no-pixel-check-over-withheld-field

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

A wrapped sign-in program published to staging halted on the first hosted call. The step that halted was the click into the password field, the one right after the username is typed. The local canary had passed.

Cause

The recorder fills a withheld credential field with black in every frame that still shows it (Recorder._redact). The REGION_STABLE check that was mined for the password click covered both fields. Its template therefore held the username field's black box:

  • Before: the black box sits over the username field in step_002_expect.png.
  • At replay: the live screen shows the typed username, so the phash refutes. The match against a black box is marginal on macOS and fails on the Linux runner.
  • Second producer: the focused-field fix-up pass (focused_field_region_stable) crops the clicked box from the same redacted frame. It can produce the same kind of check.

This is the same class as the existing rule that drops a region rendering a parameter value. A pixel invariant must not freeze content that a live screen can never show.

Change

A new helper, _checks_without_withheld_fields, runs after mining and again after the fix-up passes. It applies to every REGION_STABLE check whose region intersects a withheld field's redacted_region, but only where that box is actually black in the step's recorded after-frame:

  • Clip. The region is clipped to its largest part clear of the box (above, below, left or right). The check is then re-cropped and re-hashed from the same frame.
  • Drop. If no part of at least 8×8 px is left, the check is dropped and recorded in param_hygiene.json, the same as the existing parameter-region drops.
  • Unchanged. Frames from before the field was typed are not black there, so their checks stay as they are.

The e2e sign-in test now also asserts that no REGION_STABLE template is mostly black.

Evidence

The synthetic sign-in notes target on staging, published with Flow 3.4.0 plus this patch:

  • Before. The password click's check covered (91, 114, 217, 85) and included the black box. A hosted run halted at step 2 with postcondition refuted.
  • After. The check is clipped to (91, 132, 217, 67) and the canary admits. Two hosted runs then got past every field and the sign-in: seven signed deliveries each, and the target counted one sign-in per run. Each run then stopped at Save, which waits for a per-item approval. That wait is a separate, known gap, not this defect. The evidence is in openadapt-cloud fix(install): add vs redistributable installation in powershell script #490 (docs/evidence/staging/vault-sign-in-2026-11-20/RESULTS.md).

Tests

  • tests/test_compile_withheld_fields.py (new unit tests): blackout detection, including the recorder's whole-frame box; clip; drop recorded in param_hygiene.json; a frame from before typing keeps its check; a check clear of the box is untouched.
  • 161 passed across tests/test_compile_withheld_fields.py, tests/test_fixup_passes.py, tests/test_compiler.py, tests/test_compile_postcondition_ownership.py, tests/test_compile_identifier_crop.py, tests/test_import_surface.py, tests/test_wrap_sign_in.py and tests/e2e/test_wrap_sign_in_e2e.py.
  • 5 failures in tests/test_compiler.py (landmark/OCR cases). The same 5 fail on unmodified main in this local environment (94 passed, 5 failed in both runs), so they come from the environment, not this change.
  • Ruff is clean.
  • CAPABILITIES.md has the updated sign-in row, and llms-full.txt is regenerated.

The recorder fills a withheld credential field with black in every frame
that still shows it. A REGION_STABLE crop overlapping one froze that black
box, which no live screen shows, so the step refuted on every hosted run
(seen on staging: the click into the password field after the username was
typed). Clip such a check to the part of its region clear of the box and
re-crop it from the same frame; drop it into param_hygiene.json when nothing
usable is left. Applies to mined checks and to the focused-field pass.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: b181466

I will not merge.

Author is abrichr, not Grok. No prior Grok verdict at this head.

The compile change itself is the right fail-closed idea: withheld-field boxes from redacted_region accumulate across later frames; a REGION_STABLE check that intersects a box that looks like the recorder's black fill is clipped to the largest remaining rectangle (or dropped into param_hygiene.json when nothing usable is left); the same rule is applied again after the focused-field pass. Undecodable frames are treated as blacked out. The wrap sign-in e2e assertion checks that compiled templates are not almost entirely black.

[P2] The changelog entry was placed under the already-dated ## v3.4.0 (2026-11-20) section. Main's Flow changelog and packages/flow/pyproject.toml already name that cut. Please add ## Unreleased above ## v3.4.0 (2026-11-20) and move only this PR's withheld-field pixel-check note there, leaving the published 3.4.0 section as it is on main. Same class of placement issue as OpenAdapt#2363 and #2365.

Review only; do not merge.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 2a5d269

I will not merge.

Author is abrichr, not Grok. This is a delta re-review of my REQUEST CHANGES at b181466303a12720ed9a70a8f6ded5d4d55f0ea0.

The compile change and e2e assertion are still intact, and the CAPABILITIES / llms-full updates correctly describe the withheld-field pixel rule. The P2 is not fixed. packages/flow/CHANGELOG.md still has no ## Unreleased section; git diff origin/main -- packages/flow/CHANGELOG.md still inserts this PR's note under the already-dated ## v3.4.0 (2026-11-20) Fixes. Please restore Unreleased above that heading and move only this PR's withheld-field note there, leaving the published 3.4.0 section as it is on main.

Review only; do not merge.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 24f5d2e

Delta re-review of my REQUEST CHANGES at 2a5d26954. The withheld-field note now sits under a new ## Unreleased / ### Fixes heading. The dated ## v3.4.0 (2026-11-20) section is identical to main. tests/test_compile_withheld_fields.py landed in 653e6db59. I am not merging: the public OpenAdapt merge HOLD stands until the privacy-floor PR merges.

Logged on openadapt-internal#211.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: e8cd81b

Since the APPROVE at 24f5d2eabe, the only commit is ruff format on compiler/compile.py and tests/test_compile_withheld_fields.py (wrapping only; the clip/drop logic is unchanged) and a regeneration of llms-full.txt that removes the withheld-field bullet from the dated 3.4.0 Fixes section, matching the earlier move of that note under ## Unreleased. The capability table in llms-full.txt still states the rule.

I am not merging: the PR is CONFLICTING with main on packages/flow/CHANGELOG.md because main now uses ## v3.4.0 (held until PyPI serves openadapt-privacy 1.1.4) and this branch still has ## v3.4.0 (2026-11-20). Please merge or rebase main, keep the Unreleased note, and take the held heading.

Logged on openadapt-internal#211.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: d3e47bc

Delta check versus my APPROVE at e8cd81be. The only new commit is a merge of current main. Unique work is unchanged (compiler clip/drop of withheld-field pixel checks, tests). The changelog resolution is the Unreleased fix above the unaltered held ## v3.4.0 (held until PyPI serves openadapt-privacy 1.1.4) heading. Merge-tree versus main is clean. Not merged: coordinator order and packages-gate still apply.

Pointer: openadapt-internal#211

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude (independent reviewer)
Reviewed-Head: 191922e

Delta since Grok's approval at d3e47bc9

  • 571d62a1f unpacks redacted_region into four ints before appending, at both call sites, and renames the loop variable sa to after_png. The behavior is the same as before: the four values pass through in the same order.
  • The rest of the delta is two merges of origin/main and the changelog entry under Unreleased.

Correctness of the change as a whole

  • Box format: Recorder._redact documents redacted_region as (x, y, w, h), which is the compiler's Region format. The unpacked names x0, y0, x1, y1 suggest corners, which they are not. They should read x, y, w, h. This is a nit; the values are right.
  • Two producers: the helper runs per step right after mining, using that step's after-frame and every box seen up to and including that step. It runs again after apply_fixup_passes, so the focused-field pass (fixup_passes.py, REGION_STABLE from the after-frame) is covered too. The second pass rebuilds the box list in event order from pending. A step that the second pass can't find in after_by_step gets no boxes and is left alone. I found no such step: every step the fix-up passes return comes from pending.
  • Clip or drop:
    • Only REGION_STABLE checks that intersect a box, where that box is black in the after-frame, are changed.
    • A clip goes to the largest part of at least 8×8 px clear of the box, and is then re-checked against every hit box. If no clear part is left, the check is dropped and recorded in param_hygiene.json.
    • The whole-frame box (_WHOLE_FRAME, used when a field's box can't be read) intersects everything, so every overlapping check is dropped.
    • The re-crop and the phash come from the same after-frame.
  • Before typing: a frame from before the field was typed is not black there, so its check is untouched. That is right, and a unit test covers it.

Could a withheld field still be pixel-checked or captured?

  • REGION_STABLE: no, for the two producers above.
  • Values: the recorder writes no withheld value into the event or the frames. The field is black from the typing step on, so a template can capture a black box but never the value.

Nits (non-blocking)

  1. One extra black row and column. PIL's rectangle([x, y, x + w, y + h]) is inclusive, so the recorder's black box covers row y + h and column x + w as well. _clip_away starts the "below" part at by + bh and the "right" part at bx + bw, so a clipped check keeps one black row or column at its edge. The effect on phash is negligible at the sizes in the evidence (217×67). Using + 1 there, or making the recorder exclusive, would make it exact.
  2. Undecodable frame. _shows_blackout treats an undecodable frame as blacked out, and the clip path then calls _crop_png on that same frame. The drop path is fine. A clip on an undecodable frame would fail in _crop_png, not drop. This is unlikely, since mining already decoded the frame.

Out of scope

The click-target and anchor templates (compile.py around lines 3202 and 3385) and native_focus.py crop from the before-frame. On a sign-in form, the before-frame of a later step already shows an earlier withheld field black. A locate template next to it could include that box. These are locate templates, not refuting postconditions, and the staging evidence passed every field. It is the same class of problem, though, and worth a follow-up issue.

CI (gh pr checks)

14 checks pass, none fail and 15 are still pending: the flow unit shards, critical-e2e (with test_wrap_sign_in_e2e.py) and the other packages / jobs. Merge once they are green.

@abrichr abrichr closed this Nov 22, 2026
@abrichr abrichr reopened this Nov 22, 2026
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 191922e

Independent cross-vendor adversarial review of 191922eee028515d20188cd796bb7778b2a9f9c0 (Claude-authored claude/no-pixel-check-over-withheld; I authored none of this PR).

Findings & fail-closed verification

  • Covers both REGION_STABLE producers (compiler/compile.py): _checks_without_withheld_fields runs after postcondition mining and again after the fix-up passes (focused_field_region_stable), so neither producer can freeze a recorder blackout box over a withheld credential field.
  • Frame-verified & safe clipping/dropping: Only boxes that actually show blackout in the step's recorded after_png (_shows_blackout) are clipped or dropped, leaving pre-typing frames and non-intersecting checks untouched. _clip_away keeps only the largest clear sub-region of at least 8x8 px; after iterative clipping, any surviving intersection falls back to dropping the check. Clipped checks are re-cropped via _sealed.write_bytes and re-hashed (phash_png), and dropped checks are recorded in param_hygiene.json with "<withheld credential field>" (no credential leakage and no silent drops).
  • Regression coverage: test_compile_withheld_fields.py covers blackout detection, clipping, dropping/recording, pre-typing frames, and clear checks, and test_wrap_sign_in_e2e.py asserts no REGION_STABLE template is mostly black.

Generality gate

  1. No per-app code in engine: Verified; operates generically on recorder redacted_region metadata and REGION_STABLE postconditions.
  2. Fix the class, not the instance: Verified; aligns withheld-field pixel-check hygiene with parameter-region hygiene across both mining and fix-up passes.
  3. Held-out evidence: Verified via unit tests, sign-in e2e test, and staging sign-in runs (with the downstream Save approval wait honestly noted as a separate gap).

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 40cb741

VERDICT: APPROVE

Independent cross-vendor delta review of 40cb74188f129e0698b1ed4d36fd27acea103d58 (Claude-authored claude/no-pixel-check-over-withheld-field; I authored none of this PR).

  • Delta since prior Gemini APPROVE at 191922ee (#7082843811): Only two origin/main merges (b2251e21, 40cb7418) and a 2-line packages/flow/CHANGELOG.md backtick-formatting fix (2fc2e14d). All withheld-field blackout detection, clipping/dropping, and param_hygiene.json invariants verified at 191922ee are unchanged.
  • Note: PR currently shows CONFLICTING against main and needs a clean main merge before landing.

This branch has not been deployed

No deployments
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