Home / Companies / Twilio / Blog / Post Details
Content Deep Dive

Going surfing – Protect your Node.js app from Cross-Site Request Forgery

Blog post from Twilio

Post Details
Company
Date Published
Author
Dominik Kundel
Word Count
1,187
Language
English
Hacker News Points
-
Summary

A Cross-Site Request Forgery (CSRF) attack occurs when an attacker sends a request on behalf of a user to a web application without their knowledge or consent, often using a hidden form. To protect against CSRF attacks, developers can use CSRF tokens, which are randomly generated strings sent as cookies that must be included in subsequent requests made by the browser. By implementing CSRF tokens, developers can prevent attackers from performing malicious requests on behalf of users. The text demonstrates how to implement CSRF tokens in an Express.js application using middleware such as csurf and cookie-parser, and shows how this can help protect against CSRF attacks.