Skip to content
atlas

Don't confuse these

Cross-site scripting (XSS) vs SQL injection

Why they differ

Both abuse input the site trusts too much, but SQL injection attacks the database on the server, while XSS attacks the visitor's browser.

Cross-site scripting (XSS)

Application security

An attack that smuggles a harmful script into a web page, so it runs in the browser of everyone who visits the page.

Formal

A flaw in a web application that places untrusted input into its pages without making it safe first; the web browser then runs that input as code with the same rights as the site's own code, so it can read what the user sees and act in their name.

In plain English

Like a notice board where someone pins up a note that, when read aloud, makes the reader hand over their house keys - the board itself never checks what is pinned to it.

In practice

An attacker posts a comment with a hidden script on a municipality's public consultation page; every resident who opens the page while logged in unknowingly hands the attacker their session.

Why it matters

The harmful code runs inside a site the visitor trusts, so the browser gives it the visitor's session and data; it remains one of the most often reported flaws in web applications.

SQL injection

Application security

An attack where text typed into a form is read by the database as a command, letting an outsider read or change its data.

Formal

An attack on a web application that builds database commands by pasting user input straight into the command text; crafted input changes the meaning of the command, so the database runs instructions the developer never intended.

In plain English

Like a form that says "Pay the sum of ___ to Anna", where someone writes "10 kroner, and also pay everything to me" in the blank - and the clerk simply does all of it.

In practice

A small Danish online shop passes whatever is typed into its search box straight to its database; an attacker types a short piece of SQL instead of a product name, and the page lists every customer's email address and hashed password.

Why it matters

One weak form field can hand over a whole database, and the flaw still turns up in new code decades after it was first described - even though a simple habit, keeping input apart from the command, prevents it.

Shared connections

Atlas is in beta.