Restrict Host-based origin fetches to Steam CDN names.
When upstream is empty the cache used the client Host as the fetch URL, so any LAN client with a spoofed Steam User-Agent could proxy to literal IPs or arbitrary names. Reject those hosts, stop following upstream redirects, and keep path-only cache keys so real Steam CDNs still share entries.
This commit is contained in:
@@ -345,6 +345,18 @@ func (sc *SteamCache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
req.Host = r.Host
|
||||
} else { // if no upstream server is configured, proxy the request to the host specified in the request
|
||||
host := r.Host
|
||||
if !hostAllowedForDirectFetch(host) {
|
||||
logger.Logger.Warn().
|
||||
Str("host", host).
|
||||
Str("client_ip", clientIP).
|
||||
Msg("Rejecting direct-fetch Host (not a Steam CDN name)")
|
||||
sc.metrics.IncrementErrors()
|
||||
if isNew {
|
||||
coalescedReq.complete(nil, fmt.Errorf("host not allowed for direct fetch"))
|
||||
}
|
||||
http.Error(w, "Invalid URL", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if r.Header.Get("X-Sls-Https") == "enable" {
|
||||
host = "https://" + host
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user