防护思路
点击放大

A portable defensi security and AI-agent security skill for de, founders, DevOps engineers, and security practitioners. Covers secure design, secure code review, infrastructure hardening, identity, privacy, incident response, management, and AI/LLM agent security.
Built on: OWASP, NIST 800-53 / 800-63B, CIS Benchmarks, OWASP ASVS.
---
README.md for install, release channels, onboarding, and documentation licensing.This repository is licensed under the Apache License, 2.0. See LICENSE and NOTICE. If a file includes a different attribution or third-party restriction, that notice controls for that material.
---
SKILL.md when re AI-generated patches.When re or hardening AI-generated code:
Local Semgrep rules li semgrep/. The runbook is references/appsec/ai-code-secure-remediation.md.
Example prompts:
---
This corpus now explicitly incorporates recent official cybersecurity guidance and deployment signals from OpenAI, Google, and Anthropic:
GPT-5.3-Codex can work autonomously for hours or days on complex cyber tasks, and pairs that capability with identity , classifier-based monitoring, and trust-based access for higher-risk workflows. Source: OpenAI - Introducing Trusted Access for CyberData Poisoning, Prompt Injection, and Model Source Tampering to risk assessment and mitigation guidance for AI systems. Source: Google - SAIF Risk AssessmentBig Sleep agent found a real-world security flaw at risk of exploitation, reinforcing the case for AI-assisted defense with strong go. Source: Google - A summer of security: empowering cyber defenders with AIClaude Mythos Preview can surpass all but the most skilled humans at finding and exploiting software , so access is being limited to defensi rather than opened broadly. Source: Anthropic - Project GlasswingMythos Preview on its official system cards page, which is the canonical public entry point for the model's capability and safety documentation. Source: Anthropic - Model system cardsThe practical implication for this repository is simple: as cyber-capable models improve, the default answer is not to give them more power. The default answer is to impro, logging, trust separation, incident response, and recovery.
---
This repository is designed as a portable security knowledge base. It is primarily packaged as a Claude Code skill, but the same SKILL.md + references/ corpus can be loaded into any AI coding assistant. Installation guides for all major tools are below.
v1.0.0 is the last pre-refactor portable snapshot for existing consumers.v2.0.0-rc.1 contains the changes produced by phases 1-6 of the refactor.main may mo of both tags during ongoing refactor work.If the assistant supports agentskill.sh, give it this exact instruction:
agentskill.sh is a third-party skill installer. Review its source before trusting it in CI or on a shared machine.
The official install paths are documented below.
If you want the refactor preview instead, use:
---
Claude Code loads skills from folders that contain a SKILL.md file. Clone the repository into your personal skills folder:
In Windows PowerShell 5.1, use $HOME\.claude\skills\security-hardening as the target folder.
To enable the skill for a single project only, clone it into .claude/skills/security-hardening at the project root instead.
Start a new Claude Code session. Claude Code loads SKILL.md and reads the references/ files when a security task matches the skill description.
---
Claude on the web supports Skills and Projects with attached files.
Option A - Skills (recommended):
1. Open claude.ai > Settings > Capabilities > Skills > Create skill.
2. Name it security-hardening.
3. Upload SKILL.md and every file under references/ (drag-and-drop the folder).
4. The skill activates automatically on security questions.
Option B - Project knowledge:
1. Create a new Project named "Security Hardening".
2. In Project knowledge, upload SKILL.md + the references/ folder (zip if needed).
3. Paste the body of SKILL.md into the Custom instructions field so the model always applies the workflow.
---
Gemini CLI reads context from GEMINI.md files and supports extensions.
Option A - Project context (per-repo):
Option B - Global context (all projects):
Gemini CLI loads GEMINI.md automatically at session start. Reference indi files inline with @.gemini/security-references/appsec/owasp-top10.md.
---
Option A - Custom GPT (shareable):
1. Go to chatgpt.com/gpts/editor > Create.
2. Name: Security Hardening Auditor.
3. Instructions: paste the contents of SKILL.md.
4. Knowledge: upload every file under references/ (max 20 files per GPT - if you exceed the limit, zip rarely-used references or split into two GPTs by category).
5. Capabilities: enable Code Interpreter for log/config parsing.
6. Save and pin to your sidebar.
Option B - Project (single account):
1. Create a new Project in ChatGPT.
2. Add SKILL.md content as Project instructions.
3. Upload references/*.md to Project files.
4. Every chat in that Project will use the security knowledge base.
---
Codex CLI reads AGENTS.md files (project-level and global) for persistent instructions.
Option A - Per-repo:
Option B - Global (all repos):
Codex loads AGENTS.md from the working directory and ~/.codex/AGENTS.md globally on every session.
---
Copy the GitHub Actions workflow into your own project to get automated security scanning on every push:
The repository now ships ready-to-copy profiles under templates/ai-tool-profiles/ for:
Claude CodeCodexGemini CLICursorIt also ships posture o under templates/ai-tool-profiles/postures/ for:
solostartupprod-sensitivegdpr-sensitivePremerged bundles are a under templates/ai-tool-profiles/bundles/ for:
claude-code-prod-sensitivecursor-prod-sensitivegemini-cli-prod-sensitivecodex-gdpr-sensitiveno-code-gdpr-sensitiveSee references/ai/ai-tool-profiles.md for base-profile selection, bundle selection, and exact copy paths per tool.
Once installed, the skill activates on prompts like:
If your goal is "defense first", work through the corpus in this order:
1. references/ops/defensi.md
2. references/ai/quick-start-ai-coding.md + references/ai/ai-cli-hardening.md
3. references/ai/ai-ide-no-code-security.md
4. references/ops/secret-leak-pre.md + references/ops/pre-push-checklist.md
5. references/privacy/pri.md + references/privacy/gdpr-security-ops.md
6. references/ai/ai-agent-incident-response.md + references/ops/incident-playbooks.md
---
---
references/appsec/owasp-top10.mdCovers: Broken Access Control, Cryptographic Failures, Injection, Insecure Design, Security Misconfiguration, Components, Auth Failures, Integrity Failures, Logging Failures, SSRF.
references/appsec/database-security.mdreferences/appsec/webhooks-security.mdreferences/appsec/threat-modeling.mdreferences/appsec/api-security.mdCovers: BOLA/IDOR, BFLA, mass assignment, rate limiting, JSON schema , SSRF, secure error handling, webhook signature , GraphQL depth/complexity limits, pagination security.
references/appsec/graphql-security.mdCovers: object and field-le, introspection disablement, depth and complexity budgets, alias/batching caps, persisted queries, multipart upload risks, WebSocket subscriptions, telemetry, and N+1 / backend fan-out abuse.
references/appsec/secure-headers.mdCovers: HSTS, CSP (nonce/hash-based), X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COEP/COOP/CORP, cookie attributes (Secure, HttpOnly, SameSite), CORS, headers to remo blocks for Nginx and Cloudflare Workers.
references/appsec/browser-security-modern.mdCovers: Trusted Types, Subresource Integrity (SRI), COOP/COEP/CORP isolation, Permissions Policy, Worker / WebSocket / WASM surfaces, and report-only rollout strategy for legacy frontends.
references/appsec/language-patterns.md| Language | Patterns covered |
|----------|-----------------|
| Node.js / Ja | Command injection, eval, prototype pollution, path tra, NoSQL injection |
| Python | Command injection, eval/exec, pickle.loads, path tra, SSTI (Jinja2) |
| PHP | Command injection, eval, file inclusion, SQL injection, extract() |
| Go | Template injection, command injection, path tra, SQL injection |
| Ruby | Command injection, eval/ERB, Marshal.load, mass assignment |
| Java | SQL injection, XXE, unsafe deserialization |
| PowerShell | In, command injection, path tra, Con -AsPlainText, TLS bypass, download-and-run, ExecutionPolicy myth, PSScriptAnalyzer rules |
| Bash / POSIX shell | Word splitting, unquoted $var, missing set -Eeuo pipefail, find/xargs injection, curl \| sh, temp file races, secrets in argv, IFS/PATH tampering, shellcheck rules |
references/ops/secret-leak-pre.md.gitignore security template.Includes: per-provider re steps (OpenAI, AWS, GitHub, Stripe, GCP, Slack...), a detection table with regex patterns, frontend-safe key matrix, 8 common leak traps, and secrets manager examples (Vault, AWS Secrets Manager, SOPS, Doppler).
references/ai/quick-start-ai-coding.mdCovers: secret detection, dangerous patterns (e=True/pickle), IDOR pre, password hashing, frontend key safety, error message leaks, input , TLS , dependency audit, and a quick-reference card.
references/ops/pre-push-checklist.mdgit push. Organized by category with copy-paste grep commands for quick scanning.Covers: secrets, dangerous patterns, auth/authorization, input/output, sensitive data, dependencies, configuration, and frontend-specific checks.
references/appsec/production-error-handling.mdCovers: generic error responses with reference IDs, correct HTTP status codes (401 vs 403 vs 404), removing ser, what to log log, log field redaction (Pino, Zap, structlog), startup config (fail-fast if secrets missing), debug mode risks, and CORS error response safety.
references/ai/.mdCovers: eval, pickle.loads, shell=True, SHA-256 for passwords, CORS wildcard with credentials, file upload without , logging PII/tokens, disabling TLS , Docker as root, mass assignment, missing rate limiting, trusting frontend for roles.
---
references/appsec/secure-headers.mdreferences/infra/rate-limiting-infrastructure.mdCovers: Nginx examples, Redis-backed counters, per-route and per-identity quotas, Retry-After, 429 telemetry, proxy trust pitfalls, and abuse-specific limit design for login, OTP, search, uploads, and GraphQL.
references/infra/iot-ot-security.mdCovers: Purdue Model segmentation (IT/OT DMZ), default credential elimination, legacy protocol risks (Modbus, DNP3, BACnet, PROFINET), firmware/patch management, passive OT monitoring, OT-specific incident response (safety-first containment).
---
references/iam/authorization-rbac.mdCovers: RBAC implementation, ABAC with OPA, ReBAC with OpenFGA, deny-by-default, IDOR/BOLA safe patterns, common anti-patterns (frontend-only check, role from client payload), 404 vs 403 strategy.
references/iam/session-management.mdCovers: session rotation after login or pri change, ser in, logout-all-devices, idle and absolute timeouts, fixation pre, refresh-token re, cookie baselines, and concurrent session handling.
references/iam/webauthn-fido2.mdCovers: RP ID and origin , challenge lifecycle, registration/authentication ceremonies, passkeys, user- defaults, attestation decisions, counter handling, and secure recovery design.
references/iam/acti.mdCovers: Tiering Model (Tier 0/1/2), LAPS, disabling SMBv1 / LLMNR / NTLMv1, Kerberoasting and AS-REP Roasting mitigations, gMSA, Protected Users group, Conditional Access, PIM (just-in-time ele), risky sign-in monitoring. Tools: BloodHound, PingCastle, Purple Knight.
---
references/platform/mobile-security.mdCovers: Keychain/Keystore secure storage, certificate pinning, cleartext traffic pre, binary protections (ProGuard, obfuscation), root/jailbreak detection, permission least pri, PII in logs, debuggable=false. Tools: MobSF, Frida, objection, Drozer.
references/platform/desktop-app-security.mdCovers: Buffer o, format string injection, compiler hardening flags (ASLR, DEP, stack canaries), C# deserialization (BinaryFormatter), XXE, DLL hijacking mitigations, Electron secure configuration (nodeIntegration: false, contextIsolation: true, sandbox: true, IPC ). Tools: Process Monitor, Electronegativity, AddressSanitizer.
references/platform/endpoint-.mdCovers: Dangerous (Shell, WScript, ADODB), AMSI integration, macro signing, AppLocker/WDAC application whitelisting, Credential Guard, EDR deployment, BitLocker/FileVault, local admin rights removal. Tools: CIS-CAT Lite, OSQuery, Sysinternals Autoruns.
---
references/ops/social-engineering-physical.mdCovers: Email authentication (SPF, DKIM, DMARC p=reject), phishing-resistant MFA (FIDO2/WebAuthn), AiTM bypass risks, simulated phishing (GoPhish), CEO fraud / IBAN change procedures, clean desk policy, badge access control, tailgating pre, MDM remote wipe, security awareness program KPIs.
---
references/ops/defensi.mdCovers: priority account hardening (password manager + FIDO2), separate admin accounts, full-disk encryption, browser/profile separation, safe AI usage, BEC-resistant payment , travel mode, immutable backups, SaaS/SSO hardening, and a 30-minute / 7-day / 30-day rollout plan.
---
references/ai/llm-agent-security.mdCovers: Prompt injection (direct and indirect), sensitive data disclosure , excessi, RAG poisoning, secrets in system prompts, agentic action audit logging, tool permission tiers (Level 0-3), output before execution, MCP ser (authentication, tool allowlists, sandboxing), plus official provider signals from OpenAI, Google, and Anthropic including Claude Mythos Preview.
references/ai/browser-computer-use-security.mdCovers: sandbox/, domain allowlists, session hygiene, uploads/downloads, credential entry boundaries, login and publish confirmations, local-OS spillover risk, screenshot/action telemetry, and release gates for browser/computer-use before widening scope.
references/ai/mcp-security.mdCovers: Excessi (HITL confirmation patterns, least-pri Docker/ configs, narrow endpoint design), Indirect Prompt Injection via MCP (step-by-step attack chain, LLM-as-a-Judge sanitization, chained-action pre), Ser and malicious manifests (allowlist enforcement, static manifest , supply chain audit), Path Tra and SSRF in MCP tool parameters (Python for read_file and fetch_url, Pydantic schema enforcement, SSRF blocklist with private ranges and AWS IMDS).
references/ai/rag-retrie.mdCovers: corpus trust tiers, retrie authorization, attribute filtering, o top-k retrieval, lifecycle and expiration, e deletion gaps, source attribution, document poisoning, and cross-tenant leakage in shared stores.
references/ai/hostile-corpus-review.mdCovers: trust tiering, ingest-without-executing, normalization, hidden-instruction stripping, known-bad pattern scanning, fact- separation, quarantine decisions, and before adoption.
references/ai/ai-cli-hardening.mdCovers: default-deny permissions, tiered ele model (read-only to high-impact actions), policy-as-code template, prompt/context firewall controls, secret-safe workflows, Git/release integrity controls, CI guardrails, and maturity roadmap by team size.
references/ai/ai-tool-profiles.mdCovers: exact template paths, posture o, premerged bundle selection, direct copy paths for the repository's conser presets, and links to official documentation used for the field names or behavior.
references/ai/ai-ide-no-code-security.mdCovers: Cursor-style workspace risks, extension/plugin trust, public preview exposure, connector scope sprawl, ser ownership, prompt/data hygiene, publish gates, exportability, and human review areas that cannot be delegated to the tool.
references/ai/agent-e.mdCovers: release-gate design, hostile-fixture families, excessi checks, MCP/tool abuse scenarios, telemetry expectations, regression metrics, and how to turn incidents or near misses back into standing e.
references/ai/ai-agent-incident-response.mdCovers: se model, first 15-minute containment steps, e collection, timeline reconstruction, blast radius analysis, eradication/recovery, communication template, and post-incident hardening actions specific to agentic systems.
---
references/privacy/gdpr-security-ops.mdCovers: data in, RoPA, technical and organizational measures, DPA / SCC / TIA checks, breach notification timeline, DSAR/delete/export workflows, e pack for audits, and common red flags.
references/privacy/pri.mdCovers: PII categories and what counts as sensitive in logs, structured log redaction (Pino redact, Zap custom fields, Python logging), automated log scanning for PII patterns, retention policy template per data category (logs 90d, transactions 7y, sessions TTL), scheduled anonymization/deletion jobs (Django + SQL), GDPR right to erasure implementation (multi-system erasure service), PII in exception reporting (Sentry send_default_pii=False, scrubbing hook), sensitive data in support dumps and backups (encryption), analytics data minimization (userId only, no email/phone), session recording masking (FullStory, LogRocket, Hotjar).
references/ops/.mdCovers: lifecycle diagram, finding sources and signal quality (SAST/SCA/DAST/secrets), se classification with context adjustment rules (internet-facing = bump up, auth required = bump down), SLA table (Critical 24h, High 7d, Medium 30d, Low 90d), triage decision tree (reachable? exploitable? blast radius? mitigating controls?), triage outcome classification (fix/accept/false positive/not applicable/compensating control), false positi with in-code suppression justification (nosemgrep/noqa with mandatory comment), risk acceptance template (expiry, dual approval, compensating controls), compensating controls per type, metrics dashboard (MTTR, SLA compliance rate, recurring types), dependency reachability analysis (go, tri).
---
references/ops/security-impro.mdAxes: code security, authentication, infrastructure, supply chain, CI/CD De, monitoring/incident response, offensi.
references/ops/detection-engineering.mdCovers: Sigma-style rules, threshold guidance, required log sources, and example detections for credential stuffing, token replay, IDOR/BOLA, GraphQL introspection or alias abuse, IMDS probing, suspicious AI tool sequences, Kubernetes secret/exec abuse, and CI/CD tampering.
references/appsec/frontend-frameworks-security.mdCovers: SSR data leaks - __NEXT_DATA__ exposes full DB objects in HTML (audit command, fix pattern for getSer / useAsyncData / RSC), DOM-based XSS in React (dangerouslySetInnerHTML + DOMPurify, ja: href injection) and Vue (), Prototype Pollution (attack chain via __proto__, lodash/jQuery/qs , Object.freeze and structuredClone mitigations), client-side secret exposure (NEXT_PUBLIC_ trap, bundle audit), CSRF in SPAs (double-submit cookie pattern), nonce-based CSP with Next.js middleware.
references/infra/supply-chain-security.mdCovers: SLSA framework (levels 0-3, requirements table, GitHub Actions pro workflow with slsa-github-generator), SBOM generation (Syft and Trivy, SPDX and CycloneDX, CI attachment, CVE scan against SBOM), Dependency Confusion attack and mitigations (npm scoped packages, pip --index-url vs --extra-index-url, hash pinning), Cosign/Sigstore keyless image signing and , gitsign for commit signing, GitHub Actions hardening (commit SHA pinning, OIDC instead of static keys, minimal permissions per job), dependency scanning (npm audit, pip-audit, go, OpenSSF Scorecard).
references/appsec/applied-cryptography.mdCovers: password hashing (Argon2id vs MD5 - why fast hashes are wrong), authenticated encryption (AES-256-GCM and ChaCha20-Poly1305 with encrypt/decrypt examples in Python/Node.js/Go), asymmetric algorithm selection table (Ed25519, ECDSA P-256, RSA), TLS 1.3 configuration, CSPRNG usage (secrets, crypto.randomBytes, crypto/rand), HMAC hash, quick reference table (use case / recommended / never use), CWE mapping for 8 common crypto mistakes.
references/compliance/cwe-owasp-mapping.mdCovers: injection, authentication, access control, cryptography, secrets, supply chain. Includes quick tool command reference (Semgrep, Bandit, Gosec, Gitleaks, Tri ZAP).
references/compliance/compliance-mapping.mdCovers: high-le toward SOC 2, ISO 27001:2022, PCI-DSS v4.0, HIPAA, GDPR/RGPD, NIS2, and DORA, plus the e types auditors usually expect for technical and organizational controls.
references/ops/security-audit-levels.md| Level | For who | Time | Key focus |
|-------|---------|------|-----------|
| 1 | Solo dev / MVP | 30-90 min | Secrets, deps, basic headers, dangerous patterns |
| 2 | Live app with users | Half-day to 1 day | IDOR, input , CORS, rate limiting |
| 3 | Production SaaS / team | 1-3 days | AuthZ model, supply chain, infra hardening, detection |
| 4 | Regulated / critical | Days to weeks | Threat model, pentest, fuzzing, red team |
Also includes a co matrix linking every reference file in this repo to its audit level(s).
references/appsec/security-testing-examples.mdCovers (pytest, Jest, Go): IDOR/authorization, rate limiting, GraphQL introspection/depth/alias/authz checks, file upload (extension, MIME, size, path tra, SVG XSS), SSRF (localhost, AWS metadata, private ranges), error handling (no stack trace, reference ID), security headers, webhook signature . Includes OWASP ZAP Docker baseline scan.
references/iam/cloud-iam-hardening.mdCovers: IAM least pri, no wildcard policies, MFA enforcement, S3/GCS/Blob public access pre, Secrets Manager usage, IMDSv2 (SSRF protection on EC2), CloudTrail audit logging, CI/CD OIDC (no long-lived keys), IaC scanning (Checko).
references/infra/container-k8s-hardening.mdCovers: non-root Dockerfiles, multi-stage builds, read-only filesystems, Tri scanning, K8s Pod Security Standards, network policies (default-deny), Secrets Secrets Operator or Vault, RBAC minimal roles, Kyverno admission policies, Cosign image signing.
references/ops/incident-playbooks.mdPlaybooks: compromised user account, webhook/integration token compromise, JWT signing secret leaked, cloud storage bucket exposed, errors/debug mode in production, CORS misconfiguration. Each follows Detect - Contain - In - Remediate - Review. Includes postmortem template.
references/compliance/co.mdreferences/appsec/security-myths.mdreferences/appsec/framework-examples.mdCovers: Express, NestJS, FastAPI, Django, Laravel, Spring Boot, Go (Gin).
---
.github/workflows/security.ymlJobs: Gitleaks (secret scanning), Semgrep (SAST), Tri scan (dependency CVEs, blocks on CRITICAL/HIGH), Syft SBOM generation (artifact upload), Dependency Review (blocks PRs introducing deps).
.github/pull_request_template.mdSections: input/output , authentication & authorization, privacy / GDPR, secrets & sensitive data, AI / automation, dependencies, network & API, code quality.
.github/dependabot.yml.github/CODEOWNERS---
| Standard / Tool | Link |
|----------------|------|
| OWASP Top 10 | |
| OWASP API Security Top 10 | |
| OWASP Mobile Top 10 | |
| OWASP LLM Top 10 | |
| OWASP ASVS | |
| OWASP Secure Headers | |
| NIST SP 800-82 Rev 3 (OT) | |
| NIST SP 800-63B (Auth) | |
| CIS Benchmarks | |
| MITRE ATT&CK for ICS | |
| MITRE ATLAS (AI/ML) | |
| OpenAI - Trusted Access for Cyber | |
| Google - SAIF Risk Assessment | |
| Google - A summer of security: empowering cyber defenders with AI | |
| Anthropic - Project Glasswing | |
| Anthropic - Model system cards | |
| Anthropic - Responsible Scaling Policy | |
| Mozilla Obser | |
| CISA ICS Ad | |
开发语言:Python
Star 数:3
该项目属于防护思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Portable defensive application security and AI-agent security skill for Claude Code, Codex, Gemini, and ChatGPT. Covers OWASP, secure design, secure code review, MCP security, prompt injection, threat modeling, incident response, and hardening.展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | security-hardening - Portable defensive application security and AI-age |
| 所属分类 | 防护思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-06 00:17:10 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 259 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |