Intermediate Topic 26 of 51 Security & Cryptography
CSRF
Attack tricking a user's browser into unwanted requests.
How it works
Cross-site request forgery tricks a logged-in browser into sending an unintended request using ambient cookies. Defend with anti-CSRF tokens, SameSite cookies and checking Origin.
Where it is used
State-changing endpoints.
Common pitfall
Using GET for state changes.
Where it fits in the course
CSRF is topic 26 of 51 in Security & Cryptography, rated Intermediate. It follows Cross-Site Scripting. The next topic is Buffer Overflow.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Security & Cryptography quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Security & Cryptography quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is CSRF?
Attack tricking a user's browser into unwanted requests. It belongs to Security & Cryptography and is an intermediate-level topic.
Where do people use CSRF?
State-changing endpoints.
What is the most common mistake with CSRF?
Using GET for state changes.
What should I learn before this topic?
Start with Cross-Site Scripting, the topic just before it in Security & Cryptography.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Security & Cryptography quiz.
Is CSRF hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn CSRF?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to CSRF?
Cross-Site Scripting, Buffer Overflow, SQL Injection are closely connected. The full list is in the related topics section of this page.
What should I study after CSRF?
Continue with Buffer Overflow, the next topic in Security & Cryptography.
Related topics
- Cross-Site Scripting (Security & Cryptography)
- Buffer Overflow (Security & Cryptography)
- SQL Injection (Security & Cryptography)
- Denial of Service (Security & Cryptography)