mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-08 10:46:37 +08:00
fix(security): patch SSRF in federation node import and restrict its access
This commit is contained in:
Submodule
+1
Submodule .worktrees/feat-dash-rule-adapter added at 8a6aacc45b
Submodule
+1
Submodule .worktrees/non-dash-release added at 608fbf74de
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -636,6 +637,16 @@ func (h *Handler) nodeImport(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rUrl, err := url.Parse(req.RemoteURL)
|
||||||
|
if err != nil || (rUrl.Scheme != "http" && rUrl.Scheme != "https") {
|
||||||
|
response.WriteJSON(w, response.ErrDefault("Invalid Remote URL format"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := IsSafeRemoteAddr(rUrl.Host); err != nil {
|
||||||
|
response.WriteJSON(w, response.Err(403, "禁止将远程节点地址设置为内部网络或保留地址"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
domainCfg, _ := h.repo.GetConfigByName("panel_domain")
|
domainCfg, _ := h.repo.GetConfigByName("panel_domain")
|
||||||
localDomain := ""
|
localDomain := ""
|
||||||
if domainCfg != nil {
|
if domainCfg != nil {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ func requiresAdmin(path string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(path, "/api/v1/federation/share/") {
|
if strings.HasPrefix(path, "/api/v1/federation/share/") || strings.HasPrefix(path, "/api/v1/federation/node/") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user