Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ See the [checks reference](https://www.cerberauth.com/docs/proxyaudit/checks/)
for the full list with CWE/OWASP mapping and remediation.

- **TLS/Transport**: protocol version, cipher strength/forward secrecy,
certificate chain/expiry/hostname/OCSP stapling, HTTP→HTTPS redirect, HSTS.
certificate chain/expiry/hostname/OCSP stapling, Heartbleed, DROWN, ROBOT,
HTTP→HTTPS redirect, HSTS.
- **HTTP Security Headers**: CSP, X-Frame-Options/frame-ancestors,
X-Content-Type-Options, Referrer-Policy, Permissions-Policy, Server/
X-Powered-By banner disclosure, cookie flags, CORS misconfiguration
Expand Down
60 changes: 51 additions & 9 deletions docs/checks/tls.mdx
Original file line number Diff line number Diff line change
@@ -1,38 +1,80 @@
---
title: TLS / Transport
description: Protocol version, cipher strength/forward secrecy, certificate chain/expiry/hostname, OCSP stapling, HTTPS redirect, and HSTS.
description: Protocol version, cipher strength/forward secrecy, certificate chain/expiry/hostname, OCSP stapling, Heartbleed, DROWN, ROBOT, HTTPS redirect, and HSTS.
---

| Check ID | Title | CVSS 4.0 | CWE | OWASP |
| --- | --- | --- | --- | --- |
| `tls.protocol_version` | Weak TLS Protocol Version Accepted | 5.3 | [CWE-326](https://cwe.mitre.org/data/definitions/326.html) | API8:2023 |
| `tls.cipher_strength` | Weak Cipher Suite or Missing Forward Secrecy | 4.8 | [CWE-327](https://cwe.mitre.org/data/definitions/327.html) | API8:2023 |
| `tls.certificate` | Certificate Chain, Expiry, Hostname, or OCSP Stapling Issue | 5.3 | [CWE-295](https://cwe.mitre.org/data/definitions/295.html) | API8:2023 |
| `tls.https_redirect` | Missing HTTP to HTTPS Redirect | 5.3 | [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | API8:2023 |
| `tls.protocol_version` | Weak TLS Protocol Version Accepted | 6.9 | [CWE-326](https://cwe.mitre.org/data/definitions/326.html) | API8:2023 |
| `tls.cipher_strength` | Weak Cipher Suite or Missing Forward Secrecy | 6.9 | [CWE-327](https://cwe.mitre.org/data/definitions/327.html) | API8:2023 |
| `tls.certificate` | Certificate Chain, Expiry, Hostname, or OCSP Stapling Issue | 6.9 | [CWE-295](https://cwe.mitre.org/data/definitions/295.html) | API8:2023 |
| `tls.heartbleed` | Heartbleed (CVE-2014-0160) | 8.7 | [CWE-125](https://cwe.mitre.org/data/definitions/125.html) | API8:2023 |
| `tls.drown` | SSLv2 Enabled (DROWN, CVE-2016-0800) | 8.2 | [CWE-327](https://cwe.mitre.org/data/definitions/327.html) | API8:2023 |
| `tls.robot` | RSA Padding Oracle (ROBOT) | 8.2 | [CWE-203](https://cwe.mitre.org/data/definitions/203.html) | API8:2023 |
| `tls.https_redirect` | Missing HTTP to HTTPS Redirect | 6.9 | [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | API8:2023 |
| `tls.hsts` | Missing or Weak Strict-Transport-Security Header | 0 (informational) | [CWE-16](https://cwe.mitre.org/data/definitions/16.html) | API8:2023 |

## `tls.protocol_version`

Tests whether the proxy still accepts deprecated TLS versions (TLS 1.0/1.1) alongside modern ones, by forcing a handshake at each deprecated version. Go's `crypto/tls` no longer implements SSLv3, so that version can't be probed directly — but a server still offering it would also offer TLS 1.0/1.1 in virtually every real deployment.
Tests whether the proxy still accepts deprecated protocol versions alongside modern ones, by forcing a handshake at each deprecated version: TLS 1.0 and 1.1 through `crypto/tls`, and SSL 3.0 through a raw ClientHello since `crypto/tls` no longer implements it. Accepted versions are reported together as one observation, code `protocol.legacy_enabled`.

Heartbleed, DROWN and ROBOT have their own checks below.

**Remediate:** disable TLS 1.0/1.1 (and SSLv3) in the proxy's TLS configuration; require TLS 1.2 or later.

## `tls.cipher_strength`

Inspects the negotiated cipher suite for missing forward secrecy (non-ECDHE/DHE key exchange on TLS ≤ 1.2), and separately forces a handshake offering only known-weak cipher suites (RC4, 3DES, CBC-mode) to test whether the server still accepts them.
Inspects the negotiated cipher suite for missing forward secrecy (non-ECDHE/DHE key exchange on TLS ≤ 1.2), and separately forces handshakes offering only weak cipher suites to test whether the server still accepts them: RC4, 3DES and NULL through a raw ClientHello, the other suites Go marks insecure (CBC mode with SHA-256) through `crypto/tls`. A raw handshake offering only DHE suites reads the Diffie-Hellman group size and flags a group below 2048 bits.

**Remediate:** restrict the cipher suite list to modern AEAD suites with ECDHE key exchange (or rely on TLS 1.3, which is always forward-secret).

## `tls.certificate`

Inspects the leaf certificate presented during the TLS handshake:

- **Chain trust** — independently verifies the presented chain against the system trust store and the request hostname.
- **Expiry** — flags an expired certificate, and separately flags one expiring within 30 days.
- **Chain trust** — independently verifies the presented chain against the system trust store, and tells a self-signed certificate apart from an untrusted chain.
- **Hostname** — flags a certificate not valid for the hostname of the target URL.
- **Expiry** — flags an expired or not yet valid certificate, and separately one expiring within 30 days.
- **OCSP stapling** — flags a handshake with no stapled OCSP response.

**Remediate:** use a certificate from a trusted CA matching the hostname, automate renewal well before expiry, and enable OCSP stapling.

## `tls.heartbleed`

Completes a raw TLS 1.2 handshake up to ServerHelloDone, advertising the heartbeat extension. When the server acknowledges the extension, sends one unencrypted heartbeat request declaring a 16-byte payload with none attached. A patched server discards it; a vulnerable one answers with 16 bytes of its process memory, which the probe discards without reading.

**Remediate:** upgrade OpenSSL to 1.0.1g or later (or build with `-DOPENSSL_NO_HEARTBEATS`), then revoke and reissue the certificate and rotate session secrets.

## `tls.drown`

Sends an SSLv2 ClientHello and reports when the server answers with an SSLv2 ServerHello, with the number of cipher specs offered. Any SSLv2 support is reported, since OpenSSL servers negotiated disabled SSLv2 ciphers (CVE-2015-3197).

**Remediate:** disable SSLv2 on every server sharing the certificate's RSA key, including mail and other non-HTTP services.

## `tls.robot`

Runs five RSA key-exchange handshakes in parallel, each sending a ClientKeyExchange whose premaster secret is encrypted with the server's public key and padded differently: correct PKCS#1 v1.5 padding, wrong prefix, misplaced zero separator, missing separator, and wrong protocol version. Each is followed by ChangeCipherSpec and an invalid Finished, then again without them. The server is reported when its responses (alert, connection close, reset or timeout) differ between variants in two consecutive rounds. Servers that do not negotiate RSA key exchange are not affected.

**Remediate:** disable RSA key-exchange cipher suites (keep ECDHE only, or use TLS 1.3), or upgrade the TLS library to a version with a constant-time RSA decryption path.

## Observation codes

Each kind of finding carries a stable code in `Metadata["code"]`, so an embedder maps it to its own check ID without matching titles:

| Check | Codes |
| --- | --- |
| `tls.protocol_version` | `protocol.legacy_enabled` |
| `tls.cipher_strength` | `cipher.no_forward_secrecy`, `cipher.rc4`, `cipher.3des`, `cipher.null`, `cipher.weak_suite`, `cipher.weak_dh` |
| `tls.certificate` | `certificate.untrusted_chain`, `certificate.self_signed`, `certificate.hostname_mismatch`, `certificate.expired`, `certificate.not_yet_valid`, `certificate.expires_soon`, `certificate.ocsp_not_stapled` |
| `tls.heartbleed` | `cve.heartbleed` |
| `tls.drown` | `cve.drown` |
| `tls.robot` | `cve.robot` |
| `tls.https_redirect` | `https_redirect.not_redirected`, `https_redirect.not_https` |

## Skipped targets

The TLS checks share one handshake, `probe.tls_info`, whose result (`probebase.TLSInfo`) is exported for other scanners. When it fails, they are skipped with the reason given by `TLSInfo.SkipReason`: a plain-HTTP target URL, a port that does not speak TLS, or a closed or unreachable port.

## `tls.https_redirect`

Sends a plain-HTTP request to the target and checks whether it's redirected to HTTPS.
Expand Down
9 changes: 9 additions & 0 deletions proxy/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ import (
headerssti "github.com/cerberauth/proxyaudit/proxy/checks/templateinjection/header_ssti"
"github.com/cerberauth/proxyaudit/proxy/checks/tls/certificate"
cipherstrength "github.com/cerberauth/proxyaudit/proxy/checks/tls/cipher_strength"
"github.com/cerberauth/proxyaudit/proxy/checks/tls/drown"
"github.com/cerberauth/proxyaudit/proxy/checks/tls/heartbleed"
"github.com/cerberauth/proxyaudit/proxy/checks/tls/hsts"
httpsredirect "github.com/cerberauth/proxyaudit/proxy/checks/tls/https_redirect"
protocolversion "github.com/cerberauth/proxyaudit/proxy/checks/tls/protocol_version"
"github.com/cerberauth/proxyaudit/proxy/checks/tls/robot"
baselinepayloads "github.com/cerberauth/proxyaudit/proxy/checks/waf/baseline_payloads"
contenttypeconsistency "github.com/cerberauth/proxyaudit/proxy/checks/waf/content_type_consistency"
encodingbypass "github.com/cerberauth/proxyaudit/proxy/checks/waf/encoding_bypass"
Expand All @@ -73,6 +76,9 @@ func AllChecks() ([]harnessx.Check, map[harnessx.CheckID]checkdef.CheckDef) {
certificate.Check,
httpsredirect.Check,
hsts.Check,
heartbleed.Check,
drown.Check,
robot.Check,

// HTTP Security Headers.
csp.Check,
Expand Down Expand Up @@ -140,6 +146,9 @@ func AllChecks() ([]harnessx.Check, map[harnessx.CheckID]checkdef.CheckDef) {
certificate.Check.ID: certificate.Def,
httpsredirect.Check.ID: httpsredirect.Def,
hsts.Check.ID: hsts.Def,
heartbleed.Check.ID: heartbleed.Def,
drown.Check.ID: drown.Def,
robot.Check.ID: robot.Def,

csp.Check.ID: csp.Def,
frameoptions.Check.ID: frameoptions.Def,
Expand Down
116 changes: 88 additions & 28 deletions proxy/checks/tls/certificate/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
package certificate

import (
"bytes"
"context"
"crypto/x509"
_ "embed"
"errors"
"net/url"
"time"

"github.com/cerberauth/harnessx"
"github.com/cerberauth/harnessx/checkdef"
"github.com/cerberauth/proxyaudit/proxy/probebase"
"github.com/cerberauth/proxyaudit/proxy/scanctx"
)

var errNoCertificate = errors.New("no certificate available from probe.tls_info")
Expand All @@ -25,55 +29,111 @@ var Def = checkdef.MustParseCheckDefYAML("certificate", checkYAML)
// soon enough to be an operational risk.
const ExpiryWarningWindow = 30 * 24 * time.Hour

var Check = checkdef.NewCheck(Def, func(_ context.Context, _ harnessx.Target, store harnessx.ResultStore) (harnessx.Result, error) {
const (
CodeUntrustedChain = "certificate.untrusted_chain"
CodeSelfSigned = "certificate.self_signed"
CodeHostnameMismatch = "certificate.hostname_mismatch"
CodeExpired = "certificate.expired"
CodeNotYetValid = "certificate.not_yet_valid"
CodeExpiresSoon = "certificate.expires_soon"
CodeOCSPNotStapled = "certificate.ocsp_not_stapled"
)

func isSelfSigned(cert *x509.Certificate) bool {
return bytes.Equal(cert.RawIssuer, cert.RawSubject) && cert.CheckSignature(cert.SignatureAlgorithm, cert.RawTBSCertificate, cert.Signature) == nil
}

func chainError(leaf *x509.Certificate, intermediates []*x509.Certificate, roots *x509.CertPool) error {
pool := x509.NewCertPool()
for _, c := range intermediates {
pool.AddCert(c)
}
_, err := leaf.Verify(x509.VerifyOptions{
Roots: roots,
Intermediates: pool,
CurrentTime: leaf.NotBefore.Add(time.Second),
})
return err
}

func observation(code, title, description, evidence string, metadata map[string]string) harnessx.Observation {
if metadata == nil {
metadata = map[string]string{}
}
metadata[probebase.MetadataCode] = code
return harnessx.Observation{Title: title, Description: description, Evidence: evidence, Metadata: metadata}
}

var Check = checkdef.NewCheck(Def, func(_ context.Context, target harnessx.Target, store harnessx.ResultStore) (harnessx.Result, error) {
info, ok := probebase.Info(store)
if !ok || info.Err != nil || info.ConnState == nil || len(info.ConnState.PeerCertificates) == 0 {
return harnessx.Result{Err: errNoCertificate}, nil
}
sctx := scanctx.TargetContext(target)
leaf := info.ConnState.PeerCertificates[0]
subject := map[string]string{"subject": leaf.Subject.String()}

var observations []harnessx.Observation

if info.VerifyErr != nil {
observations = append(observations, harnessx.Observation{
Title: "Certificate chain does not verify",
Description: "The certificate presented by the target does not chain to a trusted root, or the hostname does not match.",
Evidence: info.VerifyErr.Error(),
Metadata: map[string]string{"subject": leaf.Subject.String()},
})
if err := chainError(leaf, info.ConnState.PeerCertificates[1:], sctx.RootCAs); err != nil {
var unknownAuthority x509.UnknownAuthorityError
if errors.As(err, &unknownAuthority) && isSelfSigned(leaf) {
observations = append(observations, observation(CodeSelfSigned,
"Certificate is self-signed",
"The certificate presented by the target is signed by its own key instead of a trusted certificate authority, so clients cannot authenticate the server.",
err.Error(), subject))
} else {
observations = append(observations, observation(CodeUntrustedChain,
"Certificate chain does not verify",
"The certificate presented by the target does not chain to a trusted root.",
err.Error(), subject))
}
}

if u, err := url.Parse(target.URL); err == nil {
if err := leaf.VerifyHostname(u.Hostname()); err != nil {
observations = append(observations, observation(CodeHostnameMismatch,
"Certificate hostname does not match",
"The certificate presented by the target is not valid for the hostname of the target URL.",
err.Error(), map[string]string{"subject": leaf.Subject.String(), "hostname": u.Hostname()}))
}
}

now := time.Now()
notAfter := map[string]string{"not_after": leaf.NotAfter.Format(time.RFC3339)}
switch {
case now.After(leaf.NotAfter):
observations = append(observations, harnessx.Observation{
Title: "Certificate has expired",
Description: "The certificate presented by the target expired and is no longer valid.",
Evidence: "not_after: " + leaf.NotAfter.Format(time.RFC3339),
Metadata: map[string]string{"not_after": leaf.NotAfter.Format(time.RFC3339)},
})
observations = append(observations, observation(CodeExpired,
"Certificate has expired",
"The certificate presented by the target expired and is no longer valid.",
"not_after: "+leaf.NotAfter.Format(time.RFC3339), notAfter))
case now.Before(leaf.NotBefore):
observations = append(observations, observation(CodeNotYetValid,
"Certificate is not valid yet",
"The certificate presented by the target is not valid before a future date.",
"not_before: "+leaf.NotBefore.Format(time.RFC3339), map[string]string{"not_before": leaf.NotBefore.Format(time.RFC3339)}))
case leaf.NotAfter.Before(now.Add(ExpiryWarningWindow)):
observations = append(observations, harnessx.Observation{
Title: "Certificate expires soon",
Description: "The certificate presented by the target expires within 30 days.",
Evidence: "not_after: " + leaf.NotAfter.Format(time.RFC3339),
Metadata: map[string]string{"not_after": leaf.NotAfter.Format(time.RFC3339)},
})
observations = append(observations, observation(CodeExpiresSoon,
"Certificate expires soon",
"The certificate presented by the target expires within 30 days.",
"not_after: "+leaf.NotAfter.Format(time.RFC3339), notAfter))
}

if info.ConnState.OCSPResponse == nil {
observations = append(observations, harnessx.Observation{
Title: "OCSP stapling not enabled",
Description: "The target did not staple an OCSP response during the TLS handshake, so clients must query the CA's OCSP responder separately (or skip revocation checking entirely).",
Evidence: "no OCSP response in TLS handshake",
})
observations = append(observations, observation(CodeOCSPNotStapled,
"OCSP stapling not enabled",
"The target did not staple an OCSP response during the TLS handshake, so clients must query the CA's OCSP responder separately (or skip revocation checking entirely).",
"no OCSP response in TLS handshake", nil))
}

return harnessx.Result{Observations: observations}, nil
}, checkdef.WithSkip(harnessx.SkipWhen(func(_ context.Context, _ harnessx.Target, store harnessx.ResultStore) string {
info, ok := probebase.Info(store)
if !ok || info.Err != nil || info.ConnState == nil || len(info.ConnState.PeerCertificates) == 0 {
return "target TLS handshake produced no certificate — see probe.tls_info"
info, _ := probebase.Info(store)
if reason := info.SkipReason(); reason != "" {
return reason
}
if len(info.ConnState.PeerCertificates) == 0 {
return "target TLS handshake produced no certificate"
}
return ""
})))
2 changes: 1 addition & 1 deletion proxy/checks/tls/certificate/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ tags:
depends_on:
- "probe.tls_info"
cvss_vector: "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N"
cvss_score: 5.3
cvss_score: 6.9
cwe_id: "CWE-295"
owasp: "API8:2023"
Loading