Query strings leak into Traefik access logs, browser history, and Referer headers. Admin key is now accepted only via X-Admin-Key; paste and can passwords only via X-Paste-Password (or the POST unlock form). Tests updated; new negative cases assert 401 for the query paths.
This commit is contained in:
@@ -160,13 +160,12 @@ func HandleResetAdminKey(dbPath string) {
|
||||
}
|
||||
|
||||
// adminKeyOK reports whether the request carries the correct admin key via
|
||||
// X-Admin-Key header or ?key=. Constant-time compare; failures and successes
|
||||
// are both logged (#40).
|
||||
// the X-Admin-Key header only. The ?key= query fallback was removed (#137):
|
||||
// query strings land in access logs, browser history, and Referer headers,
|
||||
// so accepting the key there leaked the admin secret. Constant-time compare;
|
||||
// failures and successes are both logged (#40).
|
||||
func (a *apiServer) adminKeyOK(r *http.Request, key string) bool {
|
||||
given := r.Header.Get("X-Admin-Key")
|
||||
if given == "" {
|
||||
given = r.URL.Query().Get("key")
|
||||
}
|
||||
return subtle.ConstantTimeCompare([]byte(given), []byte(key)) == 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user