Skip to content

test(e2e): read the status line in the h1 unselectable-000 guard - #1394

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
fix/h1-security-000-guard
Sep 21, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
fix/h1-security-000-guard

Conversation

@FlorentinDUBOIS

Copy link
Copy Markdown
Collaborator

Closes cause C of #1393.

The defect

test_h1_custom_answer_with_out_of_range_status_does_not_kill_the_worker asserted that an unrouted
request drew the builtin 404 and not the operator's out-of-range 000 answer, with
!stray_answer.contains("000") — a substring scan of the whole response.

raw_read_all returns everything, and the builtin 404 repeats a Crockford base32 ULID twice: once
in the Sozu-Id response header, once in the request_id field of the HTML body. Roughly one ULID
in twenty carries the substring 000, so a perfectly correct answer reddened the guard.

It fired on 2026-09-19, job 105898321274
(check fips, head 5cb5395e), on:

HTTP/1.1 404 Not Found ... Sozu-Id: 01M2WV005MHC6FDKVS19000JFY ... "request_id": "01M2WV005MHC6FDKVS19000JFY"

The request immediately before it drew 01M2WV005JRA3CXKWPPESY3TCR and passed. A defect in the
assertion, not in sōzu.

The change

The guard becomes a named predicate, with both conjuncts scoped to the status line:

fn builtin_404_answer_selected(answer: &str) -> bool {
    let status_line = answer.split_once("\r\n").map_or(answer, |(line, _)| line);
    status_line.starts_with("HTTP/1.1 404") && !status_line.starts_with("HTTP/1.1 000")
}

Neither conjunct is deleted. The positive one is byte-identical. The negative one now states what
the surrounding comment already claimed it meant.

Red-then-green

A regression test that waited for an unlucky ULID would detect nothing, so it is pinned to the exact
answer that failed in CI — Sozu-Id and the body request_id both carrying
01M2WV005MHC6FDKVS19000JFY. Against the historical predicate body:

panicked at e2e/src/tests/h1_security_tests.rs:2204:5:
a builtin 404 whose ULID carries the digits 000 is still a builtin 404
test result: FAILED. 0 passed; 1 failed

and against the fixed one, test result: ok. 1 passed; 0 failed. Three further assertions pin the
passing neighbour draw, the operator's own HTTP/1.1 000 answer (which must still be rejected —
this is what stops the mutation being "repaired" by deleting the negative conjunct), and a
CRLF-less truncated line.

The owning e2e test now reports builtin_answer_selected=true on all three harness iterations.

Reference sweep

contains("<digits>") in e2e/ splits into two shapes. The absence-asserting form
(… && !x.contains("NNN")), which a ULID collision turns into a spurious red, has exactly one hit
repo-wide — this one. The ~75 presence-asserting hits across five files are the opposite failure
mode: a ULID carrying the digits can only make a wrong status read as right, never produce a flaky
red. They are left as found and noted in #1393 as a separate latent class.

Scope

One file, test-only. No behaviour, route, metric, configuration key or CLI flag moves, so neither
doc/ nor CHANGELOG.md has anything to restate.

`test_h1_custom_answer_with_out_of_range_status_does_not_kill_the_worker`
asserted that an unrouted request drew the builtin 404 and not the
operator's out-of-range `000` answer with `!stray_answer.contains("000")`,
a substring scan of the WHOLE response. The builtin 404 repeats a Crockford
base32 ULID in its `Sozu-Id` header and again in the `request_id` field of
its HTML body, and roughly one ULID in twenty carries the substring `000`,
so a perfectly correct answer reddened the guard: CI job 105898321274
(check `fips`, head `5cb5395e`, 2026-09-19) failed on
`HTTP/1.1 404 Not Found ... Sozu-Id: 01M2WV005MHC6FDKVS19000JFY`, while the
request immediately before it drew `01M2WV005JRA3CXKWPPESY3TCR` and passed.
That is cause C of #1393, a defect in the assertion and not
in sozu.

Extract the guard as `builtin_404_answer_selected` and scope both conjuncts
to the status line. The positive `HTTP/1.1 404` conjunct is unchanged; the
negative one now states what it always meant -- that the status line is not
`HTTP/1.1 000` -- instead of scanning headers and body for three digits.

`the_unselectable_000_guard_reads_the_status_line_not_the_whole_answer`
exercises the predicate directly against the captured failing answer, so
the regression no longer waits on an unlucky draw, and against the
operator's own `000` answer, so the negative conjunct cannot be repaired by
deleting it.

Signed-off-by: Florentin Dubois <[email protected]>
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