回跳白名单放行本机联调地址:完整 http(s) 回跳目标允许 Uri.IsLoopback(localhost/127.0.0.1/::1),本地页面调线上 docprint API 的登录链可回到本地页;外站 host 仍拒绝
build / build-push (push) Successful in 1m30s
build / build-push (push) Successful in 1m30s
This commit is contained in:
@@ -266,8 +266,10 @@ namespace YhCore.WebApi.Auth
|
||||
/// <summary>
|
||||
/// 判定回跳目标是否允许:
|
||||
/// 1. 本地相对路径(/xxx 开头):拒绝协议相对地址(//host)与反斜杠变体(/\…)——原有安全口径;
|
||||
/// 2. 完整 http(s) URL:host 必须与 service 根 host(AppBaseUrl 或当前请求)一致——供前端页完整
|
||||
/// 地址(yschreferer 携带,含 #/ 路由片段)作回跳目标,杜绝开放重定向到任意外站。
|
||||
/// 2. 完整 http(s) URL:host 须与 service 根 host(AppBaseUrl 或当前请求)一致,或为本机联调地址
|
||||
/// (localhost / 127.0.0.1 / ::1,Uri.IsLoopback)——前端页完整地址(yschreferer 携带,含 #/
|
||||
/// 路由片段)作回跳目标;放行本机地址以支持"本地页面调线上 docprint API"的联调登录链
|
||||
/// (redirectToReferer 解析后为 http://localhost:PORT/),外站 host 仍拒绝,杜绝开放重定向。
|
||||
/// 其余情况(null/空、非 http(s) 协议、外站 host)一律拒绝。
|
||||
/// 防御:含控制字符(0x00-0x1F / 0x7F)的目标一律拒绝——hex 解码产物(平台 char 维度 hex 对
|
||||
/// 非 ASCII 码点有损,可能还原出控制字符)或手工构造的畸形 URL,Uri 解析/302 Location 序列化
|
||||
@@ -300,7 +302,8 @@ namespace YhCore.WebApi.Auth
|
||||
return false;
|
||||
}
|
||||
return string.IsNullOrEmpty(allowedHost)
|
||||
|| string.Equals(uri.Host, allowedHost, StringComparison.OrdinalIgnoreCase);
|
||||
|| string.Equals(uri.Host, allowedHost, StringComparison.OrdinalIgnoreCase)
|
||||
|| uri.IsLoopback;
|
||||
}
|
||||
|
||||
/// <summary>service 根地址的 host(回跳白名单基准):AppBaseUrl 未配置时取当前请求 host。</summary>
|
||||
|
||||
Reference in New Issue
Block a user