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

XSRF mitigation with interceptor #1

Open
paviad opened this issue Jan 17, 2023 · 1 comment
Open

XSRF mitigation with interceptor #1

paviad opened this issue Jan 17, 2023 · 1 comment

Comments

@paviad
Copy link

paviad commented Jan 17, 2023

Loved your talk at https://www.youtube.com/watch?v=NRg-rsMEdQs

The code doesn't include the XSRF interceptor thing, or did I miss it?

Thanks!

@alisaduncan
Copy link
Owner

Hey @paviad! Glad to hear it and thank you for your kind words!

You're correct, this repo doesn't include the XSRF interceptor since it requires mostly server-side code changes to see this end-to-end, which is outside of the scope of Angular.

On the Angular side, the steps are relatively straightforward: importing the HttpClientXSRFModule and configuring the cookieName and headerName as required for your system. Here's a post I wrote that documents this process (along with more info about the mitigation strategy) - Protect Your Angular App From Cross-Site Request Forgery.

On the server side, you'll have to implement verification of the XSRF Cookie value, as well as supply the cookie in the first place. It's essential to make sure you have good defenses in place for getting the initial cookie, including carefully applying SameSite cookie attribute and thoughtful consideration of CSPs, including CORs. OWASP has a great cheatsheet you might be interested in that covers this in detail - Cross-Site Request Forgery Prevention Cheat Sheet.

Hope this helps and happy secure coding!

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

No branches or pull requests

2 participants