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>
This commit is contained in:
Amariah Kamau 2026-07-30 13:50:17 +03:00
parent a884339a19
commit c389c26d8e

View file

@ -560,7 +560,7 @@ func replaceRemoteAdminServer(ctx Context, cfg *Config) error {
continue
}
cleanPath := path.Clean(permPath)
if cleanPath != permPath {
if cleanPath != permPath && strings.TrimRight(permPath, "/") != cleanPath {
return fmt.Errorf("access control %d permission %d: path %q is not canonical (did you mean %q?)", i, j, permPath, cleanPath)
}
}