The Real Fullstack

The Dangerous Query

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

Explorador7 minReto de códigoSimulador de línea de tiempo
sqljavajdbcpythonnode

Este reto aún no está traducido al Español. Estás leyendo la versión en inglés.

Misión:Try the payloads, then choose a query construction that keeps every input as data — in string, numeric and identifier positions.Contexto · Objetivos de aprendizaje ▾

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.

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

Objetivos de aprendizaje

  • 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).
SimulaciónSimulado

Ejecuta la simulación para ver la salida.

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

Simplificación

Payload detection is pattern-based and limited to five inputs; never test against systems you don't own. Modelo educativo: los números ilustran un comportamiento, no son benchmarks.

Conceptos

Retos relacionados

Referencias