You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
JSON can carry data into another language
JSON parsing does not make a value safe for SQL, a NoSQL query object, a template, or a shell. The API boundary and the receiving interpreter have different rules. Follow the parsed value to the exact operation that gives it structural meaning.
ReportShelf accepts a text filter for report titles. The handler validates that it is a bounded string, then concatenates it into SQL. The tenant comes from verified membership, but the query string places that predicate next to attacker-controlled SQL grammar.
javascript examplejavascript
1const filter =parseReportFilter(request.body);// bounded string2const sql =3"SELECT id, title FROM reports WHERE tenant_id = '"+4 member.tenantId+5"' AND title = '"+6 filter.title+7"'";8return db.query(sql);
The string can contain quote characters while remaining valid JSON and valid business text. The dangerous boundary is the construction of SQL source. Do not confuse schema validation with parameter binding.
Continue with Premium
Continue API Security with the complete lessons, guided exercises, code-review challenges and assessments.