본문으로 건너뛰기
cccskills
무료GitHub에 공개

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.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(3)

  • SKILL.md10.8 KB
  • references/api_reference.md980 B
  • references/vulnerability_patterns.md17.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Vulnerability Pattern Matcher

Overview

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.

Detection Workflow

Follow these steps to detect and assess vulnerabilities:

1. Analyze Code Structure

Identify key security-relevant elements:

  • User input sources (request parameters, form data, file uploads)
  • Data sinks (database queries, file operations, command execution)
  • Authentication and authorization mechanisms
  • Cryptographic operations
  • Network communications
  • File and resource handling

Map data flow:

  • Trace user input through the application
  • Identify where untrusted data reaches sensitive operations
  • Note any validation or sanitization applied

2. Match Vulnerability Patterns

Scan for known patterns:

  • Injection vulnerabilities (SQL, NoSQL, LDAP, XSS, command injection)
  • Authentication issues (hardcoded credentials, weak session management)
  • Cryptographic failures (weak algorithms, insecure random numbers)
  • Access control problems (IDOR, missing authorization)
  • Deserialization vulnerabilities
  • Path traversal and file inclusion
  • SSRF and XXE
  • Buffer overflows and memory safety
  • Race conditions

For each match:

  • Identify the specific pattern
  • Note the exact code location
  • Determine the vulnerability category

3. Assess Exploitability

For each detected vulnerability, evaluate:

Attack Complexity:

  • Low: Simple exploit, no special conditions required
  • Medium: Requires specific conditions, timing, or configuration
  • High: Complex exploit chain, rare conditions, or significant obstacles

Privileges Required:

  • None: Unauthenticated attacker can exploit
  • Low: Basic user account needed
  • High: Administrative or privileged access required

User Interaction:

  • None: Fully automated exploit
  • Required: Victim must take action (click link, open file, etc.)

Exploitation Conditions:

  • What must be true for successful exploitation?
  • Are there mitigating controls present?
  • What is the attack surface?

4. Determine Severity

Critical:

  • Remote code execution
  • Authentication bypass
  • Complete system compromise
  • Mass data breach

High:

  • Privilege escalation
  • Sensitive data exposure
  • SQL injection with data access
  • SSRF to internal services

Medium:

  • XSS with session theft
  • IDOR to user data
  • Information disclosure
  • Weak cryptography

Low:

  • Minor information leakage
  • Low-impact XSS
  • Configuration issues
  • Verbose error messages

5. Generate Report

For each vulnerability, provide:

  • Pattern name and category
  • Code location (file:line)
  • Why the pattern is risky
  • Exploitation conditions
  • Severity level
  • Detection confidence (High/Medium/Low)
  • Recommended fix

Detection Examples

Example 1: SQL Injection

Code (Python):

def get_user(username):
    query = "SELECT * FROM users WHERE username = '" + username + "'"
    cursor.execute(query)
    return cursor.fetchone()

Detection:

  • Pattern: SQL Injection (String Concatenation)
  • Location: Line 2
  • Category: Injection Vulnerability

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:

  • User controls username parameter
  • No input validation or sanitization
  • Database errors may be exposed to attacker

Severity: High Confidence: High (95%)

Recommended Fix:

def get_user(username):
    query = "SELECT * FROM users WHERE username = ?"
    cursor.execute(query, (username,))
    return cursor.fetchone()

Example 2: Hardcoded Credentials

Code (JavaScript):

const config = {
    apiKey: "sk-1234567890abcdef",
    dbPassword: "admin123",
    jwtSecret: "my-secret-key"
};

Detection:

  • Pattern: Hardcoded Credentials
  • Location: Lines 2-4
  • Category: Authentication & Session Management

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:

  • Code repository is public or leaked
  • Credentials are still valid
  • No additional authentication factors

Severity: Critical Confidence: High (100%)

Recommended Fix:

const config = {
    apiKey: process.env.API_KEY,
    dbPassword: process.env.DB_PASSWORD,
    jwtSecret: process.env.JWT_SECRET
};

Example 3: XSS via innerHTML

Code (JavaScript):

function displayWelcome(username) {
    document.getElementById('welcome').innerHTML = "Hello " + username;
}

Detection:

  • Pattern: DOM-based XSS
  • Location: Line 2
  • Category: Cross-Site Scripting

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 input
  • No Content-Security-Policy
  • Sensitive data in cookies or localStorage

Severity: Medium Confidence: High (90%)

Recommended Fix:

function displayWelcome(username) {
    document.getElementById('welcome').textContent = "Hello " + username;
}

Example 4: Path Traversal

Code (Node.js):

