input-validation
Skill0 starsChanged 9 months agoMITView on GitHub
Use when processing user input, form data, file uploads, or query parameters
5 other projects use a version of this.
Adopted by
Most recently taken up by
- drvoss/everything-copilot-clitheir own version, first seen Aug 9, 2026
- Archive228/loopkittheir own version, first seen Jun 29, 2026
- JeremyMorgan/code-review-skillstheir own version, first seen Jun 3, 2026
- suhailkakar/the-skillstheir own version, first seen May 7, 2026
- YepAPI/skillstheir own version, first seen Apr 12, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- Archive228/loopkit★ 756same name
- drvoss/everything-copilot-cli★ 47same name
- suhailkakar/the-skills★ 26same name
- JeremyMorgan/code-review-skills★ 15same name
- YepAPI/skills★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository10 other files it gives its agents.
- access-controlSkill
- accessibilitySkill
- api-securitySkill
- authenticationSkill
- dependency-securitySkill
- injection-preventionSkill
- secrets-managementSkill
- security-contextSkill
- security-headersSkill
- xss-csrfSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
2
Distinctive
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 43
Every field has constraints.
- Distinctive: line 59
Check extension, MIME type, and file signature.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Input Validation
Validate everything that enters your system. Server-side. Every time. Client-side validation is UX, not security.
Related: injection-prevention, xss-csrf, api-security, security-context
Rule 1: Validate Server-Side (Always)
Client-side validation can be bypassed with one curl command.
// WRONG — only client-side validation
<input type="email" required> // Attacker skips this entirely
// RIGHT — validate on the server
function createUser(req, res) {
const { email, name } = req.body;
if (!email || !isValidEmail(email)) return res.status(400).json({ error: 'Valid email required' });
if (!name || name.length > 100) return res.status(400).json({ error: 'Name required, max 100 chars' });
// proceed
}Rule 2: Whitelist, Don't Blacklist
Reject everything except what you expect. Blacklists always miss something.
// WRONG — trying to block bad characters
if (input.includes('<script>')) reject();
// RIGHT — only allow expected format
if (!/^[a-zA-Z0-9\s\-]{1,100}$/.test(input)) reject();Rule 3: Validate Type, Length, and Range
Every field has constraints. Enforce them.
# WRONG — no validation
age = request.form['age']
save_user(age=age)
# RIGHT — validate type, range, and length
age = request.form.get('age')
if not age or not age.isdigit() or not (0 <= int(age) <= 150):
return bad_request('Age must be a number between 0 and 150')
save_user(age=int(age))Rule 4: Validate File Uploads
Check extension, MIME type, and file signature. Never trust the filename.
// WRONG — trusts the file extension
if (file.originalname.endsWith('.jpg')) saveFile(file);
// RIGHT — check MIME type AND magic bytes
const allowedMimes = ['image/jpeg', 'image/png', 'image/webp'];
if (!allowedMimes.includes(file.mimetype)) reject();
const fileBuffer = fs.readFileSync(file.path);
const type = await fileTypeFromBuffer(fileBuffer);
if (!type || !allowedMimes.includes(type.mime)) reject();Rule 5: Sanitize Before Storage, Escape Before Display
Two different operations. Both required.
// Sanitize on input (remove dangerous content)
const cleanHtml = DOMPurify.sanitize(userInput);
await saveToDb(cleanHtml);
// Escape on output (prevent XSS in different contexts)
element.textContent = storedValue; // HTML contextQuick Reference
| Do | Don't |
| Validate server-side on every request | Rely on client-side validation alone |
| Whitelist expected formats | Blacklist known bad patterns |
| Enforce type, length, and range limits | Accept any value from the client |
| Check file MIME type AND magic bytes | Trust file extensions |
| Sanitize on input, escape on output | Skip either step |
| Return clear error messages | Silently accept bad input |
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.

