Communitygithub.com

lguidolin/多層防御セキュリティ

信頼できない入力、シークレット、認証/認可、依存関係を扱う場合や、新しい攻撃対象領域を脅威モデル化する際に使用します。キーワード: STRIDE、脅威モデル、最小権限、シークレット管理、サプライチェーン、依存関係スキャン、入力検証、監査ログ、多層防御。

多層防御セキュリティ とは?

このスキルは、AIエージェント(Claude Code、Cursor、Codexなど)がソフトウェア開発プロジェクトにおいてセキュリティ設計と実装をガイドするための包括的なフレームワークを提供します。多層防御(Defense in Depth)の原則に基づき、単一の防御層に依存せず、各層が相互に補完し合う設計を推進します。主なプラクティスとして、STRIDEモデルによる軽量な脅威モデリング、最小権限の原則の徹底、シークレットのランタイム取得とコード内への非埋め込み、信頼境界での入力検証、依存関係のロックとスキャン、そして監査ログの記録が含まれます。このスキルは、認可の最終的な実施レイヤーとしてRLS(Row-Level Security)、DoS対策としてGraphQLの深さ/コスト制限、シークレット管理にKey Vault、CIパイプラインでの依存関係監査とイメージスキャン(Trivyなど)を推奨しており、開発者が安全なシステムを構築するための実践的なチェックリストとして機能します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/defense-in-depth-security

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

多層防御セキュリティ は何をしますか?

概要

セキュリティは多層的であり、どの単一のレイヤーも失敗する可能性があることを前提とし、機能する最小の権限を付与します。攻撃者はあなたが忘れたレイヤーを見つけます——一つの壁に依存するシステムは、その壁に一つのバグがあれば崩壊しますが、重複する最小権限制御は、単一の障害が発生しても生き残ります。

原則(普遍的なもの)

  • 信頼できない入力、シークレット、またはユーザーデータを扱うものは、構築前に脅威モデル化する。 新しい面ごとに軽量なSTRIDEパス(なりすまし、改ざん、否認防止、情報漏洩、サービス拒否、権限昇格)を実施します。モデルと緩和策を記録します(recording-decisionsを参照)。
  • 多層防御。 単一の制御が「唯一の」セキュリティではありません。認証、認可、入力検証、データレイヤーの強制は、それぞれ他のものがバイパスされる可能性があると想定します。
  • あらゆる場所で最小権限 — ロール、トークン、サービスアカウント、DB権限。デフォルトはアクセスなし。最小限を付与し、未使用のものを取り消す。
  • シークレットはコード、イメージ、またはコミットされた設定に決して存在しない。 ランタイム時にシークレットストアから取得され、ローテーションされ、それを必要とするワークロードにスコープが制限されます。
  • 信頼境界ですべての入力を検証する。 すべての外部システムの出力を信頼できないデータとして扱い、決して命令としては扱いません。
  • 依存関係のサプライチェーンは攻撃対象領域である。 ロックファイルをコミットして整合性チェックを行い、依存関係をスキャンして更新し、ベースイメージを固定してスキャンします。
  • 機密性の高いアクションは監査される — 誰が、いつ、何をしたか — これにより悪用やミスを再現可能にします。

クイックリファレンス

対象面最初の質問
ユーザー入力を受け取る新しいエンドポイントSTRIDEモデルは?検証はどこ?機能する最小のロールは?
シークレットを含むものシークレットストアにあるか(コード/イメージではなく)?スコープは制限されているか?ローテーション可能か?
新しい依存関係ロックファイルは固定されているか?スキャンされたか?十分にサポートされているか?
特権を伴う変更監査されているか?アクターはデータレイヤーで認可されているか(アプリ層だけでなく)?

スタックの仕組み

最終的な実施レイヤーとしてのRLS、DoS制御としてのGraphQLの深さ/コスト制限、シークレット用のKey Vault、CIでのpnpm audit/Trivy — postgres-postgraphile-rls-and-sqlおよびcloud-delivery-aksを参照。

実施: CIでの依存関係監査 + イメージスキャン + シークレットスキャン(ブロッキング);脅威モデルと監査カバレッジはレビューアの判断に委ねられます。

完全な根拠: 憲法の第X条および第XIV条、engineering-constitution/references/engineering-constitution.mdにバンドルされています。

Individual skills in this repo

This repo contains 18 individual skills — each has its own dedicated page.

lguidolin/change-hygiene-and-code-craft

Use when writing or refactoring code, structuring a commit or PR, or deciding whether to abstract duplication. Symptoms — mixing reorg with logic changes, a PR doing several things at once, a file growing large, the second copy of similar code, or unsure whether to DRY something up.

