Skip to content

Commit

Permalink
fastcgi: Protect against requests with null bytes in the path (#4614)
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie authored Mar 7, 2022
1 parent ab04559 commit c8f2834
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ func (t *Transport) Provision(ctx caddy.Context) error {

// RoundTrip implements http.RoundTripper.
func (t Transport) RoundTrip(r *http.Request) (*http.Response, error) {
// Disallow null bytes in the request path, because
// PHP upstreams may do bad things, like execute a
// non-PHP file as PHP code. See #4574
if strings.Contains(r.URL.Path, "\x00") {
return nil, caddyhttp.Error(http.StatusBadRequest, fmt.Errorf("invalid request path"))
}

env, err := t.buildEnv(r)
if err != nil {
return nil, fmt.Errorf("building environment: %v", err)
Expand Down

0 comments on commit c8f2834

Please sign in to comment.