Academy

Module 2 · Why Injection Still Happens — A Grammar Problem 🔒

Manish Garg
Manish Garg Associate CISSP · RingSafe
April 22, 2026
4 min read

Injection bugs — SQL, OS command, LDAP, NoSQL, XPath, template engines — are not about “bad input validation.” They’re about mixing two languages in one string and letting the attacker supply a mix that changes the grammar. Once you see injection as a grammar problem rather than an input problem, every class of injection becomes the same idea with different syntax.

Why this happens

Developers use string concatenation because it’s the fastest way to build a command. "SELECT * FROM users WHERE id=" + user_id feels natural; it reads like English. But what the database parses is not “a query plus an ID” — it’s one string that the database tokenizes into tokens. If the attacker controls enough of the string to inject tokens of their own, the grammar of the original query changes.

The root assumption is: “I know what SQL I’m writing because I wrote it.” The truth is: the database only knows what SQL it was handed. The user has written part of the SQL by being part of the string.

🔐 Intermediate Module · Basic Tier

Continue reading with Basic tier (₹499/month)

You've read 25% of this module. Unlock the remaining deep-dive, quiz, and every other Intermediate module.

99+ modulesAll levels up to this tier
20-question quizzesUnlimited retries with explanations
Completion certificatesShareable on LinkedIn
6 more sections locked below