Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
9cf0ab8
chore(handoff): preserve browser proxy work in progress
senamakel Oct 21, 2026
c52ad1b
Merge remote-tracking branch 'origin/main' into epic-7328-browser-res…
senamakel Oct 21, 2026
36668e1
test(bus): avoid float equality lint
senamakel Oct 21, 2026
98b4ca1
test(tinycomputer): keep browser egress host async
senamakel Oct 21, 2026
d7d1bf1
fix(browser): try later authorized egress addresses
senamakel Oct 21, 2026
c49e951
chore(deps): refresh rustls and yoke lock entries
senamakel Oct 21, 2026
525c4e7
fix(bus): bump contract for browser egress host
senamakel Oct 21, 2026
52a0507
Address browser egress review feedback
senamakel Oct 21, 2026
25afb0b
Make unreachable proxy test deterministic
senamakel Oct 21, 2026
8b2d7b4
Bump vendored browser and bus security fixes
senamakel Oct 21, 2026
69346e5
fix(tinycomputer-browser): recheck browser liveness after acquiring e…
senamakel Oct 21, 2026
e1b4de0
test(linked): gate live browser test helpers behind cfg
senamakel Oct 21, 2026
655f002
test(egress): split proxy tests into per-protocol modules
senamakel Oct 21, 2026
9d1da13
refactor(egress): split browser proxy into submodules
senamakel Oct 21, 2026
6491e75
docs(tinycomputer): drop browser executable and args from config example
senamakel Oct 21, 2026
8a30d61
test(egress): add shared fixture authorizer helpers
senamakel Oct 21, 2026
ca05bad
refactor(egress-tests): widen simulator fixture visibility to super
senamakel Oct 21, 2026
f313e14
style: format egress imports and signatures
senamakel Oct 21, 2026
cf2e63d
test(egress): narrow test imports to what each module uses
senamakel Oct 21, 2026
86aed71
refactor(egress): widen visibility of proxy request helpers
senamakel Oct 21, 2026
d871d69
test(egress): give each egress test module a specific doc comment
senamakel Oct 21, 2026
4313f29
refactor(egress): tidy imports and gate test-only re-export
senamakel Oct 21, 2026
72ed1b6
test(egress): import SocketAddr in retry tests
senamakel Oct 21, 2026
86920e6
fix(browser-egress): stream request bodies to upstream instead of buf…
senamakel Oct 21, 2026
e2d64fa
test(browser-egress): cover large request bodies and tidy round-trip …
senamakel Oct 21, 2026
8870e0b
refactor(egress): drop unused mut on proxy request binding
senamakel Oct 21, 2026
32e1080
refactor(egress): collapse let-else onto one line
senamakel Oct 21, 2026
5d8f335
fix(egress): correct proxy header validation condition
senamakel Oct 21, 2026
98ed104
Document live browser test toggle
senamakel Oct 21, 2026
8356f04
test(linked): cover enforced browser rejecting process-side reads wit…
senamakel Oct 21, 2026
3364507
fix(browser): reject process-side reads with a url under egress policy
senamakel Oct 21, 2026
f9476cd
docs(tinycomputer-bus): clarify minor version compatibility example
senamakel Oct 21, 2026
c33fb4b
fix(egress): validate lease while forwarding request bodies
senamakel Oct 21, 2026
f7a1514
refactor(browser): make ambient browser config check injectable
senamakel Oct 21, 2026
4b399e3
feat(egress): forward chunked request bodies to upstream
senamakel Oct 21, 2026
6436247
fix(egress): hoist chunk read length out of timeout future
senamakel Oct 21, 2026
e4d9682
test(egress): fix chunked upload assertion window size
senamakel Oct 21, 2026
10db35d
docs(egress): add README for the egress module
senamakel Oct 21, 2026
956342c
refactor(tinycomputer-browser): split linked tests into launch and li…
senamakel Oct 21, 2026
b6a757c
refactor(egress): extract chunked request body handling
senamakel Oct 21, 2026
22e42b5
refactor(egress): genericize forwarding over async read and write
senamakel Oct 21, 2026
c763e13
fix(egress): forward early upstream responses during uploads
senamakel Oct 21, 2026
43be533
test(egress): move request body tests into their own module
senamakel Oct 21, 2026
c51b452
refactor(egress): box the serve future before spawning
senamakel Oct 21, 2026
dbcd931
test(linked): update live test imports
senamakel Oct 21, 2026
a9e91db
Merge main into PR 150
senamakel Oct 21, 2026
0211f8f
refactor(egress): move request body handling into a body module
senamakel Oct 21, 2026
102c71b
refactor(egress): widen request body helper visibility
senamakel Oct 21, 2026
3cec61e
fix(egress): import write_all_bounded in request module
senamakel Oct 21, 2026
f462873
chore(browser): drop feature gate from action gate re-export
senamakel Oct 21, 2026
ee58766
test(egress): add chunked body tests and fix flaky egress test assert…
senamakel Oct 21, 2026
739db17
test(egress): update chunked body test import path
senamakel Oct 21, 2026
1f4ceb3
test(egress): ignore timeout result in revoked lease upload test
senamakel Oct 21, 2026
2e19215
test(linked): cover enforced launcher private session without implici…
senamakel Oct 21, 2026
b56d7a9
fix(egress): keep response future alive across upload completion
senamakel Oct 21, 2026
f68762d
test(egress): assert upload body is fully read in backpressure test
senamakel Oct 21, 2026
2848059
test(egress): read request body into pre-split buffer
senamakel Oct 21, 2026
6bc2734
test(egress): allow unwrap in chunked body tests
senamakel Oct 21, 2026
d9d2145
test(egress): use broadcast address for unreachable retry candidate
senamakel Oct 21, 2026
13561ce
test(egress): use loopback alias for unreachable address
senamakel Oct 21, 2026
901e495
fix(browser): keep egress proxy alive on transient accept errors
senamakel Oct 21, 2026
fbf5915
style(egress): format imports and function signature
senamakel Oct 21, 2026
6f53928
fix(browser): log proxy accept errors via log crate
senamakel Oct 21, 2026
3383a7e
chore(deps): add log dependency to lockfile
senamakel Oct 21, 2026
1233161
test(egress): harden retry test against port races
senamakel Oct 21, 2026
dc04ec8
fix(browser): revalidate lease while writing response to client
senamakel Oct 21, 2026
18af5d0
test(egress): move forward lease tests under egress_tests
senamakel Oct 21, 2026
9fcae36
test(browser_egress): relocate adapter tests into module directory
senamakel Oct 21, 2026
8a1c49a
test(egress): bind a reserved port for the unreachable address
senamakel Oct 21, 2026
6f6175a
test(egress): use port zero for unreachable retry candidate
senamakel Oct 21, 2026
be07779
test(egress): reserve unreachable port with bound socket in retry test
senamakel Oct 21, 2026
3e2b7ab
test(egress): collapse socket bind chain onto one line
senamakel Oct 21, 2026
25b179f
test(egress): inject connector to make retry test deterministic
senamakel Oct 21, 2026
2123fbd
refactor(egress): box serve future and widen connector visibility
senamakel Oct 21, 2026
a25738f
test(egress): remove redundant proxy stream unwrap
senamakel Oct 21, 2026
bda33ce
test(egress): shut down client before reading retry response
senamakel Oct 21, 2026
e99da0a
test(egress): stop unwrapping the service result in retry test
senamakel Oct 21, 2026
bb7840b
test(egress): remove premature client shutdown in retry test
senamakel Oct 21, 2026
7d3d6aa
refactor(egress): extract address connection retry into a helper
senamakel Oct 21, 2026
4450601
test(linked): cover closing an exited enforced browser
senamakel Oct 21, 2026
5a7ee95
fix(linked): allow close action when enforced browser has exited
senamakel Oct 21, 2026
074d966
refactor(egress): move egress tests into the egress module
senamakel Oct 21, 2026
38f1971
test(egress): register egress test submodules
senamakel Oct 21, 2026
753457b
refactor(browser_egress): move egress request types into a types module
senamakel Oct 21, 2026
a8da814
test(browser): wait for denied egress attempts in live tests
senamakel Oct 21, 2026
72c6706
style: reflow imports to satisfy rustfmt
senamakel Oct 21, 2026
88927e7
fix(egress): reject oversized chunk lines
senamakel Oct 21, 2026
cf0336b
test(egress): remove egress test module aggregator
senamakel Oct 21, 2026
4938977
fix(egress): validate lease during upstream request writes
senamakel Oct 21, 2026
131509c
fix(egress): share lease validation interval across request write phases
senamakel Oct 21, 2026
499ca17
Document egress launch environment restrictions
senamakel Oct 21, 2026
e0a0072
fix(egress): share lease validation schedule across request and response
senamakel Oct 21, 2026
b9480ab
fix(egress): drop unnecessary mut on validation interval
senamakel Oct 21, 2026
cf70a99
fix(egress): accept lease validation clock in initialize_upstream
senamakel Oct 21, 2026
ebbfb42
refactor(egress): match unit pattern in lease validation select arms
senamakel Oct 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ TINYCOMPUTER_LAB_SELF_EMAIL=
# TINYCOMPUTER_BROWSER_ARGS=--no-first-run
# TINYCOMPUTER_BROWSER_USER_AGENT=
# TINYCOMPUTER_BROWSER_ENDPOINT=http://127.0.0.1:9222
# Enforced browser egress refuses a launch if any of these ambient agent-browser
# variables are present. Unset them (including empty assignments) to use egress.
# AGENT_BROWSER_CDP=<unset>
# AGENT_BROWSER_AUTO_CONNECT=<unset>
# AGENT_BROWSER_PROVIDER=<unset>
# AGENT_BROWSER_ENGINE=<unset>
# AGENT_BROWSER_EXECUTABLE_PATH=<unset>
# AGENT_BROWSER_PROXY=<unset>
# AGENT_BROWSER_PROXY_BYPASS=<unset>
# AGENT_BROWSER_PROXY_USERNAME=<unset>
# AGENT_BROWSER_PROXY_PASSWORD=<unset>
# AGENT_BROWSER_PROFILE=<unset>
# AGENT_BROWSER_RESTORE=<unset>
# task_live: 1 shows the browser the task launches instead of running it
# headless (a headed run needs a display, so it runs on the host).
# TASK_HEADED=1
Expand Down Expand Up @@ -103,3 +116,5 @@ TINYCOMPUTER_LAB_SELF_EMAIL=
# TASK_SURFACE=desktop
# Opt-in live browser runs (see docs/technical/specs/unified-agent.md).
# TINYCOMPUTER_LIVE_BROWSER=1
# Compile and run the linked browser egress tests against installed Chromium.
# TINYCOMPUTER_LIVE_BROWSER_TESTS=1
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/tinycomputer-browser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ tinycomputer-cursor = { workspace = true }
url = { workspace = true }
# Per-session locks held across engine calls; `rt` for the runtime handle a
# blocking surface call runs the async browser on.
tokio = { workspace = true, features = ["sync", "rt", "time"] }
tokio = { workspace = true, features = ["sync", "rt", "time", "net", "io-util"] }
# Whether the process a Chrome profile lock names is alive.
sysinfo = { workspace = true }
# Report transient browser proxy listener errors without stopping the session.
log = { workspace = true }

