Skip to content

Commit 7c82e9b

Browse files
authored
Update auth header validation (#904)
1 parent 6e1c46e commit 7c82e9b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/operator/endpoints/middleware.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,16 @@ func AuthMiddleware(next http.Handler) http.Handler {
6767
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
6868
authHeader := r.Header.Get("Authorization")
6969

70-
if !strings.HasPrefix(authHeader, "CortexAWS") {
70+
if authHeader == "" {
7171
respondError(w, r, ErrorAuthHeaderMissing())
7272
return
7373
}
7474

75+
if len(authHeader) < 10 || !strings.HasPrefix(authHeader, "CortexAWS") {
76+
respondError(w, r, ErrorAuthHeaderMalformed())
77+
return
78+
}
79+
7580
parts := strings.Split(authHeader[10:], "|")
7681
if len(parts) != 2 {
7782
respondError(w, r, ErrorAuthHeaderMalformed())

0 commit comments

Comments
 (0)