check-input-validation
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "check-input-validation" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-9670e7be6e036f1f4f491e983163c6ba6f87be6e11625ee1b874487c6c101e4b. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Analyze input validation issues in PHP code. Detect missing validation, weak regular expressions, type coercion attack vectors, length/format vulnerabilities, and whitelist violations to locate and describe potential validation weaknesses.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Analyzes PHP code for input validation issues. Detects missing validation, weak regex, type coercion attacks, length/format gaps, whitelist violations.
- Inputs and outputs
- Analyze PHP code for input validation vulnerabilities.
- Testing
- Not tested
Browse files
Frontmatter
name: check-input-validation
description: Analyzes PHP code for input validation issues. Detects missing validation, weak regex, type coercion attacks, length/format gaps, whitelist violations.Input Validation Security Check
Analyze PHP code for input validation vulnerabilities.
Detection Patterns
1. Missing Input Validation
// CRITICAL: Direct use of request data
$id = $_GET['id'];
$this->delete($id); // No validation
// CRITICAL: Controller without validation
public function update(Request $request): Response
{
$data = $request->all();
$this->service->update($data); // Unvalidated
}
// CRITICAL: Command handler trusts input
public function handle(UpdateUserCommand $command): void
{
$user->setEmail($command->email); // Not validated
}
2. Weak Regex Patterns
// VULNERABLE: Anchors missing
if (preg_match('/[a-z]+/', $input)) { } // Matches substring
// VULNERABLE: Case sensitivity
if (preg_match('/^[a-z]+$/', $email)) { } // Misses uppercase
// VULNERABLE: Dot matches newline
if (preg_match('/^.+$/', $input)) { } // Dot doesn't match newline
// VULNERABLE: Overly permissive
if (preg_match('/.*/', $input)) { } // Matches everything
3. Type Coercion Attacks
// VULNERABLE: Loose comparison
if ($request->get('admin') == true) { } // '1', 'true', 1 all pass
// VULNERABLE: Array injection
$where['id'] = $_GET['id']; // Could be array: ?id[]=1&id[]=2
// VULNERABLE: Type juggling (PHP 8.4 baseline)
if ($_POST['password'] == 0) { } // '0', '0.0', ' 0' and null all pass;
// 'password123' == 0 is FALSE since PHP 8
4. Length/Format Validation Gaps
// VULNERABLE: No length limit
$description = $request->get('description');
$this->save($description); // Could be megabytes
// VULNERABLE: Missing format check
$phone = $request->get('phone'); // Could contain scripts
// VULNERABLE: No max items
$ids = $request->get('ids');
foreach ($ids as $id) { } // Unbounded array
5. Whitelist Violations
// VULNERABLE: Blacklist instead of whitelist
$forbidden = ['<script>', 'javascript:'];
if (!in_array($input, $forbidden)) { } // Easy to bypass
// VULNERABLE: Dynamic field access
$field = $_GET['field'];
$value = $entity->$field; // Can access any property
// CORRECT: Whitelist approach
$allowed = ['name', 'email', 'phone'];
if (!in_array($field, $allowed, true)) {
throw new InvalidArgumentException();
}
6. File Upload Validation
// VULNERABLE: Only checking extension
if (pathinfo($file['name'], PATHINFO_EXTENSION) === 'jpg') { }
// VULNERABLE: MIME type can be spoofed
if ($file['type'] === 'image/jpeg') { }
// CORRECT: Check actual file content
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->file($file['tmp_name']);
$allowed = ['image/jpeg', 'image/png', 'image/gif'];
if (!in_array($mime, $allowed, true)) { }
7. Numeric Input Validation
// VULNERABLE: No range check
$page = (int) $_GET['page']; // Could be negative or huge
// VULNERABLE: Float precision
$amount = (float) $_POST['amount']; // 0.1 + 0.2 != 0.3
// CORRECT: Full validation
$page = filter_var($_GET['page'], FILTER_VALIDATE_INT, [
'options' => ['min_range' => 1, 'max_range' => 1000]
]);
Grep Patterns
# Direct $_GET/$_POST usage
Grep: "\$_(GET|POST|REQUEST)\[['\"][^'\"]+['\"]\]" --glob "**/*.php"
# Missing filter_var
Grep: "\$request->get\([^)]+\)\s*;" --glob "**/*.php"
# Weak regex (no anchors)
Grep: "preg_match\(['\"]\/[^$^]" --glob "**/*.php"
# Dynamic property access
Grep: "\$\w+->\$" --glob "**/*.php"
Severity Classification
| Pattern | Severity |
|---|---|
| No input validation at all | 🔴 Critical |
| Type juggling vulnerability | 🔴 Critical |
| Missing file content check | 🟠 Major |
| Weak regex | 🟠 Major |
| Missing length limits | 🟡 Minor |
Best Practices
Use Validation Libraries
// Symfony Validation
$constraints = new Assert\Collection([
'email' => [new Assert\NotBlank(), new Assert\Email()],
'age' => [new Assert\Range(['min' => 18, 'max' => 120])],
]);
// Laravel Validation
$validated = $request->validate([
'email' => 'required|email|max:255',
'age' => 'required|integer|min:18|max:120',
]);
Always Use Strict Types
declare(strict_types=1);
function process(int $id, string $email): void { }
Output Format
### Input Validation: [Description]
**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**CWE:** CWE-20 (Improper Input Validation)
**Issue:**
[Description of missing/weak validation]
**Attack Vector:**
[How attacker exploits this]
**Code:**
```php
// Vulnerable code
Fix:
// With proper validation
## When This Is Acceptable
- **Framework FormRequest** — Laravel/Symfony form requests already validate input; additional validation is redundant
- **Internal service calls** — Methods called only by already-validated application layer don't need re-validation
- **Value Objects** — VOs validate in constructor; callers don't need additional checks
### False Positive Indicators
- Input passes through a FormRequest or Validator before reaching the method
- Method is private/protected and called only from validated entry points
- Parameter is a Value Object that self-validatesCurrent listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 PHP 输入验证漏洞检测能力,覆盖缺失验证、弱正则、类型强制、长度限制等关键安全问题
- 面向开发者安全审计场景,具备明确实用价值和广泛适用性
Highlights
- description 清晰描述功能范围,覆盖多种漏洞类型,边界明确,用户可准确理解用途
Areas to improve
-
缺少标准 'When to Use' 使用场景说明章节 Reported severity: Minor
文档末尾有 'When This Is Acceptable' 说明,但非标准命名,建议补充标准 'When to Use' 章节以明确适用场景
Recommendation: 在文档中添加 'When to Use' 章节,明确说明该 Skill 的适用场景和使用时机
Highlights
- 文档结构清晰,包含检测模式、Grep 命令、严重性分类、最佳实践等完整内容
- 提供具体代码示例和修复建议,便于理解执行
Highlights
- 提供具体的检测模式和 Grep 命令,逻辑完整,覆盖主要异常场景
- 给出正确实践示例和修复建议,具备高执行可靠性
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.