fix: harden SSRF protection for unauthenticated and user-level endpoints
- Add ValidateURLWithFetchSetting check before fetching MJ image URLs in RelayMidjourneyImage (unauthenticated endpoint) - Add ValidateURLWithFetchSetting check before fetching video URLs in VideoProxy (upstream-controlled URL) - Enable ApplyIPFilterForDomain by default to prevent DNS rebinding bypass of SSRF protection - Elevate FetchModels endpoint from AdminAuth to RootAuth - Update frontend: mark domain IP filtering as recommended, update description and i18n translations (zh-CN/zh-TW/en/fr/ja/ru/vi)
This commit is contained in:
@@ -49,6 +49,13 @@ func RelayMidjourneyImage(c *gin.Context) {
|
||||
if httpClient == nil {
|
||||
httpClient = service.GetHttpClient()
|
||||
}
|
||||
fetchSetting := system_setting.GetFetchSetting()
|
||||
if err := common.ValidateURLWithFetchSetting(midjourneyTask.ImageUrl, fetchSetting.EnableSSRFProtection, fetchSetting.AllowPrivateIp, fetchSetting.DomainFilterMode, fetchSetting.IpFilterMode, fetchSetting.DomainList, fetchSetting.IpList, fetchSetting.AllowedPorts, fetchSetting.ApplyIPFilterForDomain); err != nil {
|
||||
c.JSON(http.StatusForbidden, gin.H{
|
||||
"error": fmt.Sprintf("request blocked: %v", err),
|
||||
})
|
||||
return
|
||||
}
|
||||
resp, err := httpClient.Get(midjourneyTask.ImageUrl)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
|
||||
Reference in New Issue
Block a user