Zum Inhalt springen

Cross-site scripting (ARCH3101)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.security.xss · Severity error · Category security · CWE CWE-79

Writing untrusted data to HTML output without escaping (raw HTML sinks or innerHTML) lets attackers inject scripts, enabling cross-site scripting (XSS).

app.get("/hello", (req, res) => {
// name="<script>steal()</script>"
res.send(`<h1>Hello ${req.query.name}</h1>`);
});
import escapeHtml from "escape-html";
app.get("/hello", (req, res) => {
res.send(`<h1>Hello ${escapeHtml(String(req.query.name))}</h1>`);
});

Escape user data before writing it into HTML; use template engines with auto-escaping.