本文へ移動
cccskills
無料GitHub で公開

semgrep-custom-rule-writing

Write custom Semgrep rules to identify organization-specific logic flaws, improper cryptography usage, or missing authorization checks during source code review. This skill focuses on moving beyond default rulesets to locate complex vulnerabilities.

インストール方法を見る

含まれるファイル(3)

  • SKILL.md5.3 KB
  • evals/evals.json540 B
  • scripts/process.py7.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Semgrep Custom Rule Writing

When to Use

  • During a white-box penetration test or source code review when looking for bespoke vulnerabilities that generic SAST tools fail to detect.
  • To codify and hunt for organization-specific anti-patterns (e.g., calling an internal API without passing the authentication context).

Prerequisites

  • Authorized scope and target URLs from bug bounty program
  • Burp Suite Professional (or Community) configured with browser proxy
  • Familiarity with OWASP Top 10 and common web vulnerability classes
  • SecLists wordlists for fuzzing and enumeration

Workflow

Phase 1: Understanding Semgrep Patterns

# Concept: Semgrep syntax rules:
  - id: simple-eval-detection
    pattern: eval(...)
    message: "Avoid using eval() as it can lead to code injection."
    languages: [javascript, python]
    severity: ERROR

Phase 2: Utilizing Metavariables

# rules:
  - id: python-exec-with-variable
    pattern: exec($X)
    message: "Using exec() on variable $X is dangerous."
    languages: [python]
    severity: WARNING

Phase 3: Pattern-Inside and Pattern-Not (Contextual Matching)

# rules:
  - id: missing-auth-check-flask
    patterns:
      - pattern-inside: |
          @app.route(...)
          def $FUNC(...):
            ...
      - pattern: return $RENDER(...)
      - pattern-not-inside: |
          @login_required
          def $FUNC(...):
            ...
      - pattern-not-inside: |
          if current_user.is_authenticated:
            ...
    message: "Flask route missing @login_required or explicit authentication check."
    languages: [python]
    severity: ERROR

Phase 4: Testing Rules via Semgrep CLI

# # semgrep --config custom-rules.yml src/

Decision Point 🔀

flowchart TD
    A[Identify Pattern ] --> B{Write Rule ]}
    B -->|Yes| C[Test Rule ]
    B -->|No| D[Refine Scope ]
    C --> E[Execute Scan ]

🔵 Blue Team Detection & Defense

  • CI/CD Integration Pipeline Validation: Centralized Rule Repositories: Developer Education: Key Concepts | Concept | Description | |---------|-------------|

Output Format

Semgrep Custom Rule Writing — Assessment Report
============================================================
Target: [Target identifier]
Assessor: [Operator name]
Date: [Assessment date]
Scope: [Authorized scope]
MITRE ATT&CK: [Relevant technique IDs]

Findings Summary:
  [Finding 1]: [Severity] — [Brief description]
  [Finding 2]: [Severity] — [Brief description]

Detailed Results:
  Phase 1: [Phase name]
    - Result: [Outcome]
    - Evidence: [Screenshot/log reference]
    - Impact: [Business impact assessment]

  Phase 2: [Phase name]
    - Result: [Outcome]
    - Evidence: [Screenshot/log reference]
    - Impact: [Business impact assessment]

Risk Rating: [Critical/High/Medium/Low/Informational]
Recommendations:
  1. [Immediate remediation step]
  2. [Long-term hardening measure]
  3. [Monitoring/detection improvement]

💰 Industry Bounty Payout Statistics (2024-2025)

Company/PlatformTotal PaidHighest SingleYear
Google VRP$17.1M$250,000 (CVE-2025-4609 Chrome sandbox escape)2025
Microsoft$16.6M(Not disclosed)2024
Google VRP$11.8M$100,115 (Chrome MiraclePtr Bypass)2024
HackerOne (all programs)$81M$100,050 (crypto firm)2025
Meta/Facebook$2.3Mup to $300K (mobile code execution)2024
Crypto.com (HackerOne)$2M program$2M max2024
1Password (Bugcrowd)$1M max$1M (highest Bugcrowd ever)2024
Samsung$1M max$1M (critical mobile flaws)2025

Key Takeaway: Google alone paid $17.1M in 2025 — a 40% increase YoY. Microsoft paid $16.6M. The industry is paying more, not less. Average critical bounty on HackerOne: $3,700 (2023).

📚 Shared Resources

For cross-cutting methodology applicable to all vulnerability classes, see:

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Exploit pervasive logical flaws in Multi-Factor Authentication (MFA/2FA) implementations to bypass the secondary authentication challenge entirely. Techniques include response manipulation, referal spoofing, token reuse, and predictable backup codes.

日本語の概要は準備中です。原文の説明を表示しています。

ShulkwiSEC/bb-huge242026年7月11日 更新

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

日本語の概要は準備中です。原文の説明を表示しています。

ShulkwiSEC/bb-huge242026年7月11日 更新

Complete PortSwigger deep-dive with exact payloads for every lab variant including zero-day techniques

日本語の概要は準備中です。原文の説明を表示しています。

ShulkwiSEC/bb-huge242026年7月11日 更新

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

日本語の概要は準備中です。原文の説明を表示しています。

ShulkwiSEC/bb-huge242026年7月11日 更新

Execute AS-REP Roasting to extract and crack the NTLM hashes of Active Directory user accounts that have the "Do not require Kerberos preauthentication" flag explicitly enabled. This attack generates a recoverable Ticket Granting Ticket (TGT) without requiring the attacker to authenticate first.

日本語の概要は準備中です。原文の説明を表示しています。

ShulkwiSEC/bb-huge242026年7月11日 更新

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

日本語の概要は準備中です。原文の説明を表示しています。

ShulkwiSEC/bb-huge242026年7月11日 更新

ShulkwiSEC のスキルをすべて見る

このスキルの問題を報告する