input-validation-injection

Solid

Apply when reviewing or writing code that processes untrusted input, constructs queries or commands, or handles user-supplied data. Covers SQL, LDAP, OS command injection, prototype pollution, and general validation strategy.

AI & Automation 15 stars 2 forks Updated today MIT

Install

View on GitHub

Quality Score: 81/100

Stars 20%
40
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Input Validation and Injection Defense Ensure untrusted input is validated and never interpreted as code. Prevent injection across SQL, LDAP, OS commands, templating, and JavaScript runtime object graphs. ## Core Strategy - Validate early at trust boundaries with positive (allow-list) validation and canonicalization. - Treat all untrusted input as data, never as code. Use safe APIs that separate code from data. - Parameterize queries/commands; escape only as last resort and context-specific. ## Validation Playbook - **Syntactic validation**: enforce format, type, ranges, and lengths for each field. - **Semantic validation**: enforce business rules (e.g., start <= end date, enum allow-lists). - **Normalization**: canonicalize encodings before validation; validate complete strings (regex anchors `^$`); beware ReDoS. - **Free-form text**: define character class allow-lists; normalize Unicode; set length bounds. - **Files**: validate by content type (magic), size caps, and safe extensions; server-generate filenames; scan; store outside web root. ## SQL Injection Prevention - Use prepared statements and parameterized queries for 100% of data access. - Use bind variables for any dynamic SQL within stored procedures -- never concatenate user input into SQL. - Prefer least-privilege DB users and views; never grant admin to app accounts. - Escaping is fragile and discouraged; parameterization is the primary defense. Example (Java PreparedStatement): ```java String custname ...

Details

Author
backspace-shmackspace
Repository
backspace-shmackspace/claude-devkit
Created
5 months ago
Last Updated
today
Language
Shell
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category