Skip to content

Commit

Permalink
Add extra check to reject path escape shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
oskirby committed Jul 6, 2024
1 parent ab7aa0d commit 02c9b10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"net/url"
"os"
"path"
"strings"
"time"

"github.com/gorilla/mux"
Expand Down Expand Up @@ -552,6 +553,13 @@ func (a *autographer) handleGetX5u(w http.ResponseWriter, r *http.Request) {
return
}

// The handler regex should reject such paths, but let's be extra certain that we have been given
// a path without any attempt to escape the X5U upload directory.
if strings.Contains(pathChainFile, "/") || strings.Contains(pathChainFile, "\\") || strings.Contains(pathChainFile, "..") {
httpError(w, r, http.StatusBadRequest, "Invalid X5U file name '%s'", pathChainFile)
return
}

// Lookup the signer, and see if it has a local X5U chain upload location.
// Treat all errors as a 404 to avoid leaking unnecessary signer details as this
// endpoint has no authentication.
Expand Down

0 comments on commit 02c9b10

Please sign in to comment.