Skip to main content
skill CX Codex

security-hardening · ancoleman — Claude Code skill: what it does, how to install

The security-hardening skill tightens OS, container, cloud, network, and database settings. Use it before production deployment, audits, or vulnerability review.

MIT 1 installs ★ 533 updated 2025-12-11

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ancoleman/ai-design-components --skill security-hardening -a claude-code
Open on GitHub

What security-hardening does

security-hardening works across five infrastructure areas: Linux, containers, cloud configuration, networks, and databases. It uses CIS Benchmarks and zero-trust principles to reduce exposed components, limit permissions, deny unapproved access, and add encryption or audit controls where needed.

The skill covers SSH and sysctl settings, file permissions, SELinux or AppArmor, non-root containers, read-only filesystems, IAM, MFA, network policies, TLS, and database roles. Its verification examples use tools such as Trivy, Checkov, Prowler, Lynis, OpenSCAP, and kube-bench.

If a container needs a shell for debugging, Distroless makes that work harder because the image has no shell. Installing it through Claude Code requires npx and the ancoleman/ai-design-components repository.

What it helps with

  • harden Linux before a production deployment
  • remove excess container capabilities and root access
  • restrict cloud permissions with IAM and MFA
  • segment traffic with default-deny network policies
  • check infrastructure against CIS Benchmarks

Example prompts for the agent

  • Harden this Linux host before production and map the changes to CIS Benchmarks.
  • Review this container setup, remove unnecessary capabilities, block root execution, and make the root filesystem read-only.
  • Audit the cloud permissions, network policies, and database access rules using least privilege.

How to install security-hardening

1Skills CLI (Vercel)

npx skills add ancoleman/ai-design-components --skill security-hardening -a claude-code

2Manually: put the files in place

~/.claude/skills/security-hardening/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/security-hardening/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about security-hardening

How do I install security-hardening in Claude Code?

Run npx skills add ancoleman/ai-design-components --skill security-hardening -a claude-code, then check ~/.claude/skills/security-hardening/SKILL.md.

What does security-hardening do?

It hardens operating systems, containers, cloud settings, networks, and databases. The skill applies CIS Benchmarks, zero-trust principles, encryption, logging, and least-privilege controls.

Which infrastructure layers does it cover?

It covers Linux, containers, cloud configuration, networks, and databases. Container checks include non-root execution, read-only filesystems, seccomp, and AppArmor.

Source text

SKILL.md · MIT
---
name: security-hardening
description: Reduces attack surface across OS, container, cloud, network, and database layers using CIS Benchmarks and zero-trust principles. Use when hardening production infrastructure, meeting compliance requirements, or implementing defense-in-depth security.
---

# Security Hardening

## Purpose

Proactive reduction of attack surface across infrastructure layers through systematic configuration hardening, least-privilege enforcement, and automated security controls. Applies industry-standard CIS Benchmarks and zero-trust principles to operating systems, containers, cloud configurations, networks, and databases.

## When to Use This Skill

Invoke this skill when:
- Hardening production infrastructure before deployment
- Meeting compliance requirements (SOC 2, PCI-DSS, HIPAA, FedRAMP)
- Implementing zero-trust security architecture
- Reducing container or cloud misconfiguration risks
- Preparing for security audits or penetration tests
- Automating security baseline enforcement
- Responding to vulnerability scan findings

## Hardening Layers

Security hardening applies across five infrastructure layers:

### Layer 1: Operating System (Linux)
- Kernel parameter tuning (sysctl)
- SSH configuration hardening
- User and group management
- File system permissions and mount options
- Service minimization
- SELinux/AppArmor enforcement

### Layer 2: Container
- Minimal base images (Chainguard, Distroless, Alpine)
- Non-root container execution
- Read-only root filesystems
- Seccomp and AppArmor profiles
- Resource limits and capabilities dropping
- Pod Security Standards enforcement

