From 88f08a3f2ca0b8682e20f26d7fb5a07872d9c950 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 00:58:23 -0500 Subject: [PATCH 1/8] release(flow): 3.4.0 requires openadapt-privacy 1.1.4 Raise the privacy extra's floor to openadapt-privacy[presidio]>=1.1.4, which has sanitization_config(); restore the dated v3.4.0 heading; note the Flow changes merged since the cut (#2379, #2392, #2313, #2369). --- packages/flow/CHANGELOG.md | 21 ++++++++++++++++++++- packages/flow/pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/flow/CHANGELOG.md b/packages/flow/CHANGELOG.md index c488559fb3..1dcbc11aec 100644 --- a/packages/flow/CHANGELOG.md +++ b/packages/flow/CHANGELOG.md @@ -15,7 +15,7 @@ -## v3.4.0 (held until PyPI serves openadapt-privacy 1.1.4) +## v3.4.0 (2026-11-21) ### Features @@ -64,6 +64,10 @@ registered that admitter key (`GET /api/v1/org/{org}/admitter-keys`) and otherwise refuses with `ADMITTER_KEY_UNREGISTERED`, naming the principal id and public key an owner or admin must register. +- `openadapt login` with no token signs in through the browser: a PKCE + loopback grant on `127.0.0.1` that stores the same credential `push` and + `report-run` use. `--token`, `OPENADAPT_INGEST_TOKEN` and a stored token keep + the old path (#2379). ### Fixes @@ -92,6 +96,21 @@ - Passphrase-derived keys, attended run keys and opened sealed sets are no longer cached for the whole process. Each independent operation authenticates again; caller-owned handles still reuse their key (#2341). +- The wire tap relays a redirect that stays on an allowed origin instead of + answering 502, so it can front a form app that answers a save with + Post/Redirect/Get. A redirect to another origin is still refused, and the tap + never follows one itself (#2392). +- Native typing, keys and hotkeys need a one-shot focus lease bound to the live + control and the exact frame that authorized the input, and a typed value must + be read back completely from two independent sources. Anything uncertain + releases held keys and produces no keyboard receipt (#2313). +- A repair candidate id that would leave the repair store is refused (#2369). + +### Requirements + +- The `privacy` extra needs `openadapt-privacy[presidio]>=1.1.4`, the first + release with `sanitization_config()`, which sanitized reuse and approval bind + to. ## v3.3.0 (2026-11-19) diff --git a/packages/flow/pyproject.toml b/packages/flow/pyproject.toml index d0ebac63a9..229be04bcd 100644 --- a/packages/flow/pyproject.toml +++ b/packages/flow/pyproject.toml @@ -267,7 +267,7 @@ registry = ["sigstore>=4.5,<5; python_version >= '3.11'"] # deployment installs this and sets OPENADAPT_FLOW_SCRUB=on to fail closed. # After install: python -m spacy download en_core_web_sm privacy = [ - "openadapt-privacy[presidio]>=1.0.0", + "openadapt-privacy[presidio]>=1.1.4", # spaCy imports Click directly from its CLI package but does not declare it; # Typer 0.27 stopped supplying Click transitively. Keep regulated-mode # compilation importable under fresh, unconstrained PyPI resolution. From b149595e1f031f2b5935485b6050e6a712946d36 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 10:05:51 -0500 Subject: [PATCH 2/8] docs(flow): make the 3.4.0 notes match what #2392, #2313, #2393, #2383 and the refactors do --- llms-full.txt | 36 +++++++++++++++++++++--------------- packages/flow/CHANGELOG.md | 36 +++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index e993008024..02784446b6 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -2460,14 +2460,16 @@ automation into an independently certified transaction system. derived from its explicit key for its own lifetime. Without that, each checkpoint read ran scrypt again, and the MockMed quickstart run took 28 s instead of 3.5 s (131 derivations, now 1). -- The wire tap relays a redirect that stays on an allowed origin instead of - answering 502, so it can front a form app that answers a save with - Post/Redirect/Get. A redirect to another origin is still refused, and the tap - never follows one itself (#2392). -- Native typing, keys and hotkeys need a one-shot focus lease bound to the live - control and the exact frame that authorized the input, and a typed value must - be read back completely from two independent sources. Anything uncertain - releases held keys and produces no keyboard receipt (#2313). +- The wire tap relays a redirect to an allowed origin instead of answering + 502, so it can front a form app that answers a save with Post/Redirect/Get. + In reverse-proxy mode only the upstream origin is allowed; in browser route + mode, any origin on the tap's allowlist. Other targets are still refused, and + the tap never follows a redirect itself (#2392). +- On the guarded native path, typing, keys and hotkeys use a one-shot focus + lease bound to the live control and the exact frame that authorized the + input. A typed value is checked against two complete, independent reads; a + failed check leaves the step unverified (`input_verified=False`). An + uncertain lease releases held keys before any input (#2313). - A repair candidate id that would leave the repair store is refused (#2369). - `wrap publish` no longer refuses programs whose identity templates carry `punctuation_body_keys`. These values are salted token hashes, the same @@ -2479,15 +2481,18 @@ automation into an independently certified transaction system. - An admitted managed run, and its resume, keep the policy the local Standard gate chose when neither the CLI nor the deployment names one, instead of exiting with code 2 (#2401). -- Lens route roles come from each route's observed effects rather than its - HTTP method, so an app that creates with `PUT` or updates with `POST` gets - the right roles, and a whole-record replace answering 200 counts as an - update (#2393). +- Lens route roles come from a route's observed effects when its mutation + response identifies the record, so an app that creates with `PUT` or updates + with `POST` gets the right roles, and a whole-record replace answering 200 + counts as an update. Without that evidence, roles still fall back to the + HTTP method (#2393). - Generated verify contracts stop fewer correct writes: five generator causes of false stops are fixed, each by one schema-independent rule (#2418). - `import openadapt_flow` loads its `ir` re-exports on first use, and the qualification models and several replayer helpers moved into their own - modules. Every public name is re-exported unchanged (#2439, #2451, #2454, + modules. Names still import explicitly from their old modules; + `from openadapt_flow.qualification import *` no longer includes + `AUTOMATED_GUI_ACTUATIONS` or `build_outcome_envelope` (#2439, #2451, #2454, #2455, #2456, #2459). ### Requirements @@ -2495,5 +2500,6 @@ automation into an independently certified transaction system. - The `privacy` extra needs `openadapt-privacy[presidio]>=1.1.4`, the first release with `sanitization_config()`, which sanitized reuse and approval bind to. -- Locked dependencies move to the first fixed release of each package with an - open security advisory, including Pillow, aiohttp and filelock (#2383). +- On Python 3.11 and newer, the lock moves Pillow, filelock and other + dependencies to the first release that fixes an open security advisory. The + Python 3.10 lock keeps Pillow 12.3.0 and filelock 3.29.7 (#2383). diff --git a/packages/flow/CHANGELOG.md b/packages/flow/CHANGELOG.md index 31ea82a5a4..6bc3225ee9 100644 --- a/packages/flow/CHANGELOG.md +++ b/packages/flow/CHANGELOG.md @@ -100,14 +100,16 @@ derived from its explicit key for its own lifetime. Without that, each checkpoint read ran scrypt again, and the MockMed quickstart run took 28 s instead of 3.5 s (131 derivations, now 1). -- The wire tap relays a redirect that stays on an allowed origin instead of - answering 502, so it can front a form app that answers a save with - Post/Redirect/Get. A redirect to another origin is still refused, and the tap - never follows one itself (#2392). -- Native typing, keys and hotkeys need a one-shot focus lease bound to the live - control and the exact frame that authorized the input, and a typed value must - be read back completely from two independent sources. Anything uncertain - releases held keys and produces no keyboard receipt (#2313). +- The wire tap relays a redirect to an allowed origin instead of answering + 502, so it can front a form app that answers a save with Post/Redirect/Get. + In reverse-proxy mode only the upstream origin is allowed; in browser route + mode, any origin on the tap's allowlist. Other targets are still refused, and + the tap never follows a redirect itself (#2392). +- On the guarded native path, typing, keys and hotkeys use a one-shot focus + lease bound to the live control and the exact frame that authorized the + input. A typed value is checked against two complete, independent reads; a + failed check leaves the step unverified (`input_verified=False`). An + uncertain lease releases held keys before any input (#2313). - A repair candidate id that would leave the repair store is refused (#2369). - `wrap publish` no longer refuses programs whose identity templates carry `punctuation_body_keys`. These values are salted token hashes, the same @@ -119,15 +121,18 @@ - An admitted managed run, and its resume, keep the policy the local Standard gate chose when neither the CLI nor the deployment names one, instead of exiting with code 2 (#2401). -- Lens route roles come from each route's observed effects rather than its - HTTP method, so an app that creates with `PUT` or updates with `POST` gets - the right roles, and a whole-record replace answering 200 counts as an - update (#2393). +- Lens route roles come from a route's observed effects when its mutation + response identifies the record, so an app that creates with `PUT` or updates + with `POST` gets the right roles, and a whole-record replace answering 200 + counts as an update. Without that evidence, roles still fall back to the + HTTP method (#2393). - Generated verify contracts stop fewer correct writes: five generator causes of false stops are fixed, each by one schema-independent rule (#2418). - `import openadapt_flow` loads its `ir` re-exports on first use, and the qualification models and several replayer helpers moved into their own - modules. Every public name is re-exported unchanged (#2439, #2451, #2454, + modules. Names still import explicitly from their old modules; + `from openadapt_flow.qualification import *` no longer includes + `AUTOMATED_GUI_ACTUATIONS` or `build_outcome_envelope` (#2439, #2451, #2454, #2455, #2456, #2459). ### Requirements @@ -135,8 +140,9 @@ - The `privacy` extra needs `openadapt-privacy[presidio]>=1.1.4`, the first release with `sanitization_config()`, which sanitized reuse and approval bind to. -- Locked dependencies move to the first fixed release of each package with an - open security advisory, including Pillow, aiohttp and filelock (#2383). +- On Python 3.11 and newer, the lock moves Pillow, filelock and other + dependencies to the first release that fixes an open security advisory. The + Python 3.10 lock keeps Pillow 12.3.0 and filelock 3.29.7 (#2383). ## v3.3.0 (2026-11-19) From 97f40a11edc5cb324d8c1e1b79ea5ed7f4519a47 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 10:11:21 -0500 Subject: [PATCH 3/8] docs(flow): scope the 3.4.0 keyboard-lease and lens-role notes to what the code guarantees --- llms-full.txt | 21 ++++++++++----------- packages/flow/CHANGELOG.md | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 02784446b6..f42d9c4da5 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -2465,11 +2465,11 @@ automation into an independently certified transaction system. In reverse-proxy mode only the upstream origin is allowed; in browser route mode, any origin on the tap's allowlist. Other targets are still refused, and the tap never follows a redirect itself (#2392). -- On the guarded native path, typing, keys and hotkeys use a one-shot focus - lease bound to the live control and the exact frame that authorized the - input. A typed value is checked against two complete, independent reads; a - failed check leaves the step unverified (`input_verified=False`). An - uncertain lease releases held keys before any input (#2313). +- A Windows agent that advertises `native_keyboard_lease_v1` binds native + typing, keys and hotkeys to a one-shot focus lease over the live control and + the frame that authorized the input. If focus changes during delivery, no + further key goes down and held keys are released. A complete native value + observation needs two agreeing independent reads (#2313). - A repair candidate id that would leave the repair store is refused (#2369). - `wrap publish` no longer refuses programs whose identity templates carry `punctuation_body_keys`. These values are salted token hashes, the same @@ -2481,11 +2481,10 @@ automation into an independently certified transaction system. - An admitted managed run, and its resume, keep the policy the local Standard gate chose when neither the CLI nor the deployment names one, instead of exiting with code 2 (#2401). -- Lens route roles come from a route's observed effects when its mutation - response identifies the record, so an app that creates with `PUT` or updates - with `POST` gets the right roles, and a whole-record replace answering 200 - counts as an update. Without that evidence, roles still fall back to the - HTTP method (#2393). +- Lens route induction can take a route's role from its observed effects + instead of its HTTP method, so some apps that create with `PUT` or update + with `POST` get the right roles. Where the trace does not show the effect, + roles still follow the method (#2393). - Generated verify contracts stop fewer correct writes: five generator causes of false stops are fixed, each by one schema-independent rule (#2418). - `import openadapt_flow` loads its `ir` re-exports on first use, and the @@ -2501,5 +2500,5 @@ automation into an independently certified transaction system. release with `sanitization_config()`, which sanitized reuse and approval bind to. - On Python 3.11 and newer, the lock moves Pillow, filelock and other - dependencies to the first release that fixes an open security advisory. The + dependencies to a release that fixes an open security advisory. The Python 3.10 lock keeps Pillow 12.3.0 and filelock 3.29.7 (#2383). diff --git a/packages/flow/CHANGELOG.md b/packages/flow/CHANGELOG.md index 6bc3225ee9..45fb4eb9b2 100644 --- a/packages/flow/CHANGELOG.md +++ b/packages/flow/CHANGELOG.md @@ -105,11 +105,11 @@ In reverse-proxy mode only the upstream origin is allowed; in browser route mode, any origin on the tap's allowlist. Other targets are still refused, and the tap never follows a redirect itself (#2392). -- On the guarded native path, typing, keys and hotkeys use a one-shot focus - lease bound to the live control and the exact frame that authorized the - input. A typed value is checked against two complete, independent reads; a - failed check leaves the step unverified (`input_verified=False`). An - uncertain lease releases held keys before any input (#2313). +- A Windows agent that advertises `native_keyboard_lease_v1` binds native + typing, keys and hotkeys to a one-shot focus lease over the live control and + the frame that authorized the input. If focus changes during delivery, no + further key goes down and held keys are released. A complete native value + observation needs two agreeing independent reads (#2313). - A repair candidate id that would leave the repair store is refused (#2369). - `wrap publish` no longer refuses programs whose identity templates carry `punctuation_body_keys`. These values are salted token hashes, the same @@ -121,11 +121,10 @@ - An admitted managed run, and its resume, keep the policy the local Standard gate chose when neither the CLI nor the deployment names one, instead of exiting with code 2 (#2401). -- Lens route roles come from a route's observed effects when its mutation - response identifies the record, so an app that creates with `PUT` or updates - with `POST` gets the right roles, and a whole-record replace answering 200 - counts as an update. Without that evidence, roles still fall back to the - HTTP method (#2393). +- Lens route induction can take a route's role from its observed effects + instead of its HTTP method, so some apps that create with `PUT` or update + with `POST` get the right roles. Where the trace does not show the effect, + roles still follow the method (#2393). - Generated verify contracts stop fewer correct writes: five generator causes of false stops are fixed, each by one schema-independent rule (#2418). - `import openadapt_flow` loads its `ir` re-exports on first use, and the @@ -141,7 +140,7 @@ release with `sanitization_config()`, which sanitized reuse and approval bind to. - On Python 3.11 and newer, the lock moves Pillow, filelock and other - dependencies to the first release that fixes an open security advisory. The + dependencies to a release that fixes an open security advisory. The Python 3.10 lock keeps Pillow 12.3.0 and filelock 3.29.7 (#2383). ## v3.3.0 (2026-11-19) From bba710d077429e8260cfe4c099b4c0d59682902a Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 10:15:14 -0500 Subject: [PATCH 4/8] docs(flow): describe #2313 and #2393 in the 3.4.0 notes without guarantees the code scopes more narrowly --- llms-full.txt | 14 +++++--------- packages/flow/CHANGELOG.md | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index f42d9c4da5..ac558ccde5 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -2465,11 +2465,9 @@ automation into an independently certified transaction system. In reverse-proxy mode only the upstream origin is allowed; in browser route mode, any origin on the tap's allowlist. Other targets are still refused, and the tap never follows a redirect itself (#2392). -- A Windows agent that advertises `native_keyboard_lease_v1` binds native - typing, keys and hotkeys to a one-shot focus lease over the live control and - the frame that authorized the input. If focus changes during delivery, no - further key goes down and held keys are released. A complete native value - observation needs two agreeing independent reads (#2313). +- Guarded native keyboard delivery on a Windows agent that advertises + `native_keyboard_lease_v1` uses a one-shot focus lease over the authorized + control and frame. #2313 describes when it applies and what it checks. - A repair candidate id that would leave the repair store is refused (#2369). - `wrap publish` no longer refuses programs whose identity templates carry `punctuation_body_keys`. These values are salted token hashes, the same @@ -2481,10 +2479,8 @@ automation into an independently certified transaction system. - An admitted managed run, and its resume, keep the policy the local Standard gate chose when neither the CLI nor the deployment names one, instead of exiting with code 2 (#2401). -- Lens route induction can take a route's role from its observed effects - instead of its HTTP method, so some apps that create with `PUT` or update - with `POST` get the right roles. Where the trace does not show the effect, - roles still follow the method (#2393). +- Lens route induction can use a trace's observed effects, not only HTTP + methods, to assign route roles (#2393). - Generated verify contracts stop fewer correct writes: five generator causes of false stops are fixed, each by one schema-independent rule (#2418). - `import openadapt_flow` loads its `ir` re-exports on first use, and the diff --git a/packages/flow/CHANGELOG.md b/packages/flow/CHANGELOG.md index 45fb4eb9b2..a75578712f 100644 --- a/packages/flow/CHANGELOG.md +++ b/packages/flow/CHANGELOG.md @@ -105,11 +105,9 @@ In reverse-proxy mode only the upstream origin is allowed; in browser route mode, any origin on the tap's allowlist. Other targets are still refused, and the tap never follows a redirect itself (#2392). -- A Windows agent that advertises `native_keyboard_lease_v1` binds native - typing, keys and hotkeys to a one-shot focus lease over the live control and - the frame that authorized the input. If focus changes during delivery, no - further key goes down and held keys are released. A complete native value - observation needs two agreeing independent reads (#2313). +- Guarded native keyboard delivery on a Windows agent that advertises + `native_keyboard_lease_v1` uses a one-shot focus lease over the authorized + control and frame. #2313 describes when it applies and what it checks. - A repair candidate id that would leave the repair store is refused (#2369). - `wrap publish` no longer refuses programs whose identity templates carry `punctuation_body_keys`. These values are salted token hashes, the same @@ -121,10 +119,8 @@ - An admitted managed run, and its resume, keep the policy the local Standard gate chose when neither the CLI nor the deployment names one, instead of exiting with code 2 (#2401). -- Lens route induction can take a route's role from its observed effects - instead of its HTTP method, so some apps that create with `PUT` or update - with `POST` get the right roles. Where the trace does not show the effect, - roles still follow the method (#2393). +- Lens route induction can use a trace's observed effects, not only HTTP + methods, to assign route roles (#2393). - Generated verify contracts stop fewer correct writes: five generator causes of false stops are fixed, each by one schema-independent rule (#2418). - `import openadapt_flow` loads its `ir` re-exports on first use, and the From b327288c7aad6af3b608498f70a06676cf7e10a6 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 10:19:49 -0500 Subject: [PATCH 5/8] fix(tx): relay the redirect URL that was checked, never raw Location text A browser reads 'http:/evil.test' as the host evil.test, while urljoin puts it on the request's own origin, so the wire tap's route mode relayed a raw Location that sent the client to an origin it never checked. Relay the resolved URL instead, and refuse Location values with control characters or spaces. Found by the Codex review of #2470. --- packages/flow/openadapt_flow/tx/wire_tap.py | 10 ++++++- packages/flow/tests/test_tx_wire_redirects.py | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/flow/openadapt_flow/tx/wire_tap.py b/packages/flow/openadapt_flow/tx/wire_tap.py index aa2a947828..342efaf496 100644 --- a/packages/flow/openadapt_flow/tx/wire_tap.py +++ b/packages/flow/openadapt_flow/tx/wire_tap.py @@ -126,6 +126,10 @@ def relay_redirect_location( # even though URL parsers here treat it as a relative path. if not raw or any(ch in raw for ch in "\r\n\\"): return None + # Browsers drop tabs and newlines inside a URL; refuse any control + # character or space rather than guess how a client will read it. + if any(ord(ch) <= 0x20 or ord(ch) == 0x7F for ch in raw): + return None resolved = urljoin(request_url, raw) origin = _normalize_origin(resolved) if not origin or origin not in allowed_origins: @@ -143,7 +147,11 @@ def relay_redirect_location( if target.fragment: rewritten += "#" + target.fragment return rewritten - return raw + # Relay the URL as resolved here, never the raw text: a browser reads + # ``http:/evil.test`` as the host evil.test, while urljoin resolves it + # onto the request's own origin, so relaying the raw value would send + # the client to an origin that was never checked. + return resolved class _ResolvedTarget(NamedTuple): diff --git a/packages/flow/tests/test_tx_wire_redirects.py b/packages/flow/tests/test_tx_wire_redirects.py index 7bc61ab2e2..4650538f81 100644 --- a/packages/flow/tests/test_tx_wire_redirects.py +++ b/packages/flow/tests/test_tx_wire_redirects.py @@ -180,6 +180,36 @@ def test_relay_helper_refuses_malformed_or_non_http_targets(location): ) +@pytest.mark.parametrize( + "location", + ["http:/evil.test/x", "https:/evil.test/x", "http:evil.test", "http:///evil.test"], +) +def test_relay_helper_never_relays_text_a_browser_reads_as_another_host(location): + # A browser resolves "http:/evil.test" to the host evil.test, while urljoin + # puts it on the request's origin. The relayed value must be the URL that + # was checked, so the client cannot land anywhere else. + origin = "http://127.0.0.1:8000" + relayed = relay_redirect_location( + location, + request_url=f"{origin}/form", + allowed_origins=frozenset({origin}), + ) + assert relayed is None or relayed.startswith(origin + "/") + + +@pytest.mark.parametrize("location", ["/\t/evil.test", "/ok\tx", " /ok x"]) +def test_relay_helper_refuses_control_characters_and_spaces(location): + origin = "http://127.0.0.1:8000" + assert ( + relay_redirect_location( + location, + request_url=f"{origin}/form", + allowed_origins=frozenset({origin}), + ) + is None + ) + + def test_browser_route_relays_same_origin_redirect_and_aborts_foreign(): origin = "http://127.0.0.1:8000" From 4d5db11d72bc16868a364534256ccd8afc4b7a2c Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 10:38:45 -0500 Subject: [PATCH 6/8] fix(tx): relay redirects only in reverse-proxy mode, rebuilt from the checked URL Playwright runs a route handler only for the first URL of a redirect chain, so browser route mode refuses every redirect again. In reverse-proxy mode only a plain path relays as written; anything with a scheme or authority (including ///host) relays only as the checked URL on the tap's origin. Headers are validated as received, parse errors refuse, and IPv6 origins keep their brackets. From the Codex review of #2470. --- llms-full.txt | 10 +-- packages/flow/CHANGELOG.md | 10 +-- packages/flow/openadapt_flow/tx/wire_tap.py | 90 +++++++++---------- packages/flow/tests/test_tx_wire_redirects.py | 64 ++++++++++--- 4 files changed, 107 insertions(+), 67 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index ac558ccde5..8fe351e308 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -2460,11 +2460,11 @@ automation into an independently certified transaction system. derived from its explicit key for its own lifetime. Without that, each checkpoint read ran scrypt again, and the MockMed quickstart run took 28 s instead of 3.5 s (131 derivations, now 1). -- The wire tap relays a redirect to an allowed origin instead of answering - 502, so it can front a form app that answers a save with Post/Redirect/Get. - In reverse-proxy mode only the upstream origin is allowed; in browser route - mode, any origin on the tap's allowlist. Other targets are still refused, and - the tap never follows a redirect itself (#2392). +- In reverse-proxy mode the wire tap relays a redirect to a path on the + upstream origin, rebuilt on the tap's own origin, instead of answering 502, + so it can front a form app that answers a save with Post/Redirect/Get. The + client's next request comes back through the tap. Browser route mode still + refuses every redirect, and the tap never follows one itself (#2392). - Guarded native keyboard delivery on a Windows agent that advertises `native_keyboard_lease_v1` uses a one-shot focus lease over the authorized control and frame. #2313 describes when it applies and what it checks. diff --git a/packages/flow/CHANGELOG.md b/packages/flow/CHANGELOG.md index a75578712f..491edc524b 100644 --- a/packages/flow/CHANGELOG.md +++ b/packages/flow/CHANGELOG.md @@ -100,11 +100,11 @@ derived from its explicit key for its own lifetime. Without that, each checkpoint read ran scrypt again, and the MockMed quickstart run took 28 s instead of 3.5 s (131 derivations, now 1). -- The wire tap relays a redirect to an allowed origin instead of answering - 502, so it can front a form app that answers a save with Post/Redirect/Get. - In reverse-proxy mode only the upstream origin is allowed; in browser route - mode, any origin on the tap's allowlist. Other targets are still refused, and - the tap never follows a redirect itself (#2392). +- In reverse-proxy mode the wire tap relays a redirect to a path on the + upstream origin, rebuilt on the tap's own origin, instead of answering 502, + so it can front a form app that answers a save with Post/Redirect/Get. The + client's next request comes back through the tap. Browser route mode still + refuses every redirect, and the tap never follows one itself (#2392). - Guarded native keyboard delivery on a Windows agent that advertises `native_keyboard_lease_v1` uses a one-shot focus lease over the authorized control and frame. #2313 describes when it applies and what it checks. diff --git a/packages/flow/openadapt_flow/tx/wire_tap.py b/packages/flow/openadapt_flow/tx/wire_tap.py index 342efaf496..61992cdb64 100644 --- a/packages/flow/openadapt_flow/tx/wire_tap.py +++ b/packages/flow/openadapt_flow/tx/wire_tap.py @@ -89,12 +89,19 @@ def _utc_now_iso() -> str: def _normalize_origin(url_or_origin: str) -> str: - parts = urlsplit(url_or_origin.strip()) - if not parts.scheme or not parts.netloc: + try: + parts = urlsplit(url_or_origin.strip()) + if not parts.scheme or not parts.netloc: + return "" + scheme = parts.scheme.lower() + host = (parts.hostname or "").lower() + port = parts.port + except ValueError: + # A malformed port or bracketed host is no origin at all. return "" - scheme = parts.scheme.lower() - host = (parts.hostname or "").lower() - port = parts.port + if ":" in host: + # Keep IPv6 brackets so a port can never read as part of the address. + host = f"[{host}]" if ( port is None or (scheme == "http" and port == 80) @@ -114,6 +121,9 @@ def relay_redirect_location( ) -> Optional[str]: """Return the ``Location`` to relay for a same-origin redirect, else ``None``. + Reverse-proxy mode only: the client's next request comes back through the + tap, so every hop is checked again. Browser route mode refuses redirects. + The tap never follows a redirect itself. It hands a redirect back to the client only when the target, resolved against the request URL, stays on an allowed origin, so the next request passes through the tap again. A @@ -121,37 +131,37 @@ def relay_redirect_location( ``rewrite_from_origin``/``rewrite_to_origin`` map an absolute upstream target onto the tap's own origin in reverse-proxy mode. """ - raw = (location or "").strip() - # Browsers read a backslash as a slash, so ``/\\host`` leaves the origin - # even though URL parsers here treat it as a relative path. - if not raw or any(ch in raw for ch in "\r\n\\"): + raw = location or "" + # Validate the header exactly as received. Browsers drop tabs and newlines + # inside a URL and read a backslash as a slash, so refuse any space, + # control character or backslash rather than guess how a client reads it. + if not raw or any(ord(ch) <= 0x20 or ord(ch) == 0x7F or ch == "\\" for ch in raw): return None - # Browsers drop tabs and newlines inside a URL; refuse any control - # character or space rather than guess how a client will read it. - if any(ord(ch) <= 0x20 or ord(ch) == 0x7F for ch in raw): + try: + resolved = urljoin(request_url, raw) + origin = _normalize_origin(resolved) + parts = urlsplit(raw) + except ValueError: return None - resolved = urljoin(request_url, raw) - origin = _normalize_origin(resolved) if not origin or origin not in allowed_origins: return None - parts = urlsplit(raw) - if not parts.scheme and not parts.netloc: + # Only a plain path relays as written. Anything with a scheme or an + # authority, including ``///host`` that urlsplit reads as a path but a + # browser reads as a host, is relayed only as the URL checked here, + # rebuilt on the tap's own origin. + if not parts.scheme and not parts.netloc and not raw.startswith("//"): return raw - if rewrite_from_origin is not None and rewrite_to_origin is not None: - if origin != rewrite_from_origin: - return None - target = urlsplit(resolved) - rewritten = rewrite_to_origin.rstrip("/") + (target.path or "/") - if target.query: - rewritten += "?" + target.query - if target.fragment: - rewritten += "#" + target.fragment - return rewritten - # Relay the URL as resolved here, never the raw text: a browser reads - # ``http:/evil.test`` as the host evil.test, while urljoin resolves it - # onto the request's own origin, so relaying the raw value would send - # the client to an origin that was never checked. - return resolved + if rewrite_from_origin is None or rewrite_to_origin is None: + return None + if origin != rewrite_from_origin: + return None + target = urlsplit(resolved) + rewritten = rewrite_to_origin.rstrip("/") + (target.path or "/") + if target.query: + rewritten += "?" + target.query + if target.fragment: + rewritten += "#" + target.fragment + return rewritten class _ResolvedTarget(NamedTuple): @@ -1834,20 +1844,10 @@ def _handle_route(route: Any) -> None: if callable(fetch_fn) and callable(fulfill_fn): fetched = fetch_fn(max_redirects=0) resp_status, resp_headers, resp_body = _extract_route_response(fetched) - relayed_location = ( - relay_redirect_location( - _get_header(resp_headers, "location"), - request_url=req_url, - allowed_origins=self._allowed_origins, - ) - if resp_status is not None and 300 <= resp_status < 400 - else None - ) - if ( - resp_status is not None - and 300 <= resp_status < 400 - and relayed_location is None - ): + # Playwright runs this handler only for the first URL of a + # redirect chain, so a relayed redirect would leave later hops + # unchecked. Refuse every redirect in this mode. + if resp_status is not None and 300 <= resp_status < 400: self._finalize_request( ticket, request_headers=req_headers, diff --git a/packages/flow/tests/test_tx_wire_redirects.py b/packages/flow/tests/test_tx_wire_redirects.py index 4650538f81..47283be35d 100644 --- a/packages/flow/tests/test_tx_wire_redirects.py +++ b/packages/flow/tests/test_tx_wire_redirects.py @@ -182,23 +182,50 @@ def test_relay_helper_refuses_malformed_or_non_http_targets(location): @pytest.mark.parametrize( "location", - ["http:/evil.test/x", "https:/evil.test/x", "http:evil.test", "http:///evil.test"], + [ + "http:/evil.test/x", + "https:/evil.test/x", + "http:evil.test", + "///evil.test/x", + "////evil.test", + "http://127.0.0.1:8000/ok", + ], ) -def test_relay_helper_never_relays_text_a_browser_reads_as_another_host(location): - # A browser resolves "http:/evil.test" to the host evil.test, while urljoin - # puts it on the request's origin. The relayed value must be the URL that - # was checked, so the client cannot land anywhere else. +def test_without_a_rewrite_only_plain_paths_relay(location): + # Without the reverse-proxy rewrite, nothing with a scheme or authority + # relays: a browser may read it as a different host than urljoin did. origin = "http://127.0.0.1:8000" + assert ( + relay_redirect_location( + location, + request_url=f"{origin}/form", + allowed_origins=frozenset({origin}), + ) + is None + ) + + +@pytest.mark.parametrize( + "location", ["http:/evil.test/x", "///evil.test/x", "http://up.test/next?a=1"] +) +def test_reverse_proxy_rewrite_never_relays_raw_absolute_text(location): + up, tap = "http://up.test", "http://127.0.0.1:9000" relayed = relay_redirect_location( location, - request_url=f"{origin}/form", - allowed_origins=frozenset({origin}), + request_url=f"{up}/form", + allowed_origins=frozenset({up}), + rewrite_from_origin=up, + rewrite_to_origin=tap, ) - assert relayed is None or relayed.startswith(origin + "/") + # Either refused, or rebuilt on the tap's origin from the checked URL. + assert relayed is None or relayed.startswith(tap + "/") -@pytest.mark.parametrize("location", ["/\t/evil.test", "/ok\tx", " /ok x"]) -def test_relay_helper_refuses_control_characters_and_spaces(location): +@pytest.mark.parametrize( + "location", + ["/\t/evil.test", "/ok\tx", " /ok", "/ok ", "/ok x", "/ok\x7f", "http://[::1"], +) +def test_relay_helper_refuses_unclean_or_unparseable_headers(location): origin = "http://127.0.0.1:8000" assert ( relay_redirect_location( @@ -210,7 +237,18 @@ def test_relay_helper_refuses_control_characters_and_spaces(location): ) -def test_browser_route_relays_same_origin_redirect_and_aborts_foreign(): +def test_ipv6_origins_keep_their_brackets(): + from openadapt_flow.tx.wire_tap import _normalize_origin + + assert _normalize_origin("http://[::1]:8080/x") == "http://[::1]:8080" + assert _normalize_origin("http://[::1:8080]/x") == "http://[::1:8080]" + assert _normalize_origin("http://[::1]:8080") != _normalize_origin( + "http://[::1:8080]" + ) + assert _normalize_origin("http://h:notaport/") == "" + + +def test_browser_route_refuses_every_redirect(): origin = "http://127.0.0.1:8000" class Response: @@ -257,7 +295,9 @@ def route(self, pattern: str, handler: Any) -> None: foreign = Route(f"{origin}/save", "http://127.0.0.1:1/steal") page.handler(same) page.handler(foreign) - assert same.fulfilled is not None and not same.aborted + # Playwright calls the handler only for a chain's first URL, so even a + # same-origin redirect would leave later hops unchecked: both abort. + assert same.aborted and same.fulfilled is None assert foreign.aborted and foreign.fulfilled is None statuses = [m.response_status for m in tap.summary().mutations] assert statuses == [302, 302] From 769525ff10776f18a5a2e3341b56ea9fcfd00787 Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 10:45:54 -0500 Subject: [PATCH 7/8] fix(tx): refuse a request whose target has no parseable origin _normalize_origin now returns an empty origin for an invalid port, and the request policy checked the allowlist only for a non-empty origin. Treat an empty origin as disallowed; a regression test asserts refusal and no upstream request. From the Codex review of #2470. --- packages/flow/openadapt_flow/tx/wire_tap.py | 4 +++- packages/flow/tests/test_tx_wire_request_targets.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/flow/openadapt_flow/tx/wire_tap.py b/packages/flow/openadapt_flow/tx/wire_tap.py index 61992cdb64..bdbfb09bf3 100644 --- a/packages/flow/openadapt_flow/tx/wire_tap.py +++ b/packages/flow/openadapt_flow/tx/wire_tap.py @@ -1268,7 +1268,9 @@ def _evaluate_policy_locked( ): return "secret_in_url" - if target_origin and target_origin not in self._allowed_origins: + # A target with no parseable origin (for example an invalid port) is + # never forwarded: an empty origin must not skip the allowlist. + if not target_origin or target_origin not in self._allowed_origins: return "disallowed_origin" if not is_mutation: diff --git a/packages/flow/tests/test_tx_wire_request_targets.py b/packages/flow/tests/test_tx_wire_request_targets.py index 6ab9bb705c..5268dc4269 100644 --- a/packages/flow/tests/test_tx_wire_request_targets.py +++ b/packages/flow/tests/test_tx_wire_request_targets.py @@ -215,3 +215,13 @@ def test_all_entrypoints_share_stateful_budget_and_write_route_policy( assert route.events == ["abort"] assert tap.summary().mutations[0].block_reason == "undeclared_write_route" assert tap.summary().mutations_allowed == 0 + + +@pytest.mark.parametrize("suffix", [":notaport/rows", ":99999/rows", ":-1/rows"]) +def test_absolute_target_with_an_unparseable_origin_is_refused(upstream, suffix): + origin, seen = upstream + host = urlsplit(origin).hostname + with SessionWireTap(origin, WirePolicy(max_mutations=None)) as tap: + status = send(tap, "GET", f"http://{host}{suffix}") + assert status >= 400 + assert seen == [] From 583875ac35628a2dd0e635e84c3695dec5c5526c Mon Sep 17 00:00:00 2001 From: abrichr Date: Sat, 21 Nov 2026 15:27:16 -0500 Subject: [PATCH 8/8] fix(release): deduplicate changelog, rebuild llms-full.txt, and synchronize queued read-back timeout test --- llms-full.txt | 7 +++++ packages/flow/CHANGELOG.md | 7 ----- packages/flow/tests/test_agent_write_guard.py | 31 ++++++++++++++++--- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index adeb3b4fb0..b61178f5a0 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -2433,6 +2433,13 @@ automation into an independently certified transaction system. ### Fixes +- A headed browser window that draws no frames (on macOS, one covered by a + full-size terminal window) no longer halts a run at its first step. The + page settle waited for two animation frames after the last change, which + such a window never draws, so the readiness gate timed out after 10 s with + "starting state not ready". When every other page signal is quiet and the + page has drawn no frame for a second, or the page is hidden, the settle now + falls back to two identical screenshots. - Choice labels, values, shape metadata and browser-dialog messages are checked against declared secrets before capture. A matching or opaque secret boundary stops recording before that text reaches its artifacts. diff --git a/packages/flow/CHANGELOG.md b/packages/flow/CHANGELOG.md index a4a2389d0c..d5a15df702 100644 --- a/packages/flow/CHANGELOG.md +++ b/packages/flow/CHANGELOG.md @@ -78,13 +78,6 @@ "starting state not ready". When every other page signal is quiet and the page has drawn no frame for a second, or the page is hidden, the settle now falls back to two identical screenshots. -- `wrap publish` no longer refuses programs whose identity templates carry - `punctuation_body_keys`. These values are salted token hashes, the same - generated shape as the `c` and `r` keys, but the sanitizer sent them to - the PHI recognizer. It sometimes read one as an organization or a group - name and rewrote it, so publish stopped with `SANITIZATION_CHANGED_PROGRAM`. - Only an index key with a hex hash of 16 or more characters is kept. Free - text in that slot is still scrubbed. - Choice labels, values, shape metadata and browser-dialog messages are checked against declared secrets before capture. A matching or opaque secret boundary stops recording before that text reaches its artifacts. diff --git a/packages/flow/tests/test_agent_write_guard.py b/packages/flow/tests/test_agent_write_guard.py index 0086a7685e..ecb0e4a270 100644 --- a/packages/flow/tests/test_agent_write_guard.py +++ b/packages/flow/tests/test_agent_write_guard.py @@ -199,16 +199,36 @@ def _saturate_pool() -> threading.Event: from openadapt_flow.integrations.agents import _POOL release = threading.Event() + started = threading.Barrier(_POOL._max_workers + 1) + + def _hold() -> None: + started.wait(timeout=10) + release.wait(30) + for _ in range(_POOL._max_workers): - _POOL.submit(release.wait, 30) + _POOL.submit(_hold) + started.wait(timeout=10) return release def test_a_read_back_queued_behind_a_full_pool_survives_a_timeout( - portal: Portal, tmp_path: Path + portal: Portal, tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: + from openadapt_flow.integrations.agents import _POOL + guard = _guard(portal, tmp_path) blockers: list[threading.Event] = [] + queued = asyncio.Event() + loop_ref: list[asyncio.AbstractEventLoop] = [] + real_submit = _POOL.submit + + def _tracking_submit(fn, /, *args, **kwargs): + fut = real_submit(fn, *args, **kwargs) + if blockers and fn == guard._finish: + loop_ref[0].call_soon_threadsafe(queued.set) + return fut + + monkeypatch.setattr(_POOL, "submit", _tracking_submit) async def write(): out = await asyncio.to_thread(portal.save_order, **ORDER) @@ -216,9 +236,12 @@ async def write(): return out async def timed_out(): + loop_ref.append(asyncio.get_running_loop()) + task = asyncio.create_task(guard.arun(ORDER, write)) + await asyncio.wait_for(queued.wait(), timeout=10.0) with pytest.raises(TimeoutError): - async with asyncio.timeout(0.5): - await guard.arun(ORDER, write) + async with asyncio.timeout(0.05): + await task try: asyncio.run(timed_out())