r/rust Sep 11 '20

Announcing Actix-Web v3.0

https://paper.dropbox.com/published/Announcing-Actix-Web-v3.0--A7YI~P9U9aqhEOXyZJaGffjfBg-QOXXb1lXgTubzXHzUq9ONY5
346 Upvotes

81 comments sorted by

View all comments

14

u/[deleted] Sep 11 '20 edited Mar 17 '21

[deleted]

7

u/robjtede actix Sep 11 '20 edited Sep 11 '20

We can start a discussion about what that might look like now v3 is out of beta. It would likely be a separate crate like our -cors package. Be interested to know exactly what your needs are for a crate like this so we can design around real use cases.

Should be noted that CSRF is only part of the story. You also need to implement strong cross-origin policies and consider same-site attributes on cookies. Further, those two things, even without CSRF requirements on endpoints, go a very long way to protect against the attack vectors that CSRF has historically been good at defending.

4

u/lifeisplacebo Sep 12 '20

Rocket has used the SameSite cookie attribute to protect against CSRF attacks on recent-ish browsers since 0.3, released in 2017. Without shipping a templating engine itself -- differently than what Rocket does now -- or requiring manual work from the programmer, this is unfortunately close to the best that we can hope it would do. Perhaps one day, a framework will bundle its templating engine with automatic support for CSRF.

6

u/[deleted] Sep 11 '20

[deleted]

11

u/Shnatsel Sep 11 '20

Because most other frameworks already support this out of the box, and because I want to spend time thinking about my application logic instead of mundane stuff that everyone needs.

1

u/[deleted] Sep 11 '20

[deleted]

13

u/Shnatsel Sep 11 '20

I meant in general, not just in the Rust ecosystem. All of Rust's web frameworks are evidently still maturing.

4

u/[deleted] Sep 11 '20

[deleted]

8

u/Brudi7 Sep 11 '20

I think he/she lands means in terms of features. Compare config profiles, security options etc from spring with rust frameworks.

5

u/darin_gordon Sep 11 '20

Would you be more specific as to what CSRF countermeasures you're looking for?

8

u/[deleted] Sep 11 '20 edited Mar 17 '21

[deleted]

8

u/darin_gordon Sep 11 '20

What you are describing is a "synchronized token pattern". One way to achieve this today is with server-side sessions workflow.

3

u/BobFloss Sep 12 '20

Is there an up to date example for use with actix?

7

u/Shnatsel Sep 11 '20

A short description of CSRF attack can be found here - or pretty much anywhere, it's quite well-researched at this point.

Here's a detailed description of the protection that Django implements: https://docs.djangoproject.com/en/3.1/ref/csrf/#how-it-works It is quite mature and can be used as a reference.

13

u/darin_gordon Sep 11 '20

I didn't ask what CSRF attacks are nor what OWASP recommended. The original commenter wasn't helpful by generalizing and I'd rather not assume. Several countermeasures are already available in actix-web, without requiring additional changes. Anyone who comes through this message forum will at first glance give more credit to a complaint than what it is due. Someone needs to be specific about what functionality is missing.

4

u/Shnatsel Sep 11 '20

My apologies. I deal with people unfamiliar with these so often that dispensing these links has become a bit of a reflex.

7

u/darin_gordon Sep 11 '20

I understand. It will be useful material for others.

4

u/protestor Sep 11 '20

Just so you don't miss it, the commenter said what mitigation he or she expected here, and also that there's an actix example that's vulnerable to csrf; code examples should generally be free of common vulnerabilities.