Skip to content

Proxy error hardening: 502/504 before commit, truncation integrity, quieter expected failures - #1083

Merged
justcoding121 merged 11 commits into
developfrom
fix/proxy-error-hardening
Oct 7, 2026
Merged

justcoding121 merged 11 commits into
developfrom
fix/proxy-error-hardening

Conversation

@justcoding121

Copy link
Copy Markdown
Owner

Summary

Hardens proxy error handling found in a real Inspector session log (browser-visible protocol errors and log noise).

  • Expected failures (DNS miss, reset, cancel, ALPN reject) log one Debug line; stack at Trace. Per-host handshake-abort throttle.
  • Origin failures before any response byte now answer 502/504 (fast path, session path, H2-to-H1.1 bridge) instead of a silent close.
  • Response-header deadline is honoured on the H1 fast path and the H2-to-H1.1 bridge.
  • Truncated origin bodies (short Content-Length) are no longer rewritten as complete: client connection closed / 502 / RST_STREAM.
  • Stale pooled keep-alive replay once in the H2-to-H1.1 bridge (idempotent, bodiless only).
  • Opaque CONNECT tunnels (Inspector) dial first so DNS/refusal returns 502; the connection is reused.
  • Inspector: stale root CA detection and one-click cleanup; SKI/AKI on new roots.
  • H3 drain stall fix; H2 origin-death audit test.
  • Docs: wiki and website troubleshooting.

Tests

Regression-2026-10-07 tests for each error type: origin-failure matrix, bridge 504/502/RST/replay, H3+TCP dead (bounded 502, capability evicted), ALPN rejected, stale-root predicate and cleanup command.

Full suites: Unit 3 failures, Integration 3 failures (all environmental: chain-building error x2 and Nested_Proxy_Farm... which also fails on the base commit; one timing flake passes in isolation x5). Inspector, CLI, Configuration suites green.

Performance

Counterbalanced paired A/B vs base (mitm-http2-to-http1, https-mitm, reverse-http1-mitm, c=64): within noise, no RSS delta. New checks on the hot path are config comparisons only; the one new loop check in CopyBytesToStream is a single compare after the loop.

… breaker, log accuracy

- Answer 502/504 on H1 origin failure before the client response is committed
- Circuit breaker + decrypt bypass for clients that reject the MITM certificate
- Timeout log names the configured limit; QUIC shutdown noise at Trace
- Bridges map ProxyTimeoutException to 504
- Regression-2026-10-07 tests
…ts; stale root cleanup

- H2->H1.1 bridge replays a bodiless idempotent request once on a fresh connection when a reused origin socket was closed
- New roots carry SKI; leaves carry AKI only when the issuer has an SKI
- Inspector: Remove old root CAs command (same-CN roots except the current one)
- H3 origin session dispose and H2 relay origin-death regression tests (no defect reproduced)
- Troubleshooting docs for 502/504 and client-reject bypass
…g the host in the URL column

Showing since on every non-empty list made HH:mm ambiguous once a capture crossed midnight, so add the date when the oldest session is not from today. The previous commit also broke SessionPipelineTests, which still expected a bare Sessions: N, and added a redundant count refresh after Session retention.

The URL column repeated the Host column. Show path and query instead (non-default port kept, CONNECT shows the port), with the full URL in the tooltip, Ctrl+C, sorting and search.
…s > Columns

Add a column chooser (header right-click and Options > Columns) with Reset columns. New optional Started, Scheme and Content-Type columns are hidden by default; URL always stays visible. Visibility persists immediately in the saved grid layout, hiding the sorted column falls back to Id ascending, and the default grid is unchanged.
…tle, CONNECT 502 for opaque tunnels

Replay of 100 rapid tabs + sanity browse after the earlier hardening showed
the log was dominated by repeated stack traces for expected failures
(9.6 MB, 6.3 MB of it 'Client session cancelled') and opaque tunnels still
answered CONNECT 200 then silently closed on DNS/refusal.

- ProxyDiagnostics: expected exceptions log one Debug summary line; the
  stack moves to Trace. ReportCaught applies the same rule.
- Happy Eyeballs and 'connection setup FAILED' lines: summary at Debug.
- ProxyLog.ClientHandshakeAborted: per-host 10 s throttle (bounded table).
- ExplicitClientHandler: an opaque tunnel reuses the connection dialed for
  EstablishServerConnectionBeforeResponse instead of dialing twice.
- Inspector: opaque tunnels dial before CONNECT 200 (browser shows
  ERR_TUNNEL_CONNECTION_FAILED with a 502 instead of a bare close).
- Tests: Regression-2026-10-07 log-shape, throttle, opaque 502 and reuse.
- Docs: troubleshooting (website + wiki).
… a filter

The DataGrid resets its scroll offset when the session list is swapped for a filter change. That was read as the user scrolling away, which paused follow-latest and left the grid mid-list. Ignore scroll changes during a list swap and resume follow when the list is empty or fits on screen.
…sible

A CONNECT target has no path, so the URL cell is empty (host:port stays in the tooltip) instead of a stray :443. Because URL shows only the path and Host shows the host, both columns are pinned in the column chooser. Host column default width is wider so long names do not run into the next column.
…n fast paths

A short Content-Length read from the origin no longer rewrites the length to look complete: the fast paths keep the declared length and close the client connection, and the HTTP/2 bridge fails the exchange (502 or RST_STREAM). The H1 fast path and the HTTP/2 bridge now apply ResponseHeaderTimeoutSeconds and the per-session timeout, so a stalled origin yields a 504 instead of hanging. Adds origin-failure integration tests with a scripted TLS origin.
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

@justcoding121
justcoding121 merged commit ed0a63e into develop Oct 7, 2026
22 checks passed
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