[edge] Fetch: accept up to 1000 informational heads (Go has no count limit); KD-10 beyond

This commit is contained in:
2026-11-07 16:41:41 +01:00
parent 8c04b0f4bd
commit 27b0a165b2
3 changed files with 37 additions and 3 deletions
+4 -2
View File
@@ -28,8 +28,10 @@ pub struct Fetched {
/// Dial timeout, matching Caddy's reverse_proxy default. /// Dial timeout, matching Caddy's reverse_proxy default.
pub const DIAL_TIMEOUT: Duration = Duration::from_secs(3); pub const DIAL_TIMEOUT: Duration = Duration::from_secs(3);
/// More 1xx heads than this before a final answer is treated as a broken server. /// More 1xx heads than this before a final answer is treated as a broken server. Go (and so
const MAX_INFORMATIONAL: usize = 8; /// 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 { pub fn peer(addr: SocketAddr, u: &UpstreamRt) -> HttpPeer {
let mut p = HttpPeer::new(addr, u.tls, u.sni.clone()); let mut p = HttpPeer::new(addr, u.tls, u.sni.clone());
+24
View File
@@ -505,6 +505,21 @@ pub fn corpus() -> Vec<Case> {
a, a,
Req::get(a, "/").header("cookie", &session("continue-ok")), 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( https(
"auth answers 2xx with a 5 MB body", "auth answers 2xx with a 5 MB body",
a, a,
@@ -734,6 +749,15 @@ pub const KNOWN_DIVERGENCES: &[Divergence] = &[
}, },
reason: "as KD-8, on the plain-HTTP listener", 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 { impl Outcome {
+9 -1
View File
@@ -11,7 +11,8 @@
//! - `Authorization: Bearer good` → 200 with identity; any other Authorization → 401 + WWW-Authenticate //! - `Authorization: Bearer good` → 200 with identity; any other Authorization → 401 + WWW-Authenticate
//! - cookie `authelia_session=good` → 200 with identity; `nameless` → 200 without identity; //! - cookie `authelia_session=good` → 200 with identity; `nameless` → 200 without identity;
//! `forbidden` → 403 //! `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), //! `big-deny` (200 / 401 with a 5 MB body), `truncated-ok` (200 whose body is cut short),
//! `switch` (101 Switching Protocols), `hang` (never answers) //! `switch` (101 Switching Protocols), `hang` (never answers)
//! - otherwise GET/HEAD → 302 to the portal with `rd`, other methods → 401 //! - 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.extend(allowed(true));
b 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" => { "big-ok" => {
let mut hs: Vec<(&str, &str)> = vec![("X-Sent-Content-Type", "none")]; let mut hs: Vec<(&str, &str)> = vec![("X-Sent-Content-Type", "none")];
hs.extend(IDENTITY); hs.extend(IDENTITY);