### Layer 3: Cloud Configuration
- IAM least privilege and MFA enforcement
- Network security groups and NACL configuration
- Encryption at rest and in transit
- Public access blocking
- Logging and monitoring enablement
- CSPM (Cloud Security Posture Management) integration

### Layer 4: Network
- Default-deny network policies
- Network segmentation and micro-segmentation
- TLS/mTLS enforcement
- Firewall rule minimization
- DNS security (DNSSEC, DNS filtering)

### Layer 5: Database
- Authentication and authorization hardening
- Connection encryption (SSL/TLS)
- Audit logging enablement
- Network isolation and access control
- Role-based permissions with least privilege

## Core Hardening Principles

### 1. Default Deny, Explicit Allow
Start with all access denied, explicitly permit only required operations. Apply default-deny firewall rules and network policies, then allow specific traffic.

### 2. Least Privilege Access
Grant minimum permissions required for operation. Use RBAC, IAM policies with specific resources, and database roles with limited permissions (no DELETE or DDL unless required).

### 3. Defense in Depth
Implement multiple overlapping security controls: network firewalls, authentication, authorization, audit logging, and encryption working together.

### 4. Minimal Attack Surface
Remove unnecessary components, services, and permissions. Use minimal container base images, disable unused services, and drop all Linux capabilities unless required.

### 5. Fail Securely
On error or misconfiguration, default to secure state. Authentication failures deny access, missing configurations use restrictive defaults, and monitoring failures trigger immediate alerts.

## Hardening Priority Framework

Prioritize hardening efforts based on exposure and data sensitivity:

### Critical Priority: Internet-Facing Systems
**Apply immediately:**
- Container hardening (minimal images, non-root, read-only)
- Network segmentation (DMZ, WAF, DDoS protection)
- TLS termination and certificate management
- Rate limiting and authentication
- Real-time monitoring and alerting

**Tools:** Trivy, Falco, ModSecurity, Cloudflare

### High Priority: Systems with Sensitive Data
**Apply before production:**
- Encryption at rest (AES-256, KMS-managed keys)
- Strict access controls (RBAC, least privilege)
- Comprehensive audit logging
- Database connection encryption
- Regular vulnerability scanning

**Tools:** Checkov, Prowler, Lynis, OpenSCAP

### Standard Priority: Internal Systems
**Apply systematically:**
- OS hardening (CIS Benchmarks)
- Service minimization
- Patch management automation
- Configuration management
- Basic monitoring

**Tools:** Ansible, Puppet, kube-bench, docker-bench-security

## CIS Benchmark Integration

CIS (Center for Internet Security) Benchmarks provide industry-standard hardening guidance.

### Automated CIS Scanning

**Docker CIS Benchmark:**
```bash
docker run --rm -it \
  --net host \
  --pid host \
  --cap-add audit_control \
  -v /var/lib:/var/lib:ro \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /etc:/etc:ro \
  docker/docker-bench-security
```

**Kubernetes CIS Benchmark:**
```bash
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml
kubectl logs job/kube-bench
```

**Linux CIS Benchmark:**
```bash
# Using Lynis
lynis audit system --quick

# Using OpenSCAP
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_cis \
  /usr/share/xml/scap/ssg/content/ssg-ubuntu2004-ds.xml
```

### Key CIS Controls Mapping

| CIS Control | Hardening Action | Layer |
|-------------|------------------|-------|
| 4.1 Secure Configuration | Apply hardening baselines | All layers |
| 5.1 Account Management | Enforce least privilege, MFA | OS, Cloud |
| 6.1 Access Control | RBAC, network policies | All layers |
| 8.1 Audit Log Management | Enable comprehensive logging | All layers |
| 13.1 Network Monitoring | Deploy IDS/IPS, flow logs | Network |
| 3.1 Data Protection | Enable encryption at rest/transit | Cloud, Database |

For detailed CIS control mapping, see `references/cis-benchmark-mapping.md`.