lguidolin/cloud-delivery-aks

Use when deploying to Kubernetes or Azure Kubernetes Service (AKS), configuring cloud secrets, setting up progressive rollout/canary, per-PR ephemeral environments, or k8s health probes. Keywords — Kubernetes, AKS, Key Vault, Argo Rollouts, Flagger, canary, blue-green, liveness, readiness, PodDisruptionBudget, HPA, rollback, GHCR.

lguidolin/commit-history-rewrite

Use when an existing repository has messy commit history that needs to conform to conventional commits before adopting release-please, or when intermediate WIP/fixup/merge commits need to be cleaned up.

lguidolin/conventional-commits-and-releases

Use when committing, writing a commit message, opening a PR that will be squash-merged, or configuring automated versioning/changelogs. Keywords — conventional commits, release-please, semver, feat/fix/chore, breaking change, changelog.

lguidolin/designing-before-building

Use when starting a feature, fixing a non-trivial bug, or about to write implementation code — before any code exists. Symptoms you need this: "this is simple, I'll just code it", reaching for the editor before a design is approved, or an idea that hasn't been turned into a spec and plan.

lguidolin/engineering-constitution

Use when starting work in a project that follows the engineering constitution, orienting to its rules, or deciding which engineering practice applies to a task — spec writing, commits, testing, security, deploys, database, or UI work.

lguidolin/graphql-contract-testing

Use when writing a GraphQL query/mutation that the UI and a test will share, or building route/schema contract or smoke tests. Symptoms — copying a query into a test, a test asserting on query text, schema change that didn't break the UI build, or RLS/permission drift. Keywords — graphql-codegen, typed document, contract test, route smoke test.

lguidolin/init-repo-CI

Use when setting up a new repository with conventional commits, release-please, and CI automation, or when retrofitting an existing repository that lacks automated versioning and PR validation workflows.

lguidolin/interface-craft-and-accessibility

Use when building or styling UI — components, layouts, forms, design tokens — or making accessibility decisions. Keywords — a11y, WCAG, keyboard navigation, focus state, contrast, design system, minimalist UI, component reuse, ARIA, semantic HTML.

lguidolin/merge-gates-and-automation

Use when setting up or changing CI, pre-push hooks, or a task runner, or deciding what must pass before merge. Symptoms — tempted to put authoritative checks only in a local hook, skip CI, bypass with --no-verify, or unsure what gates a merge vs. runs locally.

lguidolin/observability-and-slos

Use when adding logging, metrics, tracing, health checks, SLOs, or alerting — or when building a service surface that needs to be operable and debuggable. Keywords — structured logs, OpenTelemetry, correlation id, RED metrics, liveness, readiness, SLI, SLO, error budget, alerting.

lguidolin/performance-and-scale

Use when working on hot paths, list endpoints, pagination, data-access in loops, or public interfaces/schemas. Symptoms — unbounded queries, N+1 access, no latency budget, optimizing without measuring, or changing an interface many consumers depend on. Keywords — pagination, N+1, Hyrum's Law, performance budget, bundle size.

lguidolin/postgres-postgraphile-rls-and-sql

Use when writing PostgreSQL, PostGraphile config, Row-Level Security policies, SQL schema files, or working on the Browser→App→PostGraphile→Postgres data path. Keywords — RLS, SECURITY DEFINER, search_path, pgSettings, grants, roles, GraphQL depth limit, query cost, statement_timeout, SQL file organization.

lguidolin/recording-decisions

Use when a design or architecture decision has been made and needs to be captured — writing a decision record or ADR, updating a decision index, noting a deferred idea, or superseding a past decision. Keywords — ADR, decision record, rationale, rejected alternatives, dependency index.

lguidolin/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

lguidolin/ship-it

Use when the user wants to ship work — push, PR, archive decision records, merge, and clean up. Handles the full lifecycle from committing final changes through post-merge cleanup including converting specs/plans to compact decision records.

lguidolin/tests-as-a-control

Use when writing or modifying tests, when a test breaks during a refactor, or when testing permission/role rules. Symptoms — tempted to edit a test to make it pass, testing only the happy path, a deny-test that started passing, flaky tests, or unsure what to assert.

lguidolin/zero-downtime-migrations

Use when changing a database schema where data must survive the change — adding/removing/renaming columns, constraints, indexes, or backfilling. Symptoms — a destructive migration bundled with a code deploy, a NOT NULL column with a backfill, a table-locking UPDATE, or a rename. Keywords — expand/contract, parallel change, backfill, NOT VALID, CREATE INDEX CONCURRENTLY, graphile-migrate.

関連スキル