Skip to content
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

Align Orign and Host header #14970

Merged
merged 2 commits into from
Mar 11, 2024
Merged

Align Orign and Host header #14970

merged 2 commits into from
Mar 11, 2024

Conversation

chrismeyersfsu
Copy link
Member

SUMMARY
  • Before this change the Host: header was runserver. Seems to be set by nginx upstream flow.

  • After this change we explicitly set the Host: header

  • More about CSRF checks ... CSRF checks that Origin == Host. Think about how the browser works.

    "I'm executing javascript that I downloaded from awx.com (ORIGIN) and I'm making an XHR POST request to awx.com (HOST)" Server verifies; Host: header == Origin: header; OK!

    vs. the malicious case.

    "I'm executing javascript that I downloaded from google.com (ORIGIN) and I'm making an XHR POST request to awx.com (HOST)" Server verifies; Host: header != Origin: header; NOT OK!

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API
AWX VERSION
devel
ADDITIONAL INFORMATION

* Before this change the Host: header was runserver. Seems to be set by
  nginx upstream flow.
* After this change we explicitly set the Host: header
* More about CSRF checks ...
  CSRF checks that Origin == Host. Think about how the browser works.

  <browser goes to awx.com>
  "I'm executing javascript that I downloaded from awx.com (ORIGIN) and
  I'm making an XHR POST request to awx.com (HOST)"
  Server verifies; Host: header == Origin: header; OK!

  vs. the malicious case.

  <hacker injects javascript code into google.com>
  <browser goes to google.com>
  "I'm executing javascript that I downloaded from google.com (ORIGIN)
  and I'm making an XHR POST request to awx.com (HOST)"
  Server verifies; Host: header != Origin: header; NOT OK!
@@ -46,4 +46,5 @@ location @fallback {
# Add trailing / if missing
rewrite ^(.*)$http_host(.*[^/])$ $1$http_host$2/ permanent;
proxy_pass http://runserver;
proxy_set_header Host $http_host;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealHaoLiu TheRealHaoLiu merged commit ad96a92 into devel Mar 11, 2024
20 of 21 checks passed
@TheRealHaoLiu TheRealHaoLiu deleted the remove-csrf-hack-2 branch March 11, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants