The vulnerability lies in the vars_regexp matcher in Caddy, specifically in the MatchVarsRE.Match function in modules/caddyhttp/vars.go. The root cause is a double-expansion of user-controlled input. When a user provides a value containing a Caddy placeholder, such as {env.DATABASE_URL} or {file./etc/passwd}, in a request element that is processed by vars_regexp, the server evaluates it twice. The first expansion resolves the request variable to the user-provided string, and the second, unintended expansion evaluates the placeholders within that string. This allows an attacker to craft requests that cause the server to leak sensitive information from environment variables, local files, or system information. The vulnerability was introduced in pull request #5408, which added the line valExpanded := repl.ReplaceAll(varStr, "") to the Match function. This change was intended to fix an issue with placeholder keys but inadvertently introduced the double-expansion vulnerability. The fix is to remove the second expansion by using the raw variable string directly.