跳到正文
Skillpedia
安全48k · #4244

container-security-hardening

它能做什么

这个工具能帮助你让程序(即“容器”)更加安全。它会检查已知的安全漏洞,确保程序以最小必要权限运行,并帮助防范攻击。

适用场景

  • ✓当你想检查构建容器的代码是否安全时。
  • ✓当你需要查找并修复现有容器中的安全漏洞时。
  • ✓当你想确保容器在生产环境中安全运行时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/container-security-hardening/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/container-security-hardening/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我怎样才能让我的 Docker 容器更能抵御攻击?”

每周 5 个新技能,1 分钟读完。

工作原理

它会分析容器构建代码(Dockerfile)以及正在运行的容器。它会检查不安全的配置、已知漏洞(CVE),并采取一些安全措施,比如不以管理员权限运行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Container Security Hardening Skill

A production-focused guide for building, scanning, and running containers securely — from Dockerfile authoring through runtime enforcement and supply chain integrity.


Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

When to Use This Skill

  • User mentions Docker security, container hardening, or Dockerfile security review
  • User asks about distroless images, non-root containers, or read-only filesystems
  • User wants to scan images for CVEs with Trivy, Grype, or Snyk
  • User mentions seccomp, AppArmor, Linux capabilities, or runtime security
  • User asks "is my Dockerfile secure?" or "how do I reduce my image attack surface?"
  • User wants to sign/verify images with Cosign or generate SBOMs
  • User asks about Kubernetes pod security, NetworkPolicy, or RBAC hardening
  • User says "fix container CVEs" or "harden my container for production"

When NOT to Use This Skill

  • The user is primarily asking about GitHub Actions CI/CD → recommend github-actions-advanced
  • The user needs general Docker usage help (not security) → recommend docker-expert
  • The user is working with Kubernetes orchestration beyond security → recommend kubernetes-architect
  • The user needs application-level security (SQL injection, XSS) → recommend api-security-best-practices

Security Checklist

Dockerfile

  • Minimal base image (distroless, slim, or alpine — not full debian/ubuntu)
  • Multi-stage build — no build tools, devDependencies, or compilers in runtime image
  • Non-root USER declared before CMD/ENTRYPOINT
  • Base image pinned to @sha256:... digest (not just tag)
  • No secrets in ENV, ARG, or RUN commands
  • HEALTHCHECK defined
  • OCI labels present (org.opencontainers.image.*)
  • .dockerignore excludes .git, .env, secrets, tests
  • ENTRYPOINT uses exec form, not shell form

Image Scanning

  • Trivy or Grype scan in CI (fails on HIGH/CRITICAL)
  • Hadolint passes with no warnings
  • Secret scan run on image (trivy --scanners secret)
  • SBOM generated and stored
  • .trivyignore has justified entries for accepted CVEs

Runtime

  • --read-only filesystem
  • --cap-drop ALL (add back only what's documented as required)
  • --security-opt no-new-privileges:true
  • --security-opt seccomp=<profile> applied
  • Resource limits set (--memory, --cpus, --pids-limit)
  • Image signed with Cosign; verified before deploy

Kubernetes

  • readOnlyRootFilesystem: true
  • allowPrivilegeEscalation: false
  • runAsNonRoot: true with explicit UID
  • capabilities.drop: ["ALL"]
  • Resource requests and limits defined
  • automountServiceAccountToken: false
  • Namespace PSA enforced at restricted level
  • NetworkPolicy default-deny applied
  • RBAC uses specific resource names and minimal verbs

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific penetration testing or a formal security audit.
  • Seccomp profiles and AppArmor are Linux-only; macOS/Windows Docker Desktop uses different mechanisms.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题

什么是“容器”?

容器是把程序和它运行所需的一切(如库和设置)打包在一起的包裹。它们让程序在不同的电脑上都能保持一致地运行。

什么是“CVE”?

CVE 是英文 Common Vulnerabilities and Exposures 的缩写,意为“通用漏洞披露”。它指的是已被识别的软件安全漏洞,攻击者可能利用这些漏洞发动攻击。

“加固”是什么意思?

加固是指通过减少系统或软件的“攻击面”并防范漏洞,使其更加安全的过程。

详情

作者的原始描述

Harden Docker/container images and runtime deployments with secure base images, non-root users, CVE scanning, SBOM/signing, seccomp/AppArmor, and Kubernetes pod security controls. Use for Dockerfile security reviews, container CVEs, image scanning, distroless images, or production hardening.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4244
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能