-
Notifications
You must be signed in to change notification settings - Fork 251
fix: harden CSRF protections #6186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
67c52c5
fix: disable data explorer query/script execution from URL params
alespour c9cd31d
fix: cookie hardening
alespour 8350c4b
fix: require XMLHttpRequest header on query execution endpoints
alespour 5523856
fix: add SAMEORIGIN and CORP response headers
alespour d11e009
fix: enforce same-origin on unsafe session-authenticated requests
alespour d75e19b
fix: add missing files
alespour 7ebbfda
fix: require XMLHttpRequest header for flux proxy GET
alespour 38ea6f7
test(e2e): inject same-origin headers into unsafe cy.request calls
alespour 3e80203
test(e2e): fix flaky DB name check in explore_influxql
alespour 39e8522
docs: update CHANGELOG
alespour 96fe10b
fix: force X-Requested-With header in AJAX requests
alespour 0a79a28
fix: ensure security headers are set on blocked same-origin requests
alespour 2ac02d1
test: use oauth2.DefaultCookieName in same-origin middleware tests
alespour 1f468aa
fix: same origin also compares scheme and port
alespour 1ed2913
fix: secure cookies
alespour ec44334
refactor(ui): remove unused withRouter from DataExplorer
alespour f4dc2b4
test: fix regexp
alespour c14a0b3
style: go fmt
alespour ea3e1c6
style: formatting
alespour d01989f
test(oauth2): cover secure cookie flag in NewCookieJWT
alespour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package server | ||
|
|
||
| import ( | ||
| "net/http" | ||
|
|
||
| "github.com/influxdata/chronograf" | ||
| ) | ||
|
|
||
| const ( | ||
| requestedWithHeaderName = "X-Requested-With" | ||
| xmlHttpRequestHeaderValue = "XMLHttpRequest" | ||
| ) | ||
|
|
||
| // RequireRequestedWithXMLHttpRequest rejects requests that do not include | ||
| // X-Requested-With: XMLHttpRequest. | ||
| func RequireRequestedWithXMLHttpRequest( | ||
| logger chronograf.Logger, | ||
| next http.Handler, | ||
| ) http.Handler { | ||
| return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if r.Header.Get(requestedWithHeaderName) != xmlHttpRequestHeaderValue { | ||
| logger. | ||
| WithField("component", "request_header_guard"). | ||
| WithField("remote_addr", r.RemoteAddr). | ||
| WithField("method", r.Method). | ||
| WithField("url", r.URL). | ||
| Error("Missing or invalid X-Requested-With header") | ||
| Error(w, http.StatusForbidden, "missing required X-Requested-With header", logger) | ||
| return | ||
| } | ||
|
|
||
| next.ServeHTTP(w, r) | ||
| }) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.