Three letters, two different OWASP categories

Free preview 3 min to read

A grouping this course's title suggests, and gets wrong

"SQLi, CSRF and XSS" in one course title reads like three attacks from the same family. The OWASP Top 10:2025, the current official ranking of web application security risks, says otherwise. SQL injection and XSS both sit in one category, A05:2025 Injection, whose page names both: "Injection includes Cross-site Scripting (high frequency/low impact) with more than 30k CVEs and SQL Injection (low frequency/high impact) with more than 14k CVEs". CSRF sits somewhere else, in A01:2025 Broken Access Control, which lists CWE-352: Cross-Site Request Forgery (CSRF) among its notable weaknesses. Two of the three attacks share a mechanism; the third doesn't.

What injection means, quoted

OWASP's definition: "An injection vulnerability is an application flaw that allows untrusted user input to be sent to an interpreter (e.g. a browser, database, the command line) and causes the interpreter to execute parts of that input as commands". A SQL database is one interpreter and a browser rendering HTML is another. SQLi and XSS are the same mistake, untrusted input reaching an interpreter and running as code, aimed at two different interpreters.

What CSRF is instead

In CSRF, no interpreter is tricked into running injected commands. It's a forged request: the victim's already-authenticated browser is tricked into sending a request the victim never meant to send. Nothing is injected anywhere in the chain. That's why OWASP files it under access control. The failure is a request running without the user's intent behind it, not untrusted data being read as code.

What this catalog already covers, and where this course starts

In "Rails forms: form_with", the lesson the-authenticity-token-and-csrf covers the hidden field form_with adds and the basic forgery it prevents. In "Controller filters & concerns", skip-before-action-and-the-real-csrf-case covers verify_authenticity_token as an inherited before_action, and this app's deliberate exception for GitHub's OAuth callback. In "ActionView: templates (ERB)", html-safe-and-escaping covers ERB's default escaping and .html_safe as an explicit opt-out, using this app's _welcome_modal.html.erb. None of that is retaught here.

What this course covers instead

Lessons 2 and 3 cover SQL injection, the one attack in this title no course in the catalog has covered: its mechanism, and the query patterns this app uses that are already safe. Lesson 4 goes deeper into CSRF: how the token is checked and what happens on a mismatch. Lesson 5 covers the kinds of XSS and the difference between raw and .html_safe. Lesson 6 reads this app's Content-Security-Policy configuration, which no course in this catalog has cited before. Lesson 7 closes with a review scenario that uses all three.

Where this leaves you

These three attacks aren't one thing under different names. You'll know each one's mechanism well enough to place it in the right OWASP category, and know this app's code well enough to say what's already defended, and against what.

Lesson 1 of 7 · free

Keep going with lesson 2

SQL injection: untrusted input, executed as commands

Builds a vulnerable query on a disposable table and shows how a ? placeholder quotes the value safely.

A free account also gives you the quizzes, your progress and notes, and the discussion.

Type to start searching...