Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 11, 07:15 UTC
admin: normalize request path in remote admin access-control check (defense-in-depth) (#7910)
* admin: normalize request path in remote admin access-control check Co-authored-by: atlarix-agent <agent@atlarix.dev> * admin: fix empty allowedPath regression and dead code in path normalization path.Clean("") returns ".", so cleaning allowedPath unconditionally silently broke the allow-all behavior when Paths: [""] is configured. Short-circuit the empty case before cleaning to preserve that behavior. Also remove the dead strings.HasSuffix(allowedPath, "/") branch — after path.Clean the path never has a trailing slash, so the unified reqPath == allowedPath || HasPrefix(reqPath, allowedPath+"/") form covers exact match, subpath boundary, and trailing-slash requests. Co-authored-by: atlarix-agent <agent@atlarix.dev> Co-authored-by: iabdullah215 <muhammadabdullah8040@gmail.com> * admin: validate non-canonical configured paths at provisioning path.Clean(allowedPath) silently broadens misconfigured values like // or /.. into /, which grants unintended access to all endpoints. Reject non-canonical paths during provisioning in replaceRemoteAdminServer so misconfigurations fail fast with a clear error. The path.Clean in adminPathAllowed remains as defense-in-depth but is now a safe no-op on validated inputs. Co-authored-by: atlarix-agent <agent@atlarix.dev> * admin: validate non-canonical configured paths at provisioning path.Clean(allowedPath) silently broadens misconfigured values like // or /.. into /, which grants unintended access to all endpoints. Reject non-canonical paths during provisioning in replaceRemoteAdminServer so misconfigurations fail fast with a clear error. The path.Clean in adminPathAllowed remains as defense-in-depth but is now a safe no-op on validated inputs. Co-authored-by: atlarix-agent <agent@atlarix.dev> * admin: fix TrimRight → TrimSuffix in provisioning path validation strings.TrimRight strips all trailing slashes, so a configured path like /foo// passed validation (both slashes trimmed to /foo matching path.Clean output) but was silently broadened to /foo at runtime. Use strings.TrimSuffix instead, which removes exactly one trailing slash — the only form the exemption was meant to allow (users write /pki/ca/prod/ meaning the /pki/ca/prod scope). Also update the // test case: with TrimSuffix, // is just / + one trailing slash, which is valid under the exemption. Add a new test for /foo// (double trailing slashes → wantErr: true). Co-authored-by: atlarix-agent <agent@atlarix.dev> * admin: reject non-canonical root permission path * admin: preserve trailing-slash permission semantics --------- Co-authored-by: atlarix-agent <agent@atlarix.dev> Co-authored-by: iabdullah215 <muhammadabdullah8040@gmail.com> Co-authored-by: Zen Dodd <mail@steadytao.com>