## Container Base Image Selection

Choose base images based on security requirements and compatibility needs:

| Use Case | Recommended Base | Size | CVEs | Trade-off |
|----------|------------------|------|------|-----------|
| **Production apps** | Chainguard Images | ~10MB | 0 | Minimal, zero CVEs |
| **Minimal Linux** | Alpine | ~5MB | Few | Small, auditable |
| **Compatibility** | Distroless | ~20MB | Few | No shell, harder debug |
| **Debugging** | Debian slim | ~80MB | More | Has debugging tools |
| **Legacy apps** | Ubuntu | ~100MB | Many | Full compatibility |

**Production recommendation:** Chainguard Images or Distroless for production, Alpine for development.

## Verification and Auditing

Hardening must be verified continuously, not just at implementation.

### Automated Security Scanning

**Container vulnerability scanning:**
```bash
# Trivy: Comprehensive vulnerability and misconfiguration scanner
trivy image --severity HIGH,CRITICAL myapp:latest

# Grype: Fast vulnerability scanner
grype myapp:latest
```

**Infrastructure as Code scanning:**
```bash
# Checkov: Multi-cloud IaC scanner
checkov -d terraform/ --framework terraform

# Terrascan: Policy-as-code scanner
terrascan scan -t terraform -d terraform/
```

**Kubernetes security scanning:**
```bash
# Kubesec: Security risk analysis
kubesec scan k8s/deployment.yaml

# Polaris: Configuration validation
polaris audit --format=pretty

# Trivy K8s scanning
trivy k8s --report summary cluster
```

**Cloud security posture:**
```bash
# Prowler: AWS security assessment
prowler aws --services s3 iam ec2

# ScoutSuite: Multi-cloud security audit
scout aws --services s3 iam ec2
```

### Continuous Verification Pipeline

Integrate security scanning into CI/CD:

```yaml
# GitHub Actions example
name: Security Hardening Verification

on:
  push:
    branches: [main]
  schedule:
    - cron: '0 0 * * *'  # Daily scan

jobs:
  container-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build image
        run: docker build -t myapp:test .

      - name: Scan with Trivy
        uses: aquasecurity/trivy-action@master
        with:
          image-ref: 'myapp:test'
          severity: 'CRITICAL,HIGH'
          exit-code: '1'  # Fail on findings

  iac-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Scan IaC with Checkov
        uses: bridgecrewio/checkov-action@master
        with:
          directory: terraform/
          framework: terraform
          soft_fail: false
```

### Compliance Reporting

Generate compliance reports from scan results:

```bash
# Generate CIS compliance report
kube-bench run --json > cis-report.json

# Generate vulnerability report
trivy image --format json --output vuln-report.json myapp:latest

# Aggregate reports for compliance dashboard
python scripts/generate-compliance-report.py \
  --cis cis-report.json \
  --vulns vuln-report.json \
  --output compliance-dashboard.html
```

## Automation Tools

### Hardening Automation
- **Ansible/Puppet/Chef:** Configuration management for OS hardening
- **Terraform/Pulumi:** Infrastructure as Code with security modules
- **Cloud Custodian:** Cloud resource policy enforcement
- **OPA/Gatekeeper:** Kubernetes policy enforcement
- **Kyverno:** Kubernetes-native policy management

### Scanning Tools
- **Trivy:** Universal vulnerability and misconfiguration scanner
- **Checkov:** IaC security and compliance scanner
- **Falco:** Runtime security monitoring
- **Prowler:** AWS security assessment tool
- **ScoutSuite:** Multi-cloud security auditing
- **Lynis:** Linux security auditing
- **docker-bench-security:** Docker CIS benchmark scanner
- **kube-bench:** Kubernetes CIS benchmark scanner

### Monitoring Tools
- **Falco:** Runtime threat detection for containers
- **Sysdig:** Container security and monitoring
- **Wazuh:** Host and endpoint security monitoring
- **OSSEC:** Host-based intrusion detection

