Webアプリのセキュリティレビュー(OWASP Top 10 対応・Python/Node)

Web app security review for Python and Node (OWASP Top 10 2021)

Flask・Django・FastAPI・Express・Next.js のコードを OWASP Top 10 (2021) に沿って点検し、重要度・該当箇所・攻撃シナリオ・修正コードつきの指摘レポートにまとめます。

ClaudeHermes AgentCodexCursorMIT(改変・再配布・商用利用可)Python

できること

Python(Flask / Django / FastAPI)と Node(Express / Next.js の API ルート)で作った Web アプリのソースコードを、OWASP Top 10 (2021) の観点でレビューします。機械的な洗い出しは付属スクリプト、確認と判断はエージェントが担当します。

  • ルート一覧の自動抽出(route_inventory.py): Flask・FastAPI・Django(urls.py とビュー)・DRF・Express・Next.js(pages/api と app/**/route.ts)のルートを、メソッド・パス・ハンドラー・ファイル:行・認証や CSRF 除外・レート制限の手がかりつきで一覧化。「データを変更するのに認証の手がかりがないルート」などに印をつけます
  • 危険パターンの自動検出(sec_scan.py): SQL の文字列連結・f-string、シェル実行、eval、テンプレートインジェクション、NoSQL インジェクション、XSS の出力先(|safe、dangerouslySetInnerHTML、innerHTML など)、パストラバーサル、SSRF、pickle・yaml.load、オープンリダイレクト、CSRF 対策の欠如・無効化、Cookie の Secure/HttpOnly/SameSite 抜け、CORS *、デバッグモード、トークンへの弱い乱数、パスワードへの MD5 など、JWT の署名検証なし・alg none、ハードコードされた SECRET_KEY(値は伏せ字)、マスアサインメント、XXE など約30種類
  • リクエスト由来の値がそのまま危険な処理に届いているかを同じファイル内で簡易追跡し、確度(high/medium/low)を付けます
  • 結果はコンソール・JSON・Markdown のレポート下書き・SARIF で出力。抑制コメントと baseline(既知の指摘を隠す)に対応
  • 手作業のチェックリスト: OWASP の10分類ごとの確認項目(IDOR などの認可、設計上の欠陥、依存パッケージ)とフレームワーク別の要点
  • 修正ガイド: ルールごとに、修正前と修正後のコード例(Python と Node)と確認テスト
  • 判定ガイドとレポートのひな形: 誤検出のよくある例、見逃しやすい箇所、重要度の基準、指摘レポートのテンプレート、実行例つきのサンプル

使い方

python scripts/route_inventory.py アプリのフォルダ --md routes.md
python scripts/sec_scan.py アプリのフォルダ --json scan.json --md scan-draft.md --fail-on never

エージェントはスキャン結果を1件ずつコードで確認し(確定/可能性あり/実環境での確認が必要/誤検出)、チェックリストで認可や設計も見たうえで、修正コードつきのレポートを書きます。Claude、Codex、Hermes Agent、Cursor で使えます。

必要な環境

  • Python 3(標準ライブラリのみ)。読み取り専用で、ネットワークには接続しません
  • 依存パッケージの脆弱性確認には、別途 pip-audit や npm audit が使える環境が必要です(なくてもレビューはできます)

注意点

  • パターンによる静的チェックなので、誤検出も見逃しもあります。「検出なし」は安全の証明ではありません
  • データの流れの追跡は1ファイル内の簡易的なものです。ファイルをまたぐ流れ、認可ロジックの誤り(IDOR)、業務ロジックの欠陥はスクリプトでは見つからず、チェックリストに沿ったエージェントの確認が前提です
  • ルートの認証の有無は名前からの推定です
  • 実際に攻撃を試す診断(ペネトレーションテスト)は行いません
  • examples/ のサンプルアプリは意図的に脆弱に作ってあります。実際に動かして公開しないでください
English description

Reviews Flask, Django, FastAPI, Express and Next.js code against the OWASP Top 10 (2021) and writes a findings report with severity, file:line evidence, exploit scenario and fix code.

What it does

Reviews the source code of Python (Flask, Django, FastAPI) and Node (Express, Next.js API routes) web apps against the OWASP Top 10 (2021). The bundled scripts do the mechanical sweep; the agent verifies and judges.

  • Route inventory (route_inventory.py): lists Flask, FastAPI, Django (urls.py plus views), DRF, Express and Next.js (pages/api and app/**/route.ts) routes with method, path, handler, file:line and hints for auth, CSRF exemption and rate limiting. Flags state-changing routes with no auth hint and similar review targets
  • Risk pattern scan (sec_scan.py), about 30 rule types: SQL built by concatenation or f-strings, shell execution, eval, template injection, NoSQL operator injection, XSS sinks (|safe, dangerouslySetInnerHTML, innerHTML and more), path traversal, SSRF, pickle and yaml.load, open redirects, missing or disabled CSRF protection, cookies without Secure/HttpOnly/SameSite, CORS *, debug mode, weak random for tokens, MD5 and fast hashes for passwords, JWT without signature verification or alg none, hardcoded SECRET_KEY (masked), mass assignment, XXE
  • A single-file taint heuristic checks whether request data reaches the sink and sets a confidence level (high/medium/low)
  • Output as console text, JSON, a Markdown report draft and SARIF. Inline suppression comments and a baseline file for re-reviews
  • Manual checklist per OWASP category (authorization and IDOR, insecure design, vulnerable components) plus framework quick checks
  • Fix guides per rule with before/after code for Python and Node and the regression test to add
  • Triage guide and report template: common false positives, common blind spots, severity rubric, findings report template, and a worked example with real output

How to use

python scripts/route_inventory.py path/to/app --md routes.md
python scripts/sec_scan.py path/to/app --json scan.json --md scan-draft.md --fail-on never

The agent checks each finding in the code (confirmed, likely, needs runtime check, false positive), walks the checklist for authorization and design issues, and writes a report with fix code. Works with Claude, Codex, Hermes Agent and Cursor.

Requirements

  • Python 3 (standard library only). Read-only, no network access
  • Dependency vulnerability checks need pip-audit or npm audit available separately (the review works without them)

Caveats

  • Static pattern matching has false positives and false negatives. No findings is not proof of security
  • Data-flow tracking is a simple single-file heuristic. Cross-file flows, broken authorization (IDOR) and business logic flaws are not found by the scripts and rely on the agent following the checklist
  • Route auth status is inferred from names
  • No live attack testing (penetration testing) is performed
  • The sample app in examples/ is deliberately vulnerable; never deploy it

インストール方法

  1. ダウンロードしたZIPを展開します(中に web-app-security-review/ フォルダと SKILL.md があります)。
  2. フォルダごと、使うエージェントのスキル置き場にコピーします。
    • Claude:~/.claude/skills/(プロジェクト単位なら .claude/skills/)
    • Hermes Agent:~/.hermes/skills/
    • Codex:~/.agents/skills//Cursor:~/.cursor/skills/
    • Claude アプリ(claude.ai):「カスタマイズ → スキル」からZIPをアップロード
  3. エージェントを再起動し、スキル一覧に表示されることを確認します。

Windows・Mac 別、エージェント別のインストール手順

出品者

HackStar

Skills that make everyday developer work faster and safer: Git, testing, APIs and security.

出品スキル 8 件

出品者のプロフィールとスキル一覧