Advisory

GHSA-m2w3-8f23-hxxf

Details, part 2 of 2. The advisory

Details

Impact

Information disclosure. An attacker can leak:

  • Environment variables ({env.DATABASE_URL}, {env.AWS_SECRET_ACCESS_KEY}, etc.)
  • File contents up to 1MB ({file./etc/passwd}, {file./proc/self/environ})
  • System info ({system.hostname}, {system.os}, {system.wd})

Requires a config where vars_regexp matches user-controlled input and the capture group is reflected back. The bug was introduced by PR #5408 (fix for #5406), affecting all versions since.

Suggested one-line fix:

--- a/modules/caddyhttp/vars.go
+++ b/modules/caddyhttp/vars.go
@@ -334,7 +334,7 @@
 			varStr = fmt.Sprintf("%v", vv)
 		}

-		valExpanded := repl.ReplaceAll(varStr, "")
+		valExpanded := varStr
 		if match := val.Match(valExpanded, repl); match {
 			return match, nil
 		}

This makes vars_regexp consistent with header_regexp and path_regexp. Placeholder key resolution (lines 315-318) is unaffected.

Tested on latest main commit at 95941a71 (2026-02-17).

AI Disclosure: Used Claude (Anthropic) during code review and testing. All findings verified manually.

Sources & licences