arabelatso/vulnerability-pattern-matcher
Detects security vulnerabilities by matching code against known vulnerability patterns, insecure coding idioms, and CVE-style patterns. Explains why patterns are risky and under what conditions they are exploitable. Use when analyzing code for security issues, reviewing for common vulnerabilities, or assessing exploitability of suspicious code patterns.
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill vulnerability-pattern-matcher
This skill detects security vulnerabilities by matching code against a comprehensive database of known vulnerability patterns, insecure coding idioms, and historical CVE-style patterns. It identifies risky code, explains why each pattern is dangerous, assesses exploitability conditions, and provides severity ratings with confidence levels.
Follow these steps to detect and assess vulnerabilities:
Identify key security-relevant elements:
Map data flow:
Scan for known patterns:
For each match:
For each detected vulnerability, evaluate:
Attack Complexity:
Privileges Required:
User Interaction:
Exploitation Conditions:
Critical:
High:
Medium:
Low:
For each vulnerability, provide:
Code (Python):
def get_user(username):
query = "SELECT * FROM users WHERE username = '" + username + "'"
cursor.execute(query)
return cursor.fetchone()
Detection:
Why Risky:
User input is directly concatenated into SQL query without parameterization. Attacker can inject SQL code to bypass authentication, extract data, or modify the database.
Exploitation Conditions:
username parameterSeverity: High
Confidence: High (95%)
Recommended Fix:
def get_user(username):
query = "SELECT * FROM users WHERE username = ?"
cursor.execute(query, (username,))
return cursor.fetchone()
Code (JavaScript):
const config = {
apiKey: "sk-1234567890abcdef",
dbPassword: "admin123",
jwtSecret: "my-secret-key"
};
Detection:
Why Risky:
Credentials are embedded in source code and likely committed to version control. Anyone with repository access can authenticate as the application. Credentials are difficult to rotate if compromised.
Exploitation Conditions:
Severity: Critical
Confidence: High (100%)
Recommended Fix:
const config = {
apiKey: process.env.API_KEY,
dbPassword: process.env.DB_PASSWORD,
jwtSecret: process.env.JWT_SECRET
};
Code (JavaScript):
function displayWelcome(username) {
document.getElementById('welcome').innerHTML = "Hello " + username;
}
Detection:
Why Risky:
User-controlled data is directly inserted into DOM via innerHTML without encoding. Attacker can inject JavaScript to steal cookies, session tokens, or perform actions as the victim.
Exploitation Conditions:
username contains user inputSeverity: Medium
Confidence: High (90%)
Recommended Fix:
function displayWelcome(username) {
document.getElementById('welcome').textContent = "Hello " + username;
}
Code (Node.js):
app.get('/download', (req, res) => {
const filename = req.query.file;
res.sendFile('/uploads/' + filename);
});
Detection:
Why Risky:
User controls file path without validation. Attacker can use ../ sequences to access files outside the intended directory, potentially reading sensitive configuration files, source code, or credentials.
Exploitation Conditions:
file parameterSeverity: High
Confidence: High (95%)
Recommended Fix:
const path = require('path');
app.get('/download', (req, res) => {
const filename = path.basename(req.query.file);
const filepath = path.join('/uploads/', filename);
if (!filepath.startsWith('/uploads/')) {
return res.status(400).send('Invalid file');
}
res.sendFile(filepath);
});
Code (Python):
import pickle
@app.route('/load', methods=['POST'])
def load_data():
user_data = pickle.loads(request.data)
return process(user_data)
Detection:
Why Risky:
Deserializing untrusted data with pickle can lead to arbitrary code execution. Attacker can craft malicious serialized objects that execute code during deserialization.
Exploitation Conditions:
Severity: Critical
Confidence: High (100%)
Recommended Fix:
import json
@app.route('/load', methods=['POST'])
def load_data():
user_data = json.loads(request.data)
return process(user_data)
Code (Python):
@app.route('/fetch')
def fetch_url():
url = request.args.get('url')
response = requests.get(url)
return response.content
Detection:
Why Risky:
Application makes HTTP requests to user-controlled URLs. Attacker can access internal services, cloud metadata endpoints (169.254.169.254), or perform port scanning of internal network.
Exploitation Conditions:
Severity: High
Confidence: High (95%)
Recommended Fix:
from urllib.parse import urlparse
ALLOWED_HOSTS = ['api.example.com', 'cdn.example.com']
@app.route('/fetch')
def fetch_url():
url = request.args.get('url')
parsed = urlparse(url)
if parsed.hostname not in ALLOWED_HOSTS:
return "Invalid URL", 400
response = requests.get(url, timeout=5)
return response.content
High Confidence (90-100%):
Medium Confidence (60-89%):
Low Confidence (30-59%):
MUST:
MUST NOT:
Vulnerability: [Pattern Name]
Category: [Vulnerability Category]
Location: [file:line]
Severity: [Critical/High/Medium/Low]
Confidence: [High/Medium/Low] ([percentage]%)
Description:
[Why this pattern is risky]
Exploitation Conditions:
- [Condition 1]
- [Condition 2]
- [Condition 3]
Vulnerable Code:
[Code snippet]
Recommended Fix:
[Safe code example]
Comprehensive catalog of security vulnerability patterns including:
Take arabelatso/vulnerability-pattern-matcher from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.