## Quick Reference: Common Hardening Tasks

### Harden SSH Access
```bash
# Edit /etc/ssh/sshd_config.d/hardening.conf
PermitRootLogin no
PasswordAuthentication no
PermitEmptyPasswords no
MaxAuthTries 3
X11Forwarding no
ClientAliveInterval 300
ClientAliveCountMax 2

# Restart SSH
systemctl restart sshd
```

### Harden Container Image
```dockerfile
# Use minimal base
FROM cgr.dev/chainguard/python:latest

# Non-root user
USER nonroot

# Read-only filesystem
COPY --chown=nonroot:nonroot app /app
WORKDIR /app

# Drop all capabilities
ENTRYPOINT ["python", "-m", "app"]
```

### Harden Kubernetes Pod
```yaml
securityContext:
  runAsNonRoot: true
  runAsUser: 65534
  seccompProfile:
    type: RuntimeDefault
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]
```

### Harden AWS S3 Bucket
```hcl
resource "aws_s3_bucket_public_access_block" "secure" {
  bucket = aws_s3_bucket.data.id

  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}

resource "aws_s3_bucket_server_side_encryption_configuration" "secure" {
  bucket = aws_s3_bucket.data.id

  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm = "aws:kms"
    }
  }
}
```

### Harden Network with Default Deny
```yaml
# Kubernetes NetworkPolicy: deny all ingress
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-ingress
  namespace: production
spec:
  podSelector: {}
  policyTypes:
  - Ingress
```

### Harden Database Access
```sql
-- PostgreSQL hardening
REVOKE ALL ON DATABASE app FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM PUBLIC;

CREATE ROLE app_user WITH LOGIN;
GRANT CONNECT ON DATABASE app TO app_user;
GRANT SELECT, INSERT, UPDATE ON app.orders TO app_user;

-- Force SSL connections
ALTER SYSTEM SET ssl = on;
-- In pg_hba.conf: hostssl all all 0.0.0.0/0 scram-sha-256
```

## Detailed Hardening Guides

For layer-specific hardening guidance:
- **OS hardening:** See `references/linux-hardening.md`
- **Container hardening:** See `references/container-hardening.md`
- **Cloud hardening:** See `references/cloud-hardening.md`
- **Network hardening:** See `references/network-hardening.md`
- **Database hardening:** See `references/database-hardening.md`

For automation scripts:
- **Python automation:** See `scripts/harden-linux.py`
- **Container host setup:** See `scripts/harden-container-host.sh`
- **Compliance reporting:** See `scripts/generate-compliance-report.py`
- **Infrastructure scanning:** See `scripts/scan-infrastructure.sh`

For working examples:
- **Linux configurations:** See `examples/linux/`
- **Kubernetes manifests:** See `examples/kubernetes/`
- **Terraform modules:** See `examples/terraform/`

## Integration with Related Skills

- **auth-security:** Authentication and authorization patterns complement hardening
- **secret-management:** Secure secrets handling is essential for hardening
- **kubernetes-operations:** Pod security and RBAC hardening
- **infrastructure-as-code:** Security scanning in IaC pipelines
- **building-ci-pipelines:** Automated security scanning integration
- **observability:** Security monitoring and alerting
- **compliance-frameworks:** Mapping hardening to compliance requirements

## Anti-Patterns to Avoid

**❌ Hardening only at deployment**
- Hardening is continuous; scan and verify regularly

**❌ Applying all controls blindly**
- Prioritize based on risk and exposure

**❌ No verification**
- Always verify hardening is applied and effective

**❌ Security through obscurity**
- Obscurity is not security; use proven controls

**❌ Hardening without testing**
- Test hardening changes don't break functionality

**❌ Manual hardening at scale**
- Automate hardening for consistency and repeatability

## Getting Started