# The linked engine, with the `agent-browser` feature. Without it the crate
# is the adapter alone, for hosts that bring their own `Launcher`.
Expand All @@ -50,7 +52,7 @@ default = []
agent-browser = ["dep:agent-browser"]

[dev-dependencies]
tokio = { workspace = true }
tokio = { workspace = true, features = ["test-util"] }

[lints]
workspace = true
22 changes: 20 additions & 2 deletions crates/tinycomputer-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,23 @@ through `SessionOptions::endpoint` instead of launching one. Closing an
attached session only disconnects. See `docs/technical/architecture.md` for how the
surface compares with the desktop's.

Tests that launch Chromium run in the Docker lab (`docs/technical/docker-lab.md`), never
on the host.
When the compiled TinyComputer module receives a host-private `browser.egress`
scope, it selects `EnforcedAgentBrowser`: every session must be explicitly
launched by TinyComputer, attaches and caller launch overrides are refused,
and the process uses an authenticated per-session loopback proxy. The proxy
Comment thread
senamakel marked this conversation as resolved.
Resolved
asks the host callback for TinySecurity's one-use, generation-bound dial
authorization and dials only the returned socket address. It periodically
validates active leases, including TLS CONNECT and WebSocket streams. HTTPS
contents remain opaque to the proxy and require TinySecurity's explicit
`OpaqueBrowserTraffic` classification. See
[`configuration.md`](../../docs/crates/tinycomputer/configuration.md#browser)
for the host contract and its privacy behavior.

The proxy internals and request-framing constraints are described in
[`src/egress/README.md`](src/egress/README.md).

The Chromium egress fixture tests are excluded from the default suite because
they need an installed browser; run them with
`TINYCOMPUTER_LIVE_BROWSER_TESTS=1 cargo test -p tinycomputer-browser --features agent-browser live_`.
They use local fixtures only. Other browser integration tests run in the Docker
lab (`docs/technical/docker-lab.md`).
10 changes: 10 additions & 0 deletions crates/tinycomputer-browser/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Selects opt-in browser tests at compile time.

fn main() {
println!("cargo:rustc-check-cfg=cfg(live_browser_tests)");
println!("cargo:rerun-if-env-changed=TINYCOMPUTER_LIVE_BROWSER_TESTS");

if std::env::var_os("TINYCOMPUTER_LIVE_BROWSER_TESTS").is_some() {
println!("cargo:rustc-cfg=live_browser_tests");
}
}
35 changes: 35 additions & 0 deletions crates/tinycomputer-browser/src/egress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Browser egress proxy

This module gives an explicitly launched Chromium session a private HTTP proxy
whose destination decisions come from the TinyComputer host callback. It keeps
the engine adapter (`EgressAuthorizer`) small: the host authorizes the parsed
destination, returns a one-use grant and exact socket addresses, consumes a
grant before each dial, and revalidates active leases.

## Structure

- `mod.rs` defines the public `BrowserDialTarget`, `DialGrant`,
`EgressAuthorizer`, and `EgressProxy` surface and owns the loopback listener.
- `request.rs` authenticates each local proxy client, parses HTTP proxy
requests, validates authorities and framing, and streams fixed-length and
chunked request bodies with bounded buffers.
- `forward.rs` writes sanitized upstream headers and forwards request and
response data while checking active leases.
- `serve.rs` sequences authorization, grant consumption, exact-address
connection, request forwarding, and response handling for one connection.

## Operational constraints

The proxy binds IPv4 loopback and requires Basic authentication with a random
per-session password. It never resolves destination names; it dials only an
address returned by the host and consumes the matching one-use grant first.
Only absolute `http` proxy requests, CONNECT requests, WebSocket upgrades,
fixed-length uploads, and valid HTTP/1.1 chunked uploads are accepted. Ambiguous
framing, caller-selected transfer encodings, unauthenticated clients, malformed
chunk framing, and bytes following a framed request body are refused.

HTTPS payloads remain opaque after CONNECT. The proxy checks the lease at least
once per second while uploading, tunneling, or receiving a response, and closes
the connection when validation is denied or fails. Do not add a direct-dial
fallback or locally resolve a host here: destination policy belongs to the
authenticated host callback.
35 changes: 35 additions & 0 deletions crates/tinycomputer-browser/src/egress/egress_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//! Listener lifecycle tests for the browser egress proxy.

#![allow(clippy::expect_used, clippy::unwrap_used)]

use std::io;
use tokio::net::{TcpListener, TcpStream};

mod authority_tests;
mod body_tests;
mod connect_tests;
mod forward_tests;
mod http_tests;
mod lease_tests;
mod lifecycle_tests;
mod retry_tests;
mod simulator;
mod websocket_tests;

#[tokio::test]
async fn an_accept_error_waits_then_allows_later_connections() {
let failed = super::accept_connection(std::future::ready(Err(io::Error::other(
"transient accept failure",
))))
.await;
assert!(failed.is_none());

let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let address = listener.local_addr().unwrap();
let client = TcpStream::connect(address);
let (accepted, connected) = tokio::join!(listener.accept(), client);
let accepted = super::accept_connection(std::future::ready(accepted)).await;

assert!(accepted.is_some());
connected.unwrap();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//! Authority parsing and redaction tests.

use crate::{BrowserDialTarget, DialGrant, egress::parse_authority};

#[test]
fn browser_dial_target_debug_does_not_disclose_session_or_destination() {
let target = BrowserDialTarget {
scheme: "https".into(),
hostname: "private.example.test".into(),
port: 443,
session_id: "private-browser-session".into(),
};
let debug = format!("{target:?}");
assert!(!debug.contains("private.example.test"));
assert!(!debug.contains("private-browser-session"));
assert!(debug.contains("REDACTED"));
}

#[test]
fn dial_grant_debug_does_not_disclose_lease_or_destination() {
let grant = DialGrant {
lease: "private-opaque-nonce".into(),
addresses: vec!["203.0.113.77:8443".parse().unwrap()],
};
let debug = format!("{grant:?}");
assert!(!debug.contains("private-opaque-nonce"));
assert!(!debug.contains("203.0.113.77"));
assert!(debug.contains("REDACTED"));
}

#[test]
fn proxy_authority_uses_scheme_defaults_and_canonical_ipv6_literals() {
assert_eq!(
parse_authority("example.test", "http", "session")
.unwrap()
.port,
80
);
assert_eq!(
parse_authority("example.test", "https", "session")
.unwrap()
.port,
443
);
let ipv6 = parse_authority("[2001:4860:4860::8888]:443", "https", "session").unwrap();
assert_eq!(ipv6.hostname, "2001:4860:4860::8888");
assert!(parse_authority("https://example.test:443", "https", "session").is_err());
}
Loading
Loading