skills/missing-input-validation-anti-pattern/SKILL.md
Security anti-pattern for missing input validation (CWE-20). Use when generating or reviewing code that processes user input, form data, API parameters, or external data. Detects client-only validation, missing type checks, and absent length limits. Foundation vulnerability enabling most attack classes.
npx skillsauth add igbuend/grimbard missing-input-validation-anti-patternInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Severity: High
Missing input validation occurs when applications fail to validate data from users or external sources before processing it. This enables SQL Injection, Cross-Site Scripting (XSS), Command Injection, and Path Traversal attacks. Treat all incoming data as untrusted. Validate against strict rules for type, length, format, and range.
Trusting external input without server-side validation. Client-side validation provides no security—attackers bypass it trivially.
# VULNERABLE: Trusts user input completely, enabling SQL Injection
from flask import request
import sqlite3
@app.route("/api/products")
def search_products():
# Takes 'category' directly from URL query string
category = request.args.get("category")
# Input concatenated directly into SQL query (classic SQL Injection)
db = sqlite3.connect("database.db")
cursor = db.cursor()
query = f"SELECT id, name, price FROM products WHERE category = '{category}'"
# Attacker request: /api/products?category=' OR 1=1 --
# Resulting query: "SELECT ... FROM products WHERE category = '' OR 1=1 --'"
# Returns ALL products, bypassing filter
cursor.execute(query)
products = cursor.fetchall()
return {"products": products}
# SECURE: Validates all input on server against strict allowlist
from flask import request
import sqlite3
# Strict allowlist of known-good values for 'category' parameter
ALLOWED_CATEGORIES = {"electronics", "books", "clothing", "homegoods"}
@app.route("/api/products/safe")
def search_products_safe():
category = request.args.get("category")
# 1. VALIDATE EXISTENCE: Check parameter provided
if not category:
return {"error": "Category parameter is required."}, 400
# 2. VALIDATE AGAINST ALLOWLIST: Strongest form of input validation
if category not in ALLOWED_CATEGORIES:
return {"error": "Invalid category specified."}, 400
# 3. USE PARAMETERIZED QUERIES: Safe database APIs prevent injection
db = sqlite3.connect("database.db")
cursor = db.cursor()
# '?' placeholder treats input as data, not code
query = "SELECT id, name, price FROM products WHERE category = ?"
cursor.execute(query, (category,))
products = cursor.fetchall()
return {"products": products}
required HTML attributes or JavaScript validation without server-side equivalents.Apply "Validate, then Act" to all incoming data.
Missing input validation enables most major vulnerability classes.
development
Security anti-pattern for Cross-Site Scripting vulnerabilities (CWE-79). Use when generating or reviewing code that renders HTML, handles user input in web pages, uses innerHTML/document.write, or builds dynamic web content. Covers Reflected, Stored, and DOM-based XSS. AI code has 86% XSS failure rate.
development
Security anti-pattern for XPath injection vulnerabilities (CWE-643). Use when generating or reviewing code that queries XML documents, constructs XPath expressions, or handles user input in XML operations. Detects unescaped quotes and special characters in XPath queries.
development
Security anti-pattern for weak password hashing (CWE-327, CWE-759). Use when generating or reviewing code that stores or verifies user passwords. Detects use of MD5, SHA1, SHA256 without salt, or missing password hashing entirely. Recommends bcrypt, Argon2, or scrypt.
development
Security anti-pattern for weak encryption (CWE-326, CWE-327). Use when generating or reviewing code that encrypts data, handles encryption keys, or uses cryptographic modes. Detects DES, ECB mode, static IVs, and custom crypto implementations.