web: set the configured headers on rate limited responses - #440
Open
mrueg wants to merge 1 commit into
Open
Conversation
The rate limiter was checked before the loop that applies http_server_config.headers, so a 429 was written without them. A request that was served carried the operator's Strict-Transport-Security, Content-Security-Policy and X-Frame-Options, and a request from the same client a moment later did not. A header policy is meant to hold for every response from the endpoint, so apply the headers first and turn the request away afterwards. Note when testing this by hand that X-Content-Type-Options hides the difference: http.Error sets nosniff itself, so it was present on the 429 either way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Manuel Rüger <manuel@rueg.eu>
mrueg
force-pushed
the
fix/security-headers-on-rate-limited-responses
branch
from
September 2, 2026 13:44
4be8058 to
12cc1db
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rate limiter is checked before the loop that applies
http_server_config.headers, so a 429 is written without them. A request that is served carries the operator'sStrict-Transport-Security,Content-Security-PolicyandX-Frame-Options; a request from the same client a moment later does not.A header policy is meant to hold for every response from the endpoint, so apply the headers first and turn the request away afterwards.
One note for anyone checking this by hand:
X-Content-Type-Optionshides the difference, becausehttp.Errorsetsnosniffitself, so it was present on the 429 either way. The test usesX-Frame-OptionsandStrict-Transport-Security.Tests
Added a test that spends a burst of 1, then compares the headers on the served response with those on the rate-limited one. It fails against master with both headers empty.
🤖 Generated with Claude Code