Standard Container Scanning¶
Overview¶
Security Emphasis
This task implements security best practices including least privilege RBAC, short-lived tokens, and temporary credentials. The standard container scanning approach is the most secure scanning method for non-distroless containers.
-
Standard Container Scanning
This task guides you through scanning a standard (non-distroless) container using the Kubernetes API approach. The approach uses the train-k8s-container transport to execute commands inside the target container through the Kubernetes API.
-
Task Details
Time to complete: 10-15 minutes
Security risk: ๐ก Medium - Requires creation of temporary service accounts and RBAC resources
Security approach: Implements security best practices including ephemeral credentials, least-privilege RBAC, and proper resource lifecycle management
Security Architecture¶
Understanding Permission Layers
Standard container scanning involves multiple distinct permission layers that must be properly isolated:
1. Administrator/Operator Permissions * Control: Ability to create service accounts, roles, and role bindings * Risk area: Over-privileged administrator access could affect other resources * Mitigation: Use service accounts with scoped permissions limited to RBAC management
2. Scanner Service Account Permissions * Control: Scanner's ability to access and execute commands in target containers * Risk area: Overly permissive scanner permissions could allow unintended access * Mitigation: Create time-limited, namespace-scoped permissions for specific containers
3. Container Context Permissions * Control: What the scanner can access inside the container during execution * Risk area: Root-level scanning might access sensitive container data * Mitigation: Run containers with non-root users and restricted capabilities
Security Prerequisites¶
- Kubernetes cluster with RBAC enabled (see Existing Cluster Requirements)
- kubectl configured for the target cluster
- Permissions to create service accounts and roles in the target namespace
- CINC Auditor installed (see prerequisites section)
- SAF CLI installed (will be automatically installed if missing)
Kubernetes Setup
If you don't have a Kubernetes cluster available, you can set up a local test environment using our Minikube Setup guide.
Step-by-Step Instructions¶
Step 1: Verify Prerequisites¶
Security Consideration
The scanner uses CINC Auditor (open-source InSpec) to avoid licensing issues in automated environments.
Ensure you have CINC Auditor installed:
Verify kubectl access to the cluster:
Step 2: Locate or Create a Profile¶
Security Consideration
Using appropriate security profiles is crucial. Ensure the profile matches the container's purpose and requirements.
You can use the built-in examples or provide your own InSpec profile path.
Step 3: Run the Scanning Script¶
Security Consideration
The script creates temporary resources with minimal permissions and short-lived tokens (default 1 hour). All resources are cleaned up after the scan completes.
For advanced usage with threshold validation:
Step 4: Review Scan Results¶
The script will output the scan results to the console and save detailed results to JSON and Markdown files.
Security Best Practices¶
- Use namespace-specific service accounts for isolation
- Implement threshold validation to ensure compliance requirements are met
- Run scans with least privilege - only scan containers you need to assess
- Store scan results securely if they contain sensitive information
- Consider using GitOps to manage scanning profiles in version control
- Configure scan thresholds to align with your organization's compliance requirements
Verification Steps¶
- Verify the scan completed successfully with an exit code of 0
- Check the scan results files exist
- Verify temporary resources were cleaned up
Troubleshooting¶
-
Permission Denied
Ensure you have permissions to create service accounts and roles in the target namespace.
-
Container Not Found
Verify the namespace, pod name, and container name.
-
InSpec Profile Errors
Ensure the profile exists and is correctly formatted.
-
SAF CLI Not Found
The script attempts to install SAF CLI automatically, but you may need to install Node.js first.
-
Threshold Validation Failed
Review scan results and adjust either your container security posture or threshold requirements.
Next Steps¶
-
:material-threshold:{ .lg .middle } Configure Security Thresholds
Set up automated compliance validation with custom threshold files.
-
CI/CD Integration
Automate scanning in your continuous integration pipelines.
-
Security Hardening
Fine-tune RBAC permissions and access controls.
-
Advanced Scanning
Explore scanning of specialized container types.
Compliance and Security Considerations¶
-
Risk Analysis
Review comprehensive security risk assessment for this approach:
- Kubernetes API Security Risks
- Key risk: Minimal - uses standard K8s APIs
- Overall risk rating: ๐ข Low
-
Compliance Impact
This approach has strong compliance alignment:
- DoD 8500.01: โ Full alignment (standard interfaces)
- SRG-APP-000142: โ Full alignment (least privilege)
- STIG V-242423: โ Full alignment (clear RBAC implementation)
- CIS 5.2.4: โ Full alignment (no process sharing needed)
-
Security Principles
Core security principles applied in this task:
-
Documentation Requirements
For compliance documentation:
- Standard documentation of RBAC implementation is sufficient
- No special risk acceptance documentation required
- Document token lifecycle management
- Include audit logging configuration