Performing Container Image Hardening
Overview
Cybersecurity skill for performing container image hardening. Follows industry best practices and security standards.
When to Use
Trigger phrases:
"performing container image hardening"
"This skill covers hardening container images by minimizing attack surface, remov"
When building production container images that need minimal attack surface
When compliance requires CIS Docker Benchmark adherence for container configurations
When reducing image size to minimize vulnerability exposure from unused packages
When implementing defense-in-depth for containerized workloads
When migrating from fat base images to distroless or minimal images
Do not use for runtime container security monitoring (use Falco), for host-level Docker daemon hardening (use CIS Docker Benchmark host checks), or for container orchestration security (use Kubernetes security scanning).
When NOT to Use
- When you lack proper authorization for testing
- For production systems without change management
- When the task requires legal or compliance expertise beyond technical scope
Prerequisites
- Docker or BuildKit for multi-stage builds
- Base image options: distroless, Alpine, slim, or scratch
- Container scanning tool (Trivy) for validation
- CIS Docker Benchmark reference
Workflow
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- Plan Operations — Define objectives, scope, and success criteria for container image hardening operations.
- Prepare Environment — Set up tools, access, and data sources required for container image hardening.
- Execute Core Workflow — Perform the container image hardening operations following established procedures.
- Validate Results — Verify that results meet quality standards and objectives.
- Report Findings — Document results, observations, and recommendations.
- Follow Up — Track remediation actions and verify fixes where applicable.
Tools
- Analysis Platform — Data processing and visualization
- Collaboration Tools — Team coordination and knowledge sharing
Process
- Design — Define interface, identify patterns, plan implementation
- Implement — Write code following existing conventions, add tests
- Verify — Run tests, check integration, validate behavior
Verification
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: performing-container-image-hardening3description: Use when this skill covers hardening container images by minimizing attack4 surface, removing unnecessary packages, implementing multi-stage builds, configuring5 non-root users, and applying CIS Docker Benchmark recommendations to produce secure6 production-ready images.7domain: cybersecurity8tags:9- devsecops10- cicd11- container-hardening12- docker13- cis-benchmark14- secure-sdlc15subdomain: devsecops16version: 1.0.017author: oyi7718license: Apache-2.019nist_csf:20- PR.PS-0121- GV.SC-0722- ID.IM-0423- PR.PS-0424category: cybersecurity25metadata:26 source: https://skillmd.com/skills/oyi77/performing-container-image-hardening27---2829# Performing Container Image Hardening3031## Overview3233Cybersecurity skill for performing container image hardening. Follows industry best practices and security standards.3435## When to Use36**Trigger phrases:**37- "performing container image hardening"38- "This skill covers hardening container images by minimizing attack surface, remov"394041- When building production container images that need minimal attack surface42- When compliance requires CIS Docker Benchmark adherence for container configurations43- When reducing image size to minimize vulnerability exposure from unused packages44- When implementing defense-in-depth for containerized workloads45- When migrating from fat base images to distroless or minimal images4647**Do not use** for runtime container security monitoring (use Falco), for host-level Docker daemon hardening (use CIS Docker Benchmark host checks), or for container orchestration security (use Kubernetes security scanning).484950## When NOT to Use5152- When you lack proper authorization for testing53- For production systems without change management54- When the task requires legal or compliance expertise beyond technical scope555657## Prerequisites5859- Docker or BuildKit for multi-stage builds60- Base image options: distroless, Alpine, slim, or scratch61- Container scanning tool (Trivy) for validation62- CIS Docker Benchmark reference6364## Workflow6566```python67# Example: IOC detection68import re6970IOC_PATTERNS = {71 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",72 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",73 "hash_md5": r"\b[a-f0-9]{32}\b",74 "hash_sha256": r"\b[a-f0-9]{64}\b",75}7677def extract_iocs(text: str) -> dict:78 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}79```80811. **Plan Operations** — Define objectives, scope, and success criteria for container image hardening operations.822. **Prepare Environment** — Set up tools, access, and data sources required for container image hardening.833. **Execute Core Workflow** — Perform the container image hardening operations following established procedures.844. **Validate Results** — Verify that results meet quality standards and objectives.855. **Report Findings** — Document results, observations, and recommendations.866. **Follow Up** — Track remediation actions and verify fixes where applicable.8788## Tools8990- **Analysis Platform** — Data processing and visualization91- **Collaboration Tools** — Team coordination and knowledge sharing929394## Process95961. **Design** — Define interface, identify patterns, plan implementation971. **Implement** — Write code following existing conventions, add tests981. **Verify** — Run tests, check integration, validate behavior99100## Verification101102- [ ] All container image hardening procedures executed completely and documented103- [ ] Findings validated against multiple data sources104- [ ] False positives identified and filtered105- [ ] Results documented with evidence and timestamps106- [ ] Recommendations provided with risk-based prioritization107108## Anti-Rationalization Table109110| Rationalization | Reality |111|---|---|112| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |113| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |114| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |