So the csurf middleware used in Node.js applications has been deprecated since Sept 2022 due to security vulnerabilities being discovered by Fortbridge in Aug 2022. However, it it still being downloaded almost as much now as it was 1 year ago before the vulnerabilities were published. For example, 11-Jun-22 - 17-Jun-22 = 370,190 downloads per week. 03-Jun-23 - 09-Jun-23 = 337,097 downloads per week. This tells me it's relatively just as popular now as it was last year.
According to veracode. All versions of csurf library are vulnerable if:
- csurf is setup to use double-submit cookies – csurf({cookie: true})
- default value function is in use
The authors of csurf are advising to use an alternative.
The OWASP Cheat Sheet advises that:
- Check if your framework has built-in CSRF protection and use it (Express doesn't)
- For stateful software use the synchronizer token pattern
- For stateless software use double submit cookies
So far I have tried csrf-sync as it uses the Synchroniser Token Pattern but has only 2k weekly downloads. I have also looked into csrf-csrf package as it uses the Double Submit Cookie Pattern but again, it only has 38k weekly downloads.
My question therefore is which secure alternative middleware(s) is going to provide me with the best protection from Cross-Site Request Forgery attacks in Node with Express? There doesn't seem to be a clear option and I'd like to protect my organisation.