1. **Assess current posture:** Run CIS benchmark scans
2. **Prioritize:** Internet-facing → sensitive data → internal
3. **Apply baseline hardening:** OS, container, cloud basics
4. **Automate:** Use scripts and IaC for consistency
5. **Verify continuously:** Integrate scanning into CI/CD
6. **Monitor:** Deploy runtime security monitoring
7. **Iterate:** Review and improve hardening regularly

For step-by-step implementation, start with `references/linux-hardening.md` or `references/container-hardening.md` based on infrastructure type.

© ancoleman · MIT · ancoleman/ai-design-components

Similar skills

All skills for Security →

security-hardening by other authors comes first.

security-hardening rohitg00 security-hardening is a Claude Code skill for application security, covering input handling, authentication, secrets, and dependency checks. It applies to requests to review or strengthen a project’s security. CX Codex +1 ★ 2,858repo stars auditing-cloud-with-cis-benchmarks mahipal auditing-cloud-with-cis-benchmarks audits AWS, Azure, and GCP environments against CIS Benchmarks using Prowler and ScoutSuite. Useful for baseline checks, finding misconfigurations, and audit prep. CX Codex +1 282installs container-hardening devops-skills container-hardening hardens Docker images and runtime environments with non-root users, read-only filesystems, and Kubernetes security contexts. CX Codex +1 491installs agent-security-engineer Tony363 agent-security-engineer guides infrastructure security, CIS benchmark compliance, and CI/CD security scanning. Helps teams introduce DevSecOps and zero-trust controls. CX Codex +1 402installs learn-docker-k8s-game reason-machines learn-docker-k8s-game — a skill for Claude Code, Codex, Cursor and other AI editors that turns the chat into a story-driven Docker and Kubernetes training game, running real terminal commands at each step. CX Codex +1 801installs linux-hardening devops-skills linux-hardening — a Claude Code skill that walks an agent through Linux server hardening: SSH, user policy, firewall, kernel parameters. It kicks in when a server moves to production or goes through a security review. CX Codex +1 890installs hardening-docker-containers-for-production mahipal hardening-docker-containers-for-production is a Claude Code skill that hardens Dockerfiles, images, and container runtime settings against CIS Docker Benchmark v1.8.0. It validates them with docker-bench-security, Hadolint, and Dockle. CX Codex +1 373installs

From the same set10

The whole set →
visualizing-data visualizing-data picks the right chart for your data and purpose, then helps build the dashboard or report with accessibility baked in. CX Codex +1 2installs building-ai-chat building-ai-chat guides the design of AI chat interfaces with streamed replies, context controls, and image, file, or voice input. Use it when building an assistant or coding copilot. CX Codex +1 1installs architecting-networks architecting-networks is a Claude Code skill for choosing cloud network topologies: flat, multi-VPC, hub-and-spoke, or full mesh. It supports VPC, segmentation, and hybrid connectivity planning. CX Codex +1 1installs implementing-navigation implementing-navigation implements frontend navigation patterns and Python backend routing with built-in WCAG 2.1 AA accessibility guidelines. CX Codex +1 1installs implementing-observability The implementing-observability skill wires metrics, logs and traces through OpenTelemetry and shows how to run Loki, Grafana, Tempo and Mimir yourself. Useful once one request crosses several services. CX Codex +1 1installs ingesting-data ingesting-data is a Claude Code skill with design patterns and code recipes for importing data from cloud storage, APIs, files, and streams into databases. CX Codex +1 1installs configuring-firewalls The configuring-firewalls skill guides firewall configuration across Linux hosts, cloud security controls, and Kubernetes. Use it when opening a service or narrowing network access. CX Codex +1 1installs building-ci-pipelines building-ci-pipelines — a skill for constructing secure CI/CD pipelines with SLSA provenance, monorepo optimization, caching strategies, and test parallelization. Works with GitHub Actions, GitLab CI, and Argo Workflows. CX Codex +1 1installs

Project sponsors

Companies that keep this analytics open