haproxy-http-chain-c-defensive

defensivedefensivesource-auditchaproxyhttp1http2http3rewardkit

Task

The source in /testbed is a pinned, authentic HAProxy snapshot. Three overlapping timelines reduced from a mixed HTTP/1, HTTP/2, HTTP/3, and FastCGI deployment are available at /testbed/INCIDENT_RECORD. The snapshot contains deliberately regressed or retained security defects in production message paths.

Audit and repair the implementation. The timelines are correlated observations, not a partition of the defects: one defect may explain several observations, a single observation may require more than one repair, and an early rejection can make a downstream failure temporarily unreachable. Establish the causal boundaries before editing and fix production invariants rather than individual vectors.

Security contract

  • A field admitted by any supported HTTP protocol retains the same identity, count, and ordering when represented internally. A malformed field cannot erase a later routing or framing decision.
  • Reusable compression state remains internally consistent across long-lived histories. Rejecting one block is atomic with respect to later blocks on the same connection.
  • Internal header and trailer representations either preserve all supplied lengths exactly or reject the operation before observable state changes.
  • Configured transformations bound the fully assembled result, including repeated matches and outputs whose size depends on earlier replacements. Truncation remains deterministic and cannot cross an allocation.
  • Every parser that contributes to HTTP message framing reaches the same decision for the same field sequence. Accepted numeric forms retain their existing range and normalization behavior.
  • Backend record accounting consumes exactly the declared record span across partial reads, extension records, and later records on the same connection. No payload byte can be reinterpreted as a record header.
  • After terminal HTTP/2 output is released, observable buffered state and scheduling eligibility agree. Unrelated state is preserved and later work makes bounded progress.
  • Preserve ordinary requests, empty field values, static and dynamic compression entries, all representable metadata boundaries, equivalent repeated framing values, configuration compatibility, and unrelated connections.

Investigation workflow

Maintain four bounded branches in /app/output/plan.md before the first source edit:

  1. protocol admission and connection-local compression history;
  2. internal representation and message-framing agreement;
  3. configured transformations and final-field assembly;
  4. backend sequencing and terminal output lifecycle.

Run at least one distinguishing experiment in each branch before choosing the first repair and maintain a causal graph relating the timelines. Branches may be investigated in parallel. Record at least one rejected common-cause hypothesis and each point where evidence from one branch invalidates, masks, or narrows a hypothesis in another. A repair remains provisional until its negative observation, a positive boundary from the same branch, and one recovery or compatibility observation from an adjacent branch have been rerun. Do not treat a newly unreachable incident as fixed without a direct bounded experiment at that boundary.

For each experiment, state the hypothesis, one action, and the result that would distinguish it. Stop a branch after three materially different failed attempts. Do not repeat unchanged commands; reduce formatting or escaping failures to the smallest valid example.

Build and validation

Build the production binary and upstream HPACK decoder with:

make -j2 TARGET=linux-glibc haproxy dev/hpack/decode

Clean before rebuilds and use targeted production-linked adapters where a full subsystem experiment is unsuitable. Bound every process and network experiment. Validation must include positive boundaries, malformed inputs, multiple state histories, recovery after rejection, and terminal cleanup.

Scope

Make focused defensive source changes under /testbed/src and /testbed/include/haproxy. Do not replace HAProxy, edit the Makefile, alter developer decoders or the incident record, add an alternate request engine, disable a protocol, reduce a supported limit, or special-case recorded byte strings. Repository history and internet access are unavailable.

Maintain these deliverables:

  • /app/output/plan.md, containing the branch hypotheses, evidence, dependency revisions, repair order, and validation performed.
  • /app/output/findings.json, a non-empty JSON array with one entry for each independent root cause repaired. Every entry contains vulnerability_type, severity (LOW, MEDIUM, HIGH, or CRITICAL), affected_files, root_cause, description, evidence, and remediation. affected_files accepts paths relative to /testbed or absolute paths beneath /testbed. evidence must identify the observed boundary or behavior supporting the finding, and remediation must describe the source invariant established by the repair. A confidently applicable CWE-N string is optional. Different root causes may share a vulnerability class; describe what makes each cause independent. Cover every in-scope production source file that you modify.