Skip to content

fix(start-os): bound service-side TLS establishment - #3869

Merged
dr-bonez merged 2 commits into
masterfrom
fix/tls-config-resolution-timeout
Sep 3, 2026
Merged

fix(start-os): bound service-side TLS establishment#3869
dr-bonez merged 2 commits into
masterfrom
fix/tls-config-resolution-timeout

Conversation

@helix-nine

@helix-nine helix-nine commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Cap the ordinary backend TCP connect and optional service-side TLS handshake at one shared 15-second deadline.
  • Preserve source-preserving transparent-connect setup and fallback behavior outside that deadline.
  • Add a paused-time regression test for a backend that accepts TCP and never speaks TLS.
  • Document the observable timeout in the StartOS interface guide and changelog.

Why

TLS listener phase 2 resolves the service-side connection before completing the client handshake. A service could accept TCP and then never answer its own TLS handshake, leaving the client parked indefinitely and retaining both sockets in the listener's in-progress set.

The deadline belongs inside ProxyTarget::preprocess, around backend establishment. Bounding all TLS config resolution would also cancel ACME certificate work and root-CA state updates, so those remain outside it.

Verification

  • cargo test -p start-core upstream_alpn_tests --features=test
  • cargo test -p start-core --features=test --lib — 750 passed, 3 ignored
  • cargo check -p start-core --features=test --all-targets
  • make start-core-format-check
  • Prettier checks for the changelog and interface guide
  • Taplo check for shared-libs/crates/start-core/Cargo.toml
  • projects/start-docs/build.sh
  • Timeout ablation: replacing the deadline wrapper with a direct await makes the regression test fail on its outer guard

cargo check -p start-os --all-targets reaches the existing embedded-UI prerequisite and cannot run in this checkout because projects/start-os/web/dist/static/{ui,setup-wizard} has not been built.

Closes #3776

@helix-nine
helix-nine force-pushed the fix/tls-config-resolution-timeout branch from 5177680 to 74bab80 Compare September 2, 2026 22:02
@helix-nine helix-nine changed the title fix(start-os): bound TLS config resolution so a mute container cannot park a client fix(start-os): bound service-side TLS establishment Sep 2, 2026
@helix-nine
helix-nine marked this pull request as ready for review September 2, 2026 22:03
Comment on lines +1272 to +1276
let deadline = tokio::time::Instant::now() + BACKEND_DIAL_TIMEOUT;
let stream = with_backend_deadline(deadline, self.addr, TcpStream::connect(self.addr))
.await?
.with_ctx(|_| (ErrorKind::Network, self.addr))
.log_err()
.log_err()?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just tokio::time::timeout??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No good reason for the wrapper. I removed it and now use Tokio’s timeout API directly at both awaits. I kept timeout_at rather than two independent timeout calls so the ordinary TCP connect and optional TLS handshake share one 15-second budget instead of each receiving 15 seconds. Rebased and re-ran the ALPN tests plus the start-core all-targets check in ab81885.

Apply one 15-second deadline to the backend TCP connect and optional service-side TLS handshake so a service that accepts TCP without speaking TLS cannot park the client indefinitely. Preserve transparent-connect fallback behavior outside the new deadline.
@helix-nine
helix-nine force-pushed the fix/tls-config-resolution-timeout branch from 74bab80 to ab81885 Compare September 2, 2026 23:40
@helix-nine

Copy link
Copy Markdown
Contributor Author

Thanks. The approved head is ab81885; CI is still running.

@dr-bonez
dr-bonez merged commit ae0e00f into master Sep 3, 2026
32 checks passed
@dr-bonez
dr-bonez deleted the fix/tls-config-resolution-timeout branch September 3, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vhost: a container that accepts TCP but never completes TLS parks the client's handshake forever

2 participants