Caddy plugin example: Provision swallows directory-fetch errors (nil-validator panic) and only ever loads the first key
Los mantenedores suelen responder en 1 día
@thibmeu ya está trabajando en esto.
Desde el 8/6/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Area: examples/caddy-plugin/ (httpsig.go, handler.go)
Summary
The example Caddy plugin has three robustness issues that make it fail in ways that are surprising for anyone adapting it as a starting point. The most serious causes a nil-pointer panic on the first request whenever the signature directory is unreachable at startup. The plugin also silently ignores every key in the directory except the first, and never refreshes the directory, so key rotation requires a full Caddy reload.
I understand this is an example and not audited — filing because each of these is a quiet failure mode that’s easy to inherit when using this as a template, and the first one is a crash rather than a graceful error.
1. Provision swallows the fetch error, leaving validator nil → panic in ServeHTTP
httpsig.go:60-62:
resp, err := http.Get("https://" + m.DirectoryBase + "/.well-known/http-message-signatures-directory")
if err != nil {
return nil // error discarded; m.validator is never set
}
If the directory host is unreachable at provision time, Provision returns nil (success) but leaves m.validator == nil. The first request then hits httpsig.go:82:
if err := m.validator.Validate(r); err != nil { // nil pointer dereference
…which panics instead of returning an error. Expected behaviour: either fail provisioning loudly (return err) so Caddy reports a bad config, or set the module into a state that returns 503/401 for requests rather than dereferencing nil.
2. Only the first directory key is ever used
httpsig.go:72:
validator, err := NewValidator(dir.Keys[0])
A directory may legitimately publish multiple keys (multiple agents, or a current + next key during rotation). Only Keys[0] is loaded, so any request signed with another listed key fails verification with no indication why. This also panics if dir.Keys is empty (no length check). Suggest iterating over all keys and registering each into the verifier’s keyring, keyed by JWK thumbprint.
3. Directory is fetched once at startup; no refresh
The fetch happens only in Provision, so the trusted key set is frozen at startup. Rotating or adding a key in the published directory has no effect until Caddy is reloaded/restarted. A periodic refresh (or refetch-on-unknown-keyid) would make rotation work without downtime.
Minor
handler.go:50,56hardcodesAlgo_ED25519. The README already documents Ed25519-only as an example limitation, so this is expected — noting it only for completeness.httpsig.go:59comment typo: “the directory ios localhost”.
Reproduction (issue #1)
- Point
directory_baseat a host that is down or unresolvable. xcaddy buildthe plugin and./caddy run --config Caddyfile. Provisioning succeeds.- Send any request to the guarded route → panic from nil
m.validatorrather than a clean error/401.
Suggested direction
Provision: propagate the fetch/parse error (or guardServeHTTPagainst a nil validator and return an HTTP error).NewValidator: accept the full[]json.RawMessageand register every valid key; guard against an empty list.- Optionally add a refresh interval for the directory.
Happy to open a PR for #1 and #2 if that’s welcome.
- Lenguaje dominante
- Rust
- Estrellas
- 182
- Forks
- 49
- Merge medio
- 1 d 20 min
- PR fusionados (30 d)
- 19
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cloudflare/web-bot-auth
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
cloudflare/web-bot-auth#203 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
cloudflare/web-bot-auth#172 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 1-2 días Aptitud para principiantes 56/100
cloudflare/web-bot-auth#202 ·
Los mantenedores suelen responder en 1 día
-
Demo verifier rejects the dictionary-form Signature-Agent that draft -01 requires; accepts the legacy formPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
cloudflare/web-bot-auth#199 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 54/100
cloudflare/web-bot-auth#195 ·
Los mantenedores suelen responder en 1 día
Todos los issues de cloudflare/web-bot-auth
Issues similares
-
CI/CD ignore-for-release
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
eclipse-ankaios/ankaios#844 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
symposium-dev/symposium#530 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día