CIS Caddy Benchmark

Security configuration benchmark for Caddy web server

v1.0.0 03-2025

Overview

▶

This benchmark provides prescriptive guidance for establishing a secure configuration posture for Caddy web server. It covers automatic HTTPS with ACME, TLS hardening, security headers, rate limiting, access logging, reverse proxy security, admin API restrictions, file server hardening, and certificate storage protection.

14Recommendations
7Sections
2Profile Levels
SectionAreaFocus
1Installation & PermissionsVersion management, file security
2TLS ConfigurationAutomatic HTTPS, cipher hardening
3HTTP SecuritySecurity headers, rate limiting
4Logging & Error HandlingJSON logging, error pages
5Reverse Proxy & AuthenticationUpstream TLS, basicauth
6Admin & File ServerAPI restriction, dotfile hiding
7Maintenance & CertificatesConfig validation, ACME storage

Profile Definitions

▶
ProfileDescriptionIntended Use
L1Level 1 — StandardEssential security for all Caddy deployments; minimal performance impact.
L2Level 2 — HardenedAdvanced hardening for PCI-DSS, HIPAA, or high-security environments.

1 — Installation & Permissions

▶

1.1 Version & File Security

▶
1.1.1 Ensure Caddy is running the latest stable version (Manual)
L1 Manual
Description

This recommendation verifies that Caddy is running the latest stable version on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Verify Caddy version
caddy version
# Check running user
ps -eo user,pid,comm | grep caddy
Remediation
# Install latest Caddy
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
apt-get update && apt-get install caddy
# Ensure dedicated user:
useradd -r -s /usr/sbin/nologin caddy
1.1.2 Ensure Caddyfile permissions are restricted (Automated)
L1 Auto
Description

This setting ensures that Caddyfile permissions are restricted on the Caddy web server. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the Caddy web server is essential for defense in depth.

Audit
# Check Caddyfile permissions
stat -c '%a %U %G' /etc/caddy/Caddyfile
find /etc/caddy -type f -exec stat -c '%a %n' {} \;
Remediation
# Restrict Caddyfile permissions
chmod 640 /etc/caddy/Caddyfile
chown root:caddy /etc/caddy/Caddyfile
chmod 750 /etc/caddy/
chmod 700 /var/lib/caddy/

2 — TLS Configuration

▶

2.1 HTTPS & Protocol Hardening

▶
2.1.1 Ensure automatic HTTPS is properly configured (Automated)
L1 Auto
Description

This recommendation verifies that automatic HTTPS is properly configured on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Verify automatic HTTPS is active
caddy validate --config /etc/caddy/Caddyfile
caddy list-modules | grep tls
Remediation
# Configure automatic HTTPS
# In Caddyfile:
example.com {
    # Caddy automatically provisions TLS
    # Override email for ACME:
    tls admin@example.com
}
# Or use internal CA for dev:
# tls internal
2.1.2 Ensure TLS protocols and ciphers are hardened (Automated)
L1 Auto
Description

This recommendation verifies that TLS protocols and ciphers are hardened on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check TLS configuration
grep -E 'tls|protocols|ciphers' /etc/caddy/Caddyfile
Remediation
# Harden TLS settings
# In Caddyfile:
example.com {
    tls {
        protocols tls1.2 tls1.3
        ciphers TLS_AES_256_GCM_SHA384 TLS_CHACHA20_POLY1305_SHA256
        curves x25519 secp384r1
    }
}

3 — HTTP Security

▶

3.1 Headers & Rate Limiting

▶
3.1.1 Ensure security headers are configured (Automated)
L1 Auto
Description

This recommendation verifies that security headers are configured on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check security headers
grep -E 'header|Strict-Transport|Content-Security|X-Frame' /etc/caddy/Caddyfile
Remediation
# Configure security headers
# In Caddyfile:
example.com {
    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
        X-Content-Type-Options nosniff
        X-Frame-Options DENY
        Content-Security-Policy "default-src 'self'"
        Referrer-Policy strict-origin-when-cross-origin
        -Server
    }
}
3.1.2 Ensure rate limiting is configured (Automated)
L2 Auto
Description

This recommendation verifies that rate limiting is configured on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check rate limiting
caddy list-modules | grep rate_limit
grep 'rate_limit' /etc/caddy/Caddyfile
Remediation
# Configure rate limiting
# In Caddyfile:
example.com {
    rate_limit {
        zone static {
            key static
            events 100
            window 1m
        }
    }
}

4 — Logging & Error Handling

▶

4.1 Access Logs & Errors

▶
4.1.1 Ensure structured access logging is enabled (Automated)
L1 Auto
Description

This recommendation verifies that structured access logging is enabled on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check access logging
grep -E 'log|output|format' /etc/caddy/Caddyfile
Remediation
# Configure access logging
# In Caddyfile:
example.com {
    log {
        output file /var/log/caddy/access.log {
            roll_size 100mb
            roll_keep 10
            roll_keep_for 720h
        }
        format json
        level INFO
    }
}
4.1.2 Ensure custom error pages prevent information disclosure (Automated)
L1 Auto
Description

This recommendation verifies that custom error pages prevent information disclosure on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check error handling
grep -E 'handle_errors|error' /etc/caddy/Caddyfile
Remediation
# Configure error pages (prevent info disclosure)
# In Caddyfile:
example.com {
    handle_errors {
        respond "{err.status_code} {err.status_text}"
    }
}

5 — Reverse Proxy & Authentication

▶

5.1 Proxy & Auth

▶
5.1.1 Ensure reverse proxy upstream uses TLS with header controls (Automated)
L1 Auto
Description

This recommendation verifies that reverse proxy upstream uses TLS with header controls on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check reverse proxy configuration
grep -E 'reverse_proxy|upstream' /etc/caddy/Caddyfile
Remediation
# Harden reverse proxy
# In Caddyfile:
example.com {
    reverse_proxy backend:8080 {
        header_up X-Forwarded-Proto {scheme}
        header_up X-Real-IP {remote_host}
        header_down -Server
        transport http {
            tls_insecure_skip_verify false
        }
    }
}
5.1.2 Ensure authentication is configured for sensitive paths (Automated)
L1 Auto
Description

This recommendation verifies that authentication is configured for sensitive paths on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check basic auth configuration
grep -E 'basicauth|forward_auth' /etc/caddy/Caddyfile
Remediation
# Configure authentication
# In Caddyfile:
example.com {
    basicauth /admin/* {
        admin $2a$14$... # bcrypt hash
    }
}
# Generate hash:
caddy hash-password --plaintext 'strongpassword'

6 — Admin & File Server

▶

6.1 API & Static Files

▶
6.1.1 Ensure admin API is disabled or restricted to localhost (Automated)
L1 Auto
Description

This recommendation verifies that admin API is disabled or restricted to localhost on the Caddy web server. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Caddy web server increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
# Check admin API endpoint
grep -E 'admin|api' /etc/caddy/Caddyfile
caddy environ | grep CADDY_ADMIN
Remediation
# Restrict admin API
# In Caddyfile global options:
{
    admin off
    # Or restrict to localhost:
    # admin localhost:2019
}
6.1.2 Ensure file server hides sensitive files and disables browsing (Automated)
L1 Auto
Description

This recommendation verifies that file server hides sensitive files and disables browsing on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check file server settings
grep -E 'file_server|browse' /etc/caddy/Caddyfile
Remediation
# Restrict file server
# In Caddyfile:
example.com {
    file_server {
        # Do NOT enable browse in production
        hide .git .env .htaccess
    }
    # Block dotfiles:
    @dotfiles path */.* */.*/*
    respond @dotfiles 403
}

7 — Maintenance & Certificates

▶

7.1 Validation & Storage

▶
7.1.1 Ensure configuration is validated before reload (Automated)
L1 Auto
Description

This recommendation verifies that configuration is validated before reload on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Verify Caddy config
caddy validate --config /etc/caddy/Caddyfile
caddy fmt --diff /etc/caddy/Caddyfile
Remediation
# Validate and format config
caddy validate --config /etc/caddy/Caddyfile
caddy fmt --overwrite /etc/caddy/Caddyfile
# Reload without downtime:
caddy reload --config /etc/caddy/Caddyfile
7.1.2 Ensure ACME certificate storage is protected (Automated)
L1 Auto
Description

This recommendation verifies that ACME certificate storage is protected on the Caddy web server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Caddy web server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check ACME certificate storage
ls -la /var/lib/caddy/.local/share/caddy/
stat -c '%a %U %G' /var/lib/caddy/.local/share/caddy/
Remediation
# Protect certificate storage
chmod 700 /var/lib/caddy/.local/share/caddy/
chown caddy:caddy /var/lib/caddy/.local/share/caddy/
# Configure ACME CA:
# In Caddyfile global options:
# {
#     acme_ca https://acme-v02.api.letsencrypt.org/directory
# }