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

OWASP Guidance: prefer Origin header over Referer header when Identifying Source Origin #455

Open
gsmethells opened this issue Jun 28, 2021 · 2 comments

Comments

@gsmethells
Copy link

CSRF protection in csrf.py should prefer Origin header over Referer header if the former is available when checking same_site().

@gsmethells
Copy link
Author

gsmethells commented Jun 28, 2021

The current code

       if request.is_secure and current_app.config['WTF_CSRF_SSL_STRICT']:
            if not request.referrer:
                self._error_response('The referrer header is missing.')

            good_referrer = f'https://{request.host}/'

            if not same_origin(request.referrer, good_referrer):
                self._error_response('The referrer does not match the host.')

only looks at request.referrer.

@gsmethells
Copy link
Author

Broken off from #364

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

No branches or pull requests

1 participant