The Real Fullstack

The Dangerous Query

We escape quotes before building the query. Is the search safe now?

Entdecker7 Min.Code-AufgabeZeitachsen-Simulator
sqljavajdbcpythonnode

Diese Aufgabe ist noch nicht auf Deutsch übersetzt. Du liest die englische Version.

Mission:Try the payloads, then choose a query construction that keeps every input as data — in string, numeric and identifier positions.Kontext · Lernziele ▾

Fernway's back-office customer search builds SQL from the search box and a sort dropdown. A penetration test (on a local copy with synthetic data) showed the search can return every customer — or other tables entirely. A developer added quote escaping as a quick fix.

Mission: Try the payloads, then choose a query construction that keeps every input as data — in string, numeric and identifier positions.

Lernziele

  • See how concatenated input changes a query's structure.
  • Use parameterised queries for values.
  • Allow-list identifiers that can't be parameterised (ORDER BY, column names).
SimulationSimuliert

Starte die Simulation, um die Ausgabe zu sehen.

Simulation starten
String sql = "SELECT id, name FROM customers WHERE name = '" + name + "'"           + " ORDER BY " + sort;                                   // user input becomes SQLreturn jdbc.query(sql, rowMapper);

Vereinfachung

Payload detection is pattern-based and limited to five inputs; never test against systems you don't own. Lernmodell – die Zahlen veranschaulichen Verhalten und sind keine Benchmarks.

Konzepte

Verwandte Aufgaben

Referenzen