Production containers do not expose SSH port 22 or RDP
Why it matters
SSH port 22 exposed in a production container provides a persistent shell entry point for brute-force and credential-stuffing attacks — every host scanner on the public internet probes port 22 continuously (CWE-284, NIST 800-53 CM-7). A container with sshd installed adds unnecessary attack surface: the application has no need for interactive sessions, and any credential compromise or key leak provides direct OS access bypassing all application-layer controls. CIS Docker 5.6 explicitly prohibits SSH in containers. Kubernetes provides kubectl exec as the authenticated, audited alternative for debugging.
Severity rationale
Low because SSH exposure requires a credential or key compromise to pivot to shell access, but the port being open makes brute-force and credential-stuffing attacks automatic.
Remediation
Remove all SSH-related packages and EXPOSE directives from production Dockerfiles. Audit with:
grep -r 'EXPOSE 22\|openssh\|sshd\|ssh-server' Dockerfile*
For debugging and interactive access use kubectl exec with RBAC controls:
# Requires 'pods/exec' verb in RBAC — scope to specific service accounts
kubectl exec -it <pod-name> -n production -- /bin/sh
If jump-host access to nodes is required, use AWS SSM Session Manager, GCP IAP tunneling, or Azure Bastion — these route through cloud IAM and produce audit logs without opening port 22. Remove the openssh-server package from base images: RUN apt-get remove --purge openssh-server.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Infrastructure Hardening Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-284 — Improper Access Control
- nist:rev5 · CM-7 — Least Functionality
- external · CIS-Docker-5.6 — CIS Docker Benchmark v1.6 §5.6 — Do not run SSH within containers
- soc2:2017 · CC6.6 — Protection against threats from outside system boundaries
Taxons
History
- 2026-04-18·v1.0.0·Initial import from infrastructure-hardening·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.6) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2