injection-prevention
Skill0 starsChanged 8 months agoMITView on GitHub
Use when writing database queries, SQL, ORM code, or shell commands
In this repository11 other files it gives its agents.
- access-controlSkill
- accessibilitySkill
- accessibility-testingSkill
- api-securitySkill
- authenticationSkill
- dependency-securitySkill
- input-validationSkill
- secrets-managementSkill
- security-contextSkill
- security-headersSkill
- xss-csrfSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Never build queries or commands by concatenating user input.
- Distinctive: line 47
Never pass user input directly to shell commands.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Injection Prevention
Never build queries or commands by concatenating user input. Use parameterized statements or ORM methods.
Related: input-validation, security-context
Rule 1: No String Concatenation in SQL
Concatenating user input into SQL is the most exploited vulnerability in web applications.
-- WRONG
SELECT * FROM users WHERE name = '" + userName + "';
-- RIGHT
SELECT * FROM users WHERE name = ?;
-- Bind userName as parameterRule 2: Use ORM Query Builders
ORMs parameterize by default. Use them. Don't drop to raw SQL unless absolutely necessary.
// WRONG — raw SQL with string interpolation
db.query(`SELECT * FROM users WHERE email = '${email}'`);
// RIGHT — parameterized query
db.query('SELECT * FROM users WHERE email = ?', [email]);# WRONG — f-string in raw SQL
cursor.execute(f"SELECT * FROM users WHERE name = '{name}'")
# RIGHT — parameterized
cursor.execute("SELECT * FROM users WHERE name = %s", (name,))Rule 3: No Shell Command Injection
Never pass user input directly to shell commands.
// WRONG — user controls the command
exec(`convert ${userFilename} output.png`);
// RIGHT — use allowlists and escape
const safeName = path.basename(userFilename);
execFile('convert', [safeName, 'output.png']);# WRONG
os.system(f"ls {user_input}")
# RIGHT — use subprocess with argument list
subprocess.run(["ls", user_input], check=True)Rule 4: No LDAP Injection
Escape special characters in LDAP queries.
// WRONG
(&(uid={userInput})(userPassword={password}))
// RIGHT — escape LDAP special characters: * ( ) \ NUL
(&(uid={ldap_escape(userInput)})(userPassword={ldap_escape(password)}))Quick Reference
| Do | Don't |
| Use parameterized queries | Concatenate user input into SQL |
| Use ORM query builders | Write raw SQL with interpolation |
Use execFile with argument arrays | Use exec with string commands |
| Escape LDAP special characters | Pass raw input to directory queries |
| Validate input type before querying | Trust that input is the expected type |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

