diff --git a/crates/edge/src/fetch.rs b/crates/edge/src/fetch.rs index ee9e900..c6700eb 100644 --- a/crates/edge/src/fetch.rs +++ b/crates/edge/src/fetch.rs @@ -28,8 +28,10 @@ pub struct Fetched { /// Dial timeout, matching Caddy's reverse_proxy default. pub const DIAL_TIMEOUT: Duration = Duration::from_secs(3); -/// More 1xx heads than this before a final answer is treated as a broken server. -const MAX_INFORMATIONAL: usize = 8; +/// More 1xx heads than this before a final answer is treated as a broken server. Go (and so +/// Caddy) has no count limit, only one on total header bytes; 1000 heads accepts anything a +/// real server sends, and the overall deadline bounds the rest. +const MAX_INFORMATIONAL: usize = 1000; pub fn peer(addr: SocketAddr, u: &UpstreamRt) -> HttpPeer { let mut p = HttpPeer::new(addr, u.tls, u.sni.clone()); diff --git a/tests/diff/src/lib.rs b/tests/diff/src/lib.rs index 20b82be..8e10311 100644 --- a/tests/diff/src/lib.rs +++ b/tests/diff/src/lib.rs @@ -505,6 +505,21 @@ pub fn corpus() -> Vec { a, Req::get(a, "/").header("cookie", &session("continue-ok")), ), + https( + "auth answers 9 informational heads first", + a, + Req::get(a, "/").header("cookie", &session("continue-x9")), + ), + https( + "auth answers 1000 informational heads first", + a, + Req::get(a, "/").header("cookie", &session("continue-x1000")), + ), + https( + "auth answers 1001 informational heads first", + a, + Req::get(a, "/").header("cookie", &session("continue-x1001")), + ), https( "auth answers 2xx with a 5 MB body", a, @@ -734,6 +749,15 @@ pub const KNOWN_DIVERGENCES: &[Divergence] = &[ }, reason: "as KD-8, on the plain-HTTP listener", }, + Divergence { + id: "KD-10", + rule: Rule::Status { + case: "auth answers 1001 informational heads first", + ianitor: 502, + caddy: 200, + }, + reason: "edge fails closed after 1000 informational heads from the auth server; Go limits only their total header bytes", + }, ]; impl Outcome { diff --git a/tests/support/src/authelia.rs b/tests/support/src/authelia.rs index 90ac385..6293ebe 100644 --- a/tests/support/src/authelia.rs +++ b/tests/support/src/authelia.rs @@ -11,7 +11,8 @@ //! - `Authorization: Bearer good` → 200 with identity; any other Authorization → 401 + WWW-Authenticate //! - cookie `authelia_session=good` → 200 with identity; `nameless` → 200 without identity; //! `forbidden` → 403 -//! - misbehaving answers, by cookie: `continue-ok` (100 Continue, then 200), `big-ok` / +//! - misbehaving answers, by cookie: `continue-ok` (100 Continue, then 200), `continue-xN` +//! (N × 102 Processing, then 200), `big-ok` / //! `big-deny` (200 / 401 with a 5 MB body), `truncated-ok` (200 whose body is cut short), //! `switch` (101 Switching Protocols), `hang` (never answers) //! - otherwise GET/HEAD → 302 to the portal with `rd`, other methods → 401 @@ -106,6 +107,13 @@ fn decide(req: &Recorded) -> Reply { b.extend(allowed(true)); b } + s if s.starts_with("continue-x") => { + // `continue-xN`: N informational heads (102 Processing), then 200. + let n: usize = s["continue-x".len()..].parse().unwrap_or(1); + let mut b = b"HTTP/1.1 102 Processing\r\n\r\n".repeat(n); + b.extend(allowed(true)); + b + } "big-ok" => { let mut hs: Vec<(&str, &str)> = vec![("X-Sent-Content-Type", "none")]; hs.extend(IDENTITY);