app.get('/download', (req, res) => {
    const filename = req.query.file;
    res.sendFile('/uploads/' + filename);
});

Detection:

  • Pattern: Directory Traversal
  • Location: Line 3
  • Category: Path Traversal

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:

  • User controls file parameter
  • No path canonicalization or validation
  • Sensitive files accessible on filesystem

Severity: 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);
});

Example 5: Insecure Deserialization

Code (Python):

import pickle

@app.route('/load', methods=['POST'])
def load_data():
    user_data = pickle.loads(request.data)
    return process(user_data)

Detection:

  • Pattern: Unsafe Deserialization
  • Location: Line 5
  • Category: Insecure Deserialization

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:

  • Application deserializes user input
  • Python gadget chains available
  • No integrity checks on serialized data

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)

Example 6: SSRF via URL Parameter

Code (Python):

@app.route('/fetch')
def fetch_url():
    url = request.args.get('url')
    response = requests.get(url)
    return response.content

Detection:

  • Pattern: Server-Side Request Forgery
  • Location: Line 4
  • Category: SSRF

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:

  • User controls URL parameter
  • Internal network accessible from server
  • Cloud metadata endpoint available
  • No URL allowlist or validation

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

Confidence Levels

High Confidence (90-100%):

  • Exact pattern match with known vulnerability
  • Clear exploit path identified
  • No mitigating controls present
  • Well-documented vulnerability type

Medium Confidence (60-89%):

  • Pattern resembles known vulnerability
  • Exploitation requires specific conditions
  • Some mitigating controls may be present
  • Context suggests vulnerability but not certain

Low Confidence (30-59%):

  • Potential vulnerability identified
  • Unclear or complex exploit path
  • Multiple mitigating factors present
  • Requires manual verification
  • May be false positive

Constraints

MUST:

  • Identify specific vulnerability patterns in code
  • Explain why each pattern is risky
  • Assess exploitability conditions
  • Provide severity and confidence ratings
  • Reference specific code locations (file:line)
  • Suggest concrete fixes

MUST NOT:

  • Report theoretical vulnerabilities without code evidence
  • Provide exploits or attack code
  • Assume vulnerabilities without pattern match
  • Report false positives without noting low confidence
  • Ignore mitigating controls when assessing severity

Report Format

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]

Resources

references/vulnerability_patterns.md

Comprehensive catalog of security vulnerability patterns including:

  • Injection vulnerabilities (SQL, NoSQL, LDAP, XSS, command injection)
  • Authentication and session management issues
  • Cryptographic failures
  • Access control problems
  • Deserialization vulnerabilities
  • Path traversal and file inclusion
  • SSRF and XXE
  • Buffer overflows
  • Race conditions
  • CVE-style pattern examples
  • Exploitability assessment framework

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Applies abstract interpretation using different abstract domains (intervals, octagons, polyhedra, sign, congruence) to statically analyze program variables and infer invariants, value ranges, and relationships. Use when analyzing program properties, inferring loop invariants, detecting potential errors, or understanding variable relationships through static analysis.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Uses abstract interpretation to automatically infer loop invariants, function preconditions, and postconditions for formal verification. Generates invariants that capture program behavior and support correctness proofs in Dafny, Isabelle, Coq, and other verification systems. Use when adding formal specifications to code, generating verification conditions, inferring contracts for functions, or discovering loop invariants for proofs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Performs abstract interpretation over source code to infer possible program states, variable ranges, and data properties without executing the program. Reports potential runtime errors including out-of-bounds accesses, null dereferences, type inconsistencies, division by zero, and integer overflows. Use when analyzing code for potential runtime errors, performing static analysis, checking safety properties, or verifying program behavior without execution.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Performs abstract interpretation to produce summarized execution traces and high-level program behavior representations. Highlights key control flow paths, variable relationships, loop invariants, function summaries, and potential runtime states using abstract domains (intervals, signs, nullness, etc.). Use when analyzing program behavior, understanding execution paths, computing loop invariants, tracking variable ranges, detecting potential runtime errors, or generating program summaries without concrete execution.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

Create ACSL (ANSI/ISO C Specification Language) formal annotations for C/C++ programs. Use this skill when working with formal verification, adding function contracts (requires/ensures), loop invariants, assertions, memory safety annotations, or any ACSL specifications. Supports Frama-C verification and generates comprehensive formal specifications for C/C++ code.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

CLI-based browser automation with persistent page state using ref-based element interaction. Use when users ask to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ArabelaTso/Skills-4-SE2562026년 8월 21일 업데이트

ArabelaTso의 스킬 모두 보기

이 스킬의 문제 신고