The Real Fullstack

The Dangerous Query

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

探索者7 分钟代码挑战时间线模拟器
sqljavajdbcpythonnode

此挑战尚未翻译为简体中文,你正在阅读英文版本。

任务:Try the payloads, then choose a query construction that keeps every input as data — in string, numeric and identifier positions.背景 · 学习目标 ▾

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.

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

学习目标

  • 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).
模拟模拟数据

运行模拟以查看输出。

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

简化说明

Payload detection is pattern-based and limited to five inputs; never test against systems you don't own. 教学模型——数字用于说明行为,并非基准测试。

概念

相关挑战

参考资料