Repository navigation
fix xss issue - #24071
Open
rishabh-gupta-hashicorp wants to merge 2 commits into
Open
fix xss issue#24071rishabh-gupta-hashicorp wants to merge 2 commits into
rishabh-gupta-hashicorp wants to merge 2 commits into
Conversation
Contributor
Go Test Coverage: 67.0%Patch coverage: 100.0% (1/1 changed lines covered) See the workflow run for the full per-package breakdown and downloadable HTML report. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24071 +/- ##
==========================================
+ Coverage 56.64% 62.22% +5.58%
==========================================
Files 1068 1060 -8
Lines 129948 129338 -610
==========================================
+ Hits 73612 80484 +6872
+ Misses 49554 41383 -8171
- Partials 6782 7471 +689 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rashmirathi-2
force-pushed
the
rishabh-gupta/fix-max-stale-xss
branch
from
October 27, 2026 20:04
6292344 to
a5cd35f
Compare
This branch has not been deployed
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.
Description
An invalid
?max_stale=value is echoed back in the 400 error (Invalid max_stale value "<input>") without an explicitContent-Type. If an operator setsContent-Typethroughhttp_config.response_headers(for exampletext/html), that header is applied to this response, so the browser renders the reflected input as HTML (reflected XSS).This sets
Content-Type: text/plain; charset=utf-8on that error response before it is written, matching the other error paths inwrap()(#21704). Valid requests are unaffected.Testing & Reproduction steps
Reproduce:
http_config { response_headers { "Content-Type" = "text/html" } }./v1/catalog/nodes?max_stale=<img src=x onerror=alert(1)>in a browser.text/htmland the script runs. After it, the response istext/plainand the payload is shown as text.Tests:
TestParseConsistency_InvalidMaxStaleContentType.go test ./agent/ -run 'TestParseConsistency_InvalidMaxStaleContentType$' -count=1: fails without the fix (actual: "text/html"), passes with it.go test ./agent/ -run 'TestParseConsistency|TestErrorContentTypeHeaderSet$|TestHTTPAPIResponseHeaders$|TestHTTPAPIValidateContentTypeHeaders$|TestUIResponseHeaders$|TestContentTypeIsJSON$' -count=1: passed.go vet ./agent/: passed.Links
Content-Typeon error responses)PR Checklist
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.