container-security-hardening
>
它会碰到什么
扫了多少5 个文本文件,61 KB
它会碰到什么读凭据写文件执行命令联网
命中总数9 处
命中统计严重 4 · 高 2 · 中 0 · 低 0
逐条看命中(6 条严重或高危)
- 严重
references/detailed-guide.md:207cred-paths.github
- 严重
references/detailed-guide.md:208cred-paths.env
- 严重
references/detailed-guide.md:350cred-paths- public.ecr.aws
- 严重
SKILL.md:54cred-paths- [ ] `.dockerignore` excludes `.git`, `.env`, secrets, tests
- 高
references/base-image-comparison.md:152fs-destructive&& rm -rf /var/lib/apt/lists/*
- 高
references/base-image-comparison.md:235fs-destructive- [ ] Build cache cleaned in same `RUN` layer (`rm -rf /var/lib/apt/lists/*`, `npm cache clean --force`)?
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
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](references/detailed-guide.md) 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
USERdeclared beforeCMD/ENTRYPOINT - [ ] Base image pinned to
@sha256:...digest (not just tag) - [ ] No secrets in
ENV,ARG, orRUNcommands - [ ]
HEALTHCHECKdefined - [ ] OCI labels present (
org.opencontainers.image.*) - [ ]
.dockerignoreexcludes.git,.env, secrets, tests - [ ]
ENTRYPOINTuses 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
- [ ]
.trivyignorehas justified entries for accepted CVEs
Runtime
- [ ]
--read-onlyfilesystem - [ ]
--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: truewith explicit UID - [ ]
capabilities.drop: ["ALL"] - [ ] Resource
requestsandlimitsdefined - [ ]
automountServiceAccountToken: false - [ ] Namespace PSA enforced at
restrictedlevel - [ ]
NetworkPolicydefault-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.
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
星标★ 46,490
本站分层T1
该仓技能数6676
原文件路径
skills/container-security-hardening/SKILL.md同一个仓库里的其他技能
同名技能的其他版本
有 3 个不同仓库或目录里都有叫 container-security-hardening 的技能。它们内容并不相同,别混用: