Skip to content

Commit

Permalink
Merge pull request #2340 from headlamp-k8s/uncontrolled-data-path
Browse files Browse the repository at this point in the history
backend: Validate path from user
  • Loading branch information
illume authored Sep 18, 2024
2 parents 7ea69b6 + 1cb85fc commit 0c0442a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/cmd/headlamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ type OauthConfig struct {
}

func (h spaHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.URL.Path, "..") {
http.Error(w, "Contains unexpected '..'", http.StatusBadRequest)
}

// Clean the path to prevent directory traversal
path := filepath.Clean(r.URL.Path)
path = strings.TrimPrefix(path, h.baseURL)
Expand Down

0 comments on commit 0c0442a

Please sign in to comment.