public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/caddy] f44: Backport upstream fix for CVE-2026-45135
@ 2026-11-21 4:36 Carl George
0 siblings, 0 replies; only message in thread
From: Carl George @ 2026-11-21 4:36 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/caddy
Branch : f44
Commit : 4047cffc401277634c8a9f109913c12a3c6c5544
Author : Carl George <carlwgeorge@fedoraproject.org>
Date : 2026-11-20T22:14:41-06:00
Stats : +655/-14 in 6 file(s)
URL : https://src.fedoraproject.org/rpms/caddy/c/4047cffc401277634c8a9f109913c12a3c6c5544?branch=f44
Log:
Backport upstream fix for CVE-2026-45135
- Backport upstream fix for CVE-2026-52845
- Backport upstream fix for CVE-2026-52846
- Override vendored github.com/quic-go/quic-go to 0.59.1 to fix CVE-2026-40898
- Override vendored golang.org/x/crypto to 0.56.0 to fix CVE-2026-56855 and CVE-2026-78662
- Override vendored golang.org/x/net to 0.55.0 to fix CVE-2026-25681
- Override vendored github.com/go-chi/chi to 5.5.0 to fix CVE-2026-72815, CVE-2026-72817, CVE-2026-114437, and CVE-2026-118681
- Override vendored github.com/grpc-ecosystem/grpc-gateway to 2.29.0 to fix CVE-2026-37236
- Remove selinux ports that are now part of the default policy rhbz#2496788
---
diff --git a/0010-caddyhttp-Replace-splitPos-fallback-with-stricter-matching.patch b/0010-caddyhttp-Replace-splitPos-fallback-with-stricter-matching.patch
new file mode 100644
index 0000000..c73966a
--- /dev/null
+++ b/0010-caddyhttp-Replace-splitPos-fallback-with-stricter-matching.patch
@@ -0,0 +1,211 @@
+From df12949bb5ca59ad303759c0764c949596ef8bc4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= <kevin@dunglas.fr>
+Date: Thu, 7 May 2026 21:59:42 +0200
+Subject: [PATCH] caddyhttp: Replace splitPos fallback with stricter matching
+
+Both fallbacks in splitPos relied on golang.org/x/text/search with
+search.IgnoreCase, which performs Unicode equivalence matching far beyond
+ASCII case folding. Combined with the validated-ASCII guarantee on every
+SplitPath entry, that fallback turned non-PHP filenames into PHP scripts:
+
+- when the inner loop hit a non-ASCII byte and the IndexString fallback
+ returned -1, the loop broke without resetting match=false, so a stale
+ match=true caused a non-existent .php to be reported (PoC:
+ "/name.<U+00A1>.txt").
+- search.IgnoreCase folded fullwidth, mathematical and circled letters
+ onto ASCII, so "/shell.<math sans-serif php>",
+ "/shell.<fullwidth p>hp", "/shell.<circled php>" were all detected as
+ ".php" files.
+
+Replace the fallback with strict byte-level ASCII case-insensitive
+matching: any byte >= utf8.RuneSelf in the path can never be part of a
+match, since SplitPath entries are validated ASCII-only and lower-cased
+in Provision(). This keeps the hot path branch-light and removes the
+x/text/search dependency from the main module.
+
+Reported against FrankenPHP as GHSA-3g8v-8r37-cgjm and
+GHSA-v4h7-cj44-8fc8. The vulnerable function in this module was adapted
+from the same FrankenPHP code.
+
+Fixes: CVE-2026-45135
+
+(cherry picked from commit fb324331f40782ac7a48d83f591c2bb7615d7eed)
+---
+ .../caddyhttp/reverseproxy/fastcgi/fastcgi.go | 34 +++-----
+ .../reverseproxy/fastcgi/fastcgi_test.go | 87 +++++++++++++++++++
+ 2 files changed, 99 insertions(+), 22 deletions(-)
+
+diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+index 51d4ebc2..c405d913 100644
+--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
++++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+@@ -28,8 +28,6 @@ import (
+
+ "go.uber.org/zap"
+ "go.uber.org/zap/zapcore"
+- "golang.org/x/text/language"
+- "golang.org/x/text/search"
+
+ "github.com/caddyserver/caddy/v2"
+ "github.com/caddyserver/caddy/v2/modules/caddyhttp"
+@@ -404,14 +402,19 @@ func (t Transport) buildEnv(r *http.Request) (envVars, error) {
+ return env, nil
+ }
+
+-var splitSearchNonASCII = search.New(language.Und, search.IgnoreCase)
+-
+ // splitPos returns the index where path should
+ // be split based on t.SplitPath.
+ //
+ // example: if splitPath is [".php"]
+ // "/path/to/script.php/some/path": ("/path/to/script.php", "/some/path")
+ //
++// Matching is strictly ASCII case-insensitive. Bytes >= utf8.RuneSelf in path
++// never match any split entry: split strings are validated ASCII-only and
++// lower-cased in Provision(), so any Unicode equivalence (e.g. fullwidth or
++// mathematical letters folding to ASCII) would let an attacker upload a file
++// whose name contains such code points and have it served as PHP. See
++// FrankenPHP advisories GHSA-3g8v-8r37-cgjm and GHSA-v4h7-cj44-8fc8.
++//
+ // Adapted from FrankenPHP's code (copyright 2026 Kévin Dunglas, MIT license)
+ func (t Transport) splitPos(path string) int {
+ // TODO: from v1...
+@@ -424,31 +427,18 @@ func (t Transport) splitPos(path string) int {
+
+ pathLen := len(path)
+
+- // We are sure that split strings are all ASCII-only and lower-case because of validation and normalization in Provision().
+ for _, split := range t.SplitPath {
+ splitLen := len(split)
++ if splitLen == 0 || splitLen > pathLen {
++ continue
++ }
+
+- for i := 0; i < pathLen; i++ {
+- if path[i] >= utf8.RuneSelf {
+- if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {
+- return end
+- }
+-
+- break
+- }
+-
+- if i+splitLen > pathLen {
+- continue
+- }
+-
++ for i := 0; i <= pathLen-splitLen; i++ {
+ match := true
+ for j := 0; j < splitLen; j++ {
+ c := path[i+j]
+-
+ if c >= utf8.RuneSelf {
+- if _, end := splitSearchNonASCII.IndexString(path, split); end > -1 {
+- return end
+- }
++ match = false
+
+ break
+ }
+diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go
+index 7097ff79..4977ae99 100644
+--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go
++++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go
+@@ -191,6 +191,65 @@ func TestSplitPos(t *testing.T) {
+ splitPath: []string{".php"},
+ wantPos: 9,
+ },
++ // Regression tests adapted from FrankenPHP advisories
++ // GHSA-3g8v-8r37-cgjm and GHSA-v4h7-cj44-8fc8: search.IgnoreCase
++ // matched Unicode equivalents of ASCII letters as ".php", and an
++ // inner non-ASCII byte path could leave the match flag stale.
++ {
++ name: "non-ascii byte after dot must not match",
++ path: "/PoC-match-unset.¡.txt",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "non-ascii byte mid-extension must not match",
++ path: "/script.p\xc2\xa1p",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "small full stop ﹒ in extension must not match",
++ path: "/shell﹒php",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "fullwidth full stop . in extension must not match",
++ path: "/shell.php",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "fullwidth p in extension must not match",
++ path: "/shell.php",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "circled php must not match",
++ path: "/shell.ⓟⓗⓟ",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "mathematical sans-serif bold php must not match",
++ path: "/shell.\U0001D5FD\U0001D5F5\U0001D5FD",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "mathematical script php must not match",
++ path: "/shell.\U0001D4C5\U0001D4BD\U0001D4C5",
++ splitPath: []string{".php"},
++ wantPos: -1,
++ },
++ {
++ name: "circled php with later real php still picks the real one",
++ path: "/shell.ⓟⓗⓟ.anything-after-payload.php",
++ splitPath: []string{".php"},
++ // "/shell." (7) + "ⓟⓗⓟ" (3*3 bytes) + ".anything-after-payload.php" (27) = 43
++ wantPos: 43,
++ },
+ }
+
+ for _, tt := range tests {
+@@ -244,3 +303,31 @@ func TestSplitPosUnicodeSecurityRegression(t *testing.T) {
+ assert.Equal(t, ".txt.php", pathInfo, "path info should be the remainder after first .php")
+ }
+ }
++
++// TestSplitPosSecurityRegressionUnicodeBypass guards against the FrankenPHP
++// advisories GHSA-3g8v-8r37-cgjm (uninitialized match flag on inner non-ASCII
++// byte) and GHSA-v4h7-cj44-8fc8 (Unicode equivalence via search.IgnoreCase
++// folding fullwidth/mathematical/circled letters onto ASCII). Every payload
++// below produced a false positive in the vulnerable implementation; none
++// must match here.
++func TestSplitPosSecurityRegressionUnicodeBypass(t *testing.T) {
++ t.Parallel()
++
++ tr := Transport{SplitPath: []string{".php"}}
++ payloads := []string{
++ "/PoC-match-unset.¡.txt", // GHSA-3g8v: stale match=true on IndexString fallback
++ "/shell﹒php", // U+FE52 small full stop
++ "/shell.php", // U+FF0E fullwidth full stop
++ "/shell.php", // U+FF50 fullwidth p
++ "/shell.php", // U+FF48 fullwidth h
++ "/shell.php", // U+FF50 fullwidth p (trailing)
++ "/shell.\U0001D5C1\U0001D5B5\U0001D5C1", // mathematical sans-serif p/h
++ "/shell.\U0001D5FD\U0001D5F5\U0001D5FD", // mathematical sans-serif bold p/h
++ "/shell.\U0001D4C5\U0001D4BD\U0001D4C5", // mathematical script p/h
++ "/shell.ⓟⓗⓟ", // circled latin small
++ }
++
++ for _, p := range payloads {
++ assert.Equalf(t, -1, tr.splitPos(p), "payload %q must not be detected as .php", p)
++ }
++}
diff --git a/0011-caddyhttp-Drop-headers-with-underscore-in-their-names.patch b/0011-caddyhttp-Drop-headers-with-underscore-in-their-names.patch
new file mode 100644
index 0000000..3f49e94
--- /dev/null
+++ b/0011-caddyhttp-Drop-headers-with-underscore-in-their-names.patch
@@ -0,0 +1,288 @@
+From fc6395b755a377ffa85dd38e18f24870334d8cbb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= <kevin@dunglas.fr>
+Date: Fri, 29 May 2026 19:37:17 +0200
+Subject: [PATCH] caddyhttp: Drop headers with underscore in their names
+
+Fixes: CVE-2026-52845
+
+(cherry picked from commit 3eb8e48ff052e1ad16d88c683672c306d2077a11)
+---
+ caddytest/integration/forwardauth_test.go | 65 ++++++++++++++++
+ .../caddyhttp/reverseproxy/fastcgi/fastcgi.go | 2 +-
+ .../reverseproxy/fastcgi/fastcgi_test.go | 24 ++++++
+ modules/caddyhttp/server.go | 21 ++++-
+ modules/caddyhttp/server_test.go | 77 +++++++++++++++++++
+ 5 files changed, 186 insertions(+), 3 deletions(-)
+
+diff --git a/caddytest/integration/forwardauth_test.go b/caddytest/integration/forwardauth_test.go
+index d0ecc2be..f07ae3c4 100644
+--- a/caddytest/integration/forwardauth_test.go
++++ b/caddytest/integration/forwardauth_test.go
+@@ -22,6 +22,8 @@ import (
+ "sync"
+ "testing"
+
++ "github.com/stretchr/testify/assert"
++
+ "github.com/caddyserver/caddy/v2/caddytest"
+ )
+
+@@ -204,3 +206,66 @@ func TestForwardAuthCopyHeadersAuthResponseWins(t *testing.T) {
+ t.Errorf("X-User-Role: want %q, got %q", wantUserRole, gotRole)
+ }
+ }
++
++// TestForwardAuthCopyHeadersUnderscoreAlias guards GHSA-f59h-q822-g45g:
++// a client-supplied `Remote_user` alias of the copy_headers target
++// `Remote-User` must be stripped before the auth route runs, otherwise
++// a downstream CGI/FastCGI backend would fold both names into the same
++// HTTP_REMOTE_USER variable and the attacker would override the trusted
++// identity.
++func TestForwardAuthCopyHeadersUnderscoreAlias(t *testing.T) {
++ const wantRemoteUser = "alice"
++
++ authSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
++ w.Header().Set("Remote-User", wantRemoteUser)
++ w.WriteHeader(http.StatusOK)
++ }))
++ t.Cleanup(authSrv.Close)
++
++ type received struct {
++ remoteUserHyphen, remoteUserUnderscore string
++ }
++ var (
++ mu sync.Mutex
++ last received
++ )
++ backendSrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
++ mu.Lock()
++ last = received{
++ remoteUserHyphen: r.Header.Get("Remote-User"),
++ remoteUserUnderscore: strings.Join(r.Header["Remote_user"], ","),
++ }
++ mu.Unlock()
++ fmt.Fprint(w, "ok")
++ }))
++ t.Cleanup(backendSrv.Close)
++
++ tester := caddytest.NewTester(t)
++ tester.InitServer(fmt.Sprintf(`
++ {
++ skip_install_trust
++ admin localhost:2999
++ http_port 9080
++ https_port 9443
++ grace_period 1ns
++ }
++ http://localhost:9080 {
++ forward_auth %s {
++ uri /
++ copy_headers Remote-User
++ }
++ reverse_proxy %s
++ }
++ `, strings.TrimPrefix(authSrv.URL, "http://"), strings.TrimPrefix(backendSrv.URL, "http://")), "caddyfile")
++
++ req, _ := http.NewRequest(http.MethodGet, "http://localhost:9080/", nil)
++ // Set the underscore alias via raw map access to bypass http.Header
++ // canonicalization, as an attacker would on the wire.
++ req.Header["Remote_user"] = []string{"attacker"}
++ tester.AssertResponse(req, http.StatusOK, "ok")
++
++ mu.Lock()
++ defer mu.Unlock()
++ assert.Equal(t, wantRemoteUser, last.remoteUserHyphen, "trusted Remote-User must reach the backend")
++ assert.Empty(t, last.remoteUserUnderscore, "underscore alias must be dropped")
++}
+diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+index c405d913..af63d918 100644
+--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
++++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+@@ -493,7 +493,7 @@ var tlsProtocolStrings = map[uint16]string{
+ tls.VersionTLS13: "TLSv1.3",
+ }
+
+-var headerNameReplacer = strings.NewReplacer(" ", "_", "-", "_")
++var headerNameReplacer = strings.NewReplacer("-", "_")
+
+ // Interface guards
+ var (
+diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go
+index 4977ae99..2b22c813 100644
+--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go
++++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go
+@@ -304,6 +304,30 @@ func TestSplitPosUnicodeSecurityRegression(t *testing.T) {
+ }
+ }
+
++// TestHeaderNameReplacer asserts the CGI header-to-env normalization rule:
++// hyphens are mapped to underscores while every other character (including
++// spaces) is passed through. Spaces are not RFC 7230 tokens, so they cannot
++// reach this function from the wire; the only header names that survive
++// untouched at the server layer are sanitized by the underscore filter in
++// caddyhttp.Server.serveHTTP (see GHSA-f59h-q822-g45g).
++func TestHeaderNameReplacer(t *testing.T) {
++ tests := []struct {
++ in, want string
++ }{
++ {"X-Forwarded-For", "X_Forwarded_For"},
++ {"Remote-User", "Remote_User"},
++ // Underscores are preserved (the server has already dropped any
++ // underscore-named headers when the filter is on).
++ {"Remote_User", "Remote_User"},
++ // Spaces are not rewritten because Go's HTTP parser rejects whitespace in
++ // header field names.
++ {"Foo Bar", "Foo Bar"},
++ }
++ for _, tt := range tests {
++ assert.Equal(t, tt.want, headerNameReplacer.Replace(tt.in), "input %q", tt.in)
++ }
++}
++
+ // TestSplitPosSecurityRegressionUnicodeBypass guards against the FrankenPHP
+ // advisories GHSA-3g8v-8r37-cgjm (uninitialized match flag on inner non-ASCII
+ // byte) and GHSA-v4h7-cj44-8fc8 (Unicode equivalence via search.IgnoreCase
+diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
+index f6666c14..b15d1a65 100644
+--- a/modules/caddyhttp/server.go
++++ b/modules/caddyhttp/server.go
+@@ -366,8 +366,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ return
+ }
+
+- // execute the primary handler chain
+- err := s.primaryHandlerChain.ServeHTTP(w, r)
++ err := s.serveHTTP(w, r)
+ duration = time.Since(start)
+
+ // if no errors, we're done!
+@@ -450,6 +449,24 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ }
+ }
+
++func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) error {
++ // Drop headers whose names contain `_`: once FastCGI/CGI/FrankenPHP etc. rewrites `-` to
++ // `_`, an underscore alias collides with the legitimate hyphenated header
++ // and can bypass `forward_auth copy_headers` (GHSA-f59h-q822-g45g).
++ for k := range r.Header {
++ if strings.ContainsRune(k, '_') {
++ delete(r.Header, k)
++
++ if c := s.logger.Check(zapcore.DebugLevel, "dropping header containing underscore"); c != nil {
++ c.Write(zap.String("header", k))
++ }
++ }
++ }
++
++ // execute the primary handler chain
++ return s.primaryHandlerChain.ServeHTTP(w, r)
++}
++
+ // wrapPrimaryRoute wraps stack (a compiled middleware handler chain)
+ // in s.enforcementHandler which performs crucial security checks, etc.
+ func (s *Server) wrapPrimaryRoute(stack Handler) Handler {
+diff --git a/modules/caddyhttp/server_test.go b/modules/caddyhttp/server_test.go
+index d47f55c6..20511488 100644
+--- a/modules/caddyhttp/server_test.go
++++ b/modules/caddyhttp/server_test.go
+@@ -1,16 +1,20 @@
+ package caddyhttp
+
+ import (
++ "bufio"
+ "bytes"
+ "context"
+ "io"
++ "net"
+ "net/http"
+ "net/http/httptest"
+ "net/netip"
++ "strings"
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/assert"
++ "github.com/stretchr/testify/require"
+ "go.uber.org/zap"
+ "go.uber.org/zap/zapcore"
+ )
+@@ -445,6 +449,79 @@ func TestServer_DetermineTrustedProxy_MatchRightMostUntrustedSkippingTrusted(t *
+ assert.Equal(t, clientIP, "45.54.45.54")
+ }
+
++// TestServer_serveHTTP_DropsUnderscoreHeader covers GHSA-f59h-q822-g45g: an
++// underscore-named alias (e.g. `Remote_user`) of a hyphenated header must be
++// dropped before any handler runs.
++func TestServer_serveHTTP_DropsUnderscoreHeader(t *testing.T) {
++ got := &http.Header{}
++ s := &Server{
++ logger: zap.NewNop(),
++ primaryHandlerChain: HandlerFunc(func(w http.ResponseWriter, r *http.Request) error {
++ *got = r.Header.Clone()
++ return nil
++ }),
++ }
++
++ req := httptest.NewRequest(http.MethodGet, "http://example.com/", nil)
++ req.Header["X-Real-Header"] = []string{"ok"}
++ req.Header["Remote_user"] = []string{"attacker"}
++ req.Header["Remote_groups"] = []string{"admin"}
++
++ require.NoError(t, s.serveHTTP(httptest.NewRecorder(), req))
++ assert.NotContains(t, *got, "Remote_user")
++ assert.NotContains(t, *got, "Remote_groups")
++ assert.Equal(t, "ok", got.Get("X-Real-Header"))
++}
++
++// TestServer_serveHTTP_LogsDroppedUnderscoreHeader verifies each dropped
++// header is emitted at debug level so operators can diagnose unexpectedly
++// missing headers without spamming the log on adversarial traffic.
++func TestServer_serveHTTP_LogsDroppedUnderscoreHeader(t *testing.T) {
++ var buf bytes.Buffer
++ s := &Server{
++ logger: testLogger(buf.Write),
++ primaryHandlerChain: HandlerFunc(func(http.ResponseWriter, *http.Request) error {
++ return nil
++ }),
++ }
++
++ req := httptest.NewRequest(http.MethodGet, "http://example.com/", nil)
++ req.Header["Remote_user"] = []string{"attacker"}
++
++ require.NoError(t, s.serveHTTP(httptest.NewRecorder(), req))
++ assert.Contains(t, buf.String(), `"level":"debug"`)
++ assert.Contains(t, buf.String(), `"msg":"dropping header containing underscore"`)
++ assert.Contains(t, buf.String(), `"header":"Remote_user"`)
++}
++
++// TestServer_SpaceInHeaderNameReturnsBadRequest documents why the underscore
++// filter does not also strip space-named headers: Go's HTTP parser rejects a
++// space in a field name with 400 before any handler runs, so such a request
++// can never reach Caddy's pipeline.
++func TestServer_SpaceInHeaderNameReturnsBadRequest(t *testing.T) {
++ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
++ t.Errorf("handler must not be reached; got headers %v", r.Header)
++ }))
++ t.Cleanup(srv.Close)
++
++ addr := strings.TrimPrefix(srv.URL, "http://")
++ conn, err := net.DialTimeout("tcp", addr, 5*time.Second)
++ require.NoError(t, err)
++ t.Cleanup(func() { _ = conn.Close() })
++ require.NoError(t, conn.SetDeadline(time.Now().Add(5*time.Second)))
++
++ _, err = conn.Write([]byte("GET / HTTP/1.1\r\n" +
++ "Host: " + addr + "\r\n" +
++ "Remote User: attacker\r\n" +
++ "Connection: close\r\n\r\n"))
++ require.NoError(t, err)
++
++ resp, err := http.ReadResponse(bufio.NewReader(conn), nil)
++ require.NoError(t, err)
++ t.Cleanup(func() { _ = resp.Body.Close() })
++ assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
++}
++
+ func TestServer_DetermineTrustedProxy_MatchRightMostUntrustedFirst(t *testing.T) {
+ localPrivatePrefix, _ := netip.ParsePrefix("10.0.0.0/8")
+
diff --git a/0012-templates-fix-funcStripHTML-bypass-via-depth-counter-7785.patch b/0012-templates-fix-funcStripHTML-bypass-via-depth-counter-7785.patch
new file mode 100644
index 0000000..deff3f6
--- /dev/null
+++ b/0012-templates-fix-funcStripHTML-bypass-via-depth-counter-7785.patch
@@ -0,0 +1,137 @@
+From f003239e3ea38ce3cd27c229291f0d0fad7a765a Mon Sep 17 00:00:00 2001
+From: JM Sanchez <77505889+jmrcsnchz@users.noreply.github.com>
+Date: Tue, 2 Jun 2026 03:35:02 +0800
+Subject: [PATCH] templates: fix funcStripHTML bypass via depth counter (#7785)
+
+The previous false-start approach allowed XSS bypass via inputs like <<>img src=x onerror=alert(1)> and failed on stacked angle brackets.
+
+Replace the tagStart/inTag state machine with a depth counter that mirrors PHP strip_tags behaviour: each '<' increments depth, each '>' decrements it, and text is only emitted at depth zero. Quoted attribute values (both single and double) are tracked so '>' inside href values does not prematurely close a tag.
+
+Also expand TestStripHTML with attack path coverage.
+
+Signed-off-by: JM Sanchez <77505889+jmrcsnchz@users.noreply.github.com>
+
+Fixes: CVE-2026-52846
+
+(cherry picked from commit e2eee6a7fce366321294c9c2a79f3146891dcbdf)
+---
+ modules/caddyhttp/templates/tplcontext.go | 47 +++++++++----------
+ .../caddyhttp/templates/tplcontext_test.go | 40 ++++++++++++++--
+ 2 files changed, 57 insertions(+), 30 deletions(-)
+
+diff --git a/modules/caddyhttp/templates/tplcontext.go b/modules/caddyhttp/templates/tplcontext.go
+index ee553e7a..4e8ec925 100644
+--- a/modules/caddyhttp/templates/tplcontext.go
++++ b/modules/caddyhttp/templates/tplcontext.go
+@@ -312,35 +312,32 @@ func (c TemplateContext) Host() (string, error) {
+ return host, nil
+ }
+
+-// funcStripHTML returns s without HTML tags. It is fairly naive
+-// but works with most valid HTML inputs.
++// funcStripHTML returns s without HTML tags. Similar to PHP's strip_tags()
+ func (TemplateContext) funcStripHTML(s string) string {
+ var buf bytes.Buffer
+- var inTag, inQuotes bool
+- var tagStart int
+- for i, ch := range s {
+- if inTag {
+- if ch == '>' && !inQuotes {
+- inTag = false
+- } else if ch == '<' && !inQuotes {
+- // false start
+- buf.WriteString(s[tagStart:i])
+- tagStart = i
+- } else if ch == '"' {
+- inQuotes = !inQuotes
++ depth := 0
++ var quoteChar rune
++ for _, ch := range s {
++ switch {
++ case depth > 0 && quoteChar == 0 && (ch == '"' || ch == '\''):
++ // entering a quoted attribute value
++ quoteChar = ch
++ case depth > 0 && ch == quoteChar:
++ // leaving a quoted attribute value
++ quoteChar = 0
++ case ch == '<' && quoteChar == 0:
++ depth++
++ case ch == '>' && quoteChar == 0:
++ if depth > 0 {
++ depth--
++ } else {
++ buf.WriteRune(ch) // stray '>' with no opening '<', keep it
++ }
++ default:
++ if depth == 0 {
++ buf.WriteRune(ch)
+ }
+- continue
+- }
+- if ch == '<' {
+- inTag = true
+- tagStart = i
+- continue
+ }
+- buf.WriteRune(ch)
+- }
+- if inTag {
+- // false start
+- buf.WriteString(s[tagStart:])
+ }
+ return buf.String()
+ }
+diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go
+index 67ebbac7..1ff6caef 100644
+--- a/modules/caddyhttp/templates/tplcontext_test.go
++++ b/modules/caddyhttp/templates/tplcontext_test.go
+@@ -419,14 +419,44 @@ func TestStripHTML(t *testing.T) {
+ expect: `h1`,
+ },
+ {
+- // tags not closed
++ // unclosed tag — trailing text must be stripped, not emitted
+ input: `<h1`,
+- expect: `<h1`,
++ expect: ``,
+ },
+ {
+- // false start
+- input: `<h1<b>hi`,
+- expect: `<h1hi`,
++ // false start — second '<' increments depth, single '>' only closes one level
++ input: `<h1<b>hi`,
++ expect: ``,
++ },
++ {
++ // XSS bypass via double opening bracket
++ input: `<<>img src=x onerror=alert('XSS')>`,
++ expect: ``,
++ },
++ {
++ // stacked angle brackets (PHP strip_tags parity)
++ input: `<<<<<>>>>><b>hello</b>`,
++ expect: `hello`,
++ },
++ {
++ // unclosed tag strips trailing text
++ input: `hello <world`,
++ expect: `hello `,
++ },
++ {
++ // '>' inside double-quoted attribute must not close tag early
++ input: `<a href="foo>bar">text</a>`,
++ expect: `text`,
++ },
++ {
++ // '>' inside single-quoted attribute must not close tag early
++ input: `<a href='foo>bar'>text</a>`,
++ expect: `text`,
++ },
++ {
++ // stray '>' with no opening '<' is preserved
++ input: `stray > bracket`,
++ expect: `stray > bracket`,
+ },
+ } {
+ actual := tplContext.funcStripHTML(test.input)
diff --git a/caddy.spec b/caddy.spec
index 7229f9e..d059590 100644
--- a/caddy.spec
+++ b/caddy.spec
@@ -42,6 +42,12 @@ Patch: 0007-fix-FastCGI-split-SCRIPT_NAME-PATH_INFO-confusion.patch
Patch: 0008-forward_auth-copy_headers-does-not-strip-client-supplied-identity-headers-7545.patch
# CVE-2026-30852
Patch: 0009-Only-apply-repl.ReplaceAll-on-values-from-literal-variable-names.patch
+# CVE-2026-45135
+Patch: 0010-caddyhttp-Replace-splitPos-fallback-with-stricter-matching.patch
+# CVE-2026-52845
+Patch: 0011-caddyhttp-Drop-headers-with-underscore-in-their-names.patch
+# CVE-2026-52846
+Patch: 0012-templates-fix-funcStripHTML-bypass-via-depth-counter-7785.patch
BuildRequires: go-rpm-macros
BuildRequires: go-vendor-tools
@@ -147,9 +153,6 @@ if [ -x /usr/sbin/semanage -a -x /usr/sbin/restorecon ]; then
restorecon -r %{_bindir}/caddy %{_datadir}/caddy %{_sysconfdir}/caddy %{_sharedstatedir}/caddy || :
fi
if [ -x /usr/sbin/semanage ]; then
- # QUIC
- semanage port --add --type http_port_t --proto udp 80 2> /dev/null || :
- semanage port --add --type http_port_t --proto udp 443 2> /dev/null || :
# admin endpoint
semanage port --add --type http_port_t --proto tcp 2019 2> /dev/null || :
fi
@@ -173,9 +176,6 @@ if [ $1 -eq 0 ]; then
semanage fcontext --delete --type httpd_sys_content_t '%{_datadir}/caddy(/.*)?' 2> /dev/null || :
semanage fcontext --delete --type httpd_config_t '%{_sysconfdir}/caddy(/.*)?' 2> /dev/null || :
semanage fcontext --delete --type httpd_var_lib_t '%{_sharedstatedir}/caddy(/.*)?' 2> /dev/null || :
- # QUIC
- semanage port --delete --type http_port_t --proto udp 80 2> /dev/null || :
- semanage port --delete --type http_port_t --proto udp 443 2> /dev/null || :
# admin endpoint
semanage port --delete --type http_port_t --proto tcp 2019 2> /dev/null || :
fi
diff --git a/go-vendor-tools.toml b/go-vendor-tools.toml
index 7cf1636..12df3b3 100644
--- a/go-vendor-tools.toml
+++ b/go-vendor-tools.toml
@@ -5,22 +5,27 @@ pre_commands = [
]
[archive.dependency_overrides]
-# CVE-2025-64702
-"github.com/quic-go/quic-go" = "v0.57.0"
+# CVE-2025-64702, CVE-2026-40898
+"github.com/quic-go/quic-go" = "v0.59.1"
-# CVE-2025-47913, CVE-2026-39828, CVE-2026-39829, and CVE-2026-39830
-"golang.org/x/crypto" = "v0.52.0"
+# CVE-2025-47913, CVE-2026-39828, CVE-2026-39829, and CVE-2026-39830, CVE-2026-56855, CVE-2026-78662
+"golang.org/x/crypto" = "v0.56.0"
+
+# CVE-2026-25681
+"golang.org/x/net" = "v0.55.0"
# CVE-2025-44005 and CVE-2026-40097
"github.com/smallstep/certificates" = "v0.30.0"
-# CVE-2025-69725
-# v5.2.4 fixes the CVE, but v5.2.5 is needed to work with other overrides
-"github.com/go-chi/chi/v5" = "v5.2.5"
+# CVE-2025-69725, CVE-2026-72815, CVE-2026-72817, CVE-2026-114437, CVE-2026-118681
+"github.com/go-chi/chi/v5" = "v5.5.0"
# CVE-2026-5160
"github.com/yuin/goldmark/renderer/html" = "v1.7.17"
+# CVE-2026-37236
+"github.com/grpc-ecosystem/grpc-gateway/v2" = "v2.29.0"
+
[licensing]
detector = "askalono"
diff --git a/sources b/sources
index 1d64240..b0bf277 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,2 @@
SHA512 (caddy-2.10.2.tar.gz) = 986b11e26cdaa4fbe554cf7b6bb333404fc33190945ef995122518a3fe2fe582a4cf4d2a8ab463e045857650e9deb88123f8d86a93dbdc465635755b00356205
-SHA512 (caddy-2.10.2-vendor.tar.bz2) = d2f64abee70503b70268c1f62497c9368517ea1a7ff073977974ebee0968cd21649fe01bf691bef1e3b0a60f5596af217ebbb50d4263831bb5b7cbf8fa46d6ed
+SHA512 (caddy-2.10.2-vendor.tar.bz2) = ab3d62e716271e8daaadfd753db606a5b58773cafd9c98030b04070693f84b36aa3c8c8449f29fe4ceb3f527aeb173448617b00e669fce6eaf95754a09a28321
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-21 4:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 4:36 [rpms/caddy] f44: Backport upstream fix for CVE-2026-45135 Carl George
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox