Skip to content

Tests: added add_header/add_trailer field sanitization test. - #58

Draft
louzt wants to merge 3 commits into
nginx:masterfrom
louzt:upstream/response-filter-sanitize-tests
Draft

Tests: added add_header/add_trailer field sanitization test.#58
louzt wants to merge 3 commits into
nginx:masterfrom
louzt:upstream/response-filter-sanitize-tests

Conversation

@louzt

@louzt louzt commented May 31, 2026

Copy link
Copy Markdown

Summary

This is the standalone nginx-tests regression for the add_header and add_trailer value sanitization in nginx#1414.

Why

The companion test now focuses on the runtime concern worth shipping first: invalid value bytes (NUL, CR, LF) in computed add_header and add_trailer values must not produce malformed serialized fields.

Field-name validation is intentionally out of scope for this test and remains a separate config-time concern, per the maintainer direction from 2026-06-21 that field names are static and cannot be attacker-controlled, so runtime value sanitization is the concern worth shipping first.

What changed

  • keeps the existing add_header/add_trailer CRLF value cases;
  • asserts that the response stays 200 OK after a CRLF-bearing value reaches the response filter;
  • asserts that the original header still serializes with the sanitized value;
  • asserts that no injected X-Injected field line is emitted;
  • keeps the usual no alerts and no sanitizer errors checks from Test::Nginx.

Patch shape

1 file changed, 79 insertions(+)

Validation

  • current nginx/nginx master: header_filter_sanitize.t fails 3/6;
  • patched branch for the companion C change: header_filter_sanitize.t passes 6/6;
  • ASAN/UBSAN build of the patched branch: header_filter_sanitize.t passes 6/6.

Risks / Follow-ups

This test intentionally follows the value-sanitize-only policy of nginx#1414. If upstream chooses a different late response-filter policy, the assertions should be updated to match that final design.

Field-name handling remains a separate config-time validation concern that can be added independently if maintainers prefer that boundary.

@louzt

louzt commented May 31, 2026

Copy link
Copy Markdown
Author

Companion nginx/nginx draft: nginx/nginx#1414

@louzt louzt changed the title Tests: added header filter sanitization test. Tests: added add_header/add_trailer field sanitization test. May 31, 2026
louzt and others added 3 commits August 7, 2026 15:04
Per DemiMarie directive 2026-06-21 (nginx#1414 review): 'Validating the
names can be dropped from this PR. Validating the values is much more
important, as the names are static and so cannot be attacker-controlled.'

The c09e7fe skip-names commit was dropped from the source worktree
(upstream/response-filter-sanitize @ b3134bc1c). The 6 bad-name
assertions in this test file (locations /bad-name-header/ and
/bad-name-trailer/ + 6 like/unlike assertions) test behavior that no
longer exists in the source. With c09e7fe removed, X:Bad is correctly
emitted (no skip), so the 'skips invalid field name' assertions
unavoidably fail.

Stripped them, plan from 12 → 6 user tests. With Test::Nginx framework
auto-tests (no alerts, no sanitizer errors) total = 8/8 PASS.

Validation evidence archived in docs/branch-metrics.md under
'Phase 2 Step 6 — nginx#1414 rebase validation'.
@louzt
louzt force-pushed the upstream/response-filter-sanitize-tests branch from cd58799 to 972819d Compare August 7, 2026 22:34
@louzt

louzt commented Aug 7, 2026

Copy link
Copy Markdown
Author

Rebased onto current master and dropped the bad-name feature reference per Demi's 2026-06-21 direction that field names are static. Body now reflects the value-sanitize-only scope and 6/6 test pass on the patched branch. Lab notes: https://gist.github.com/louzt/7bdf370a28126718e7e7b69d53b0ae86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants