Ash授权绕过漏洞分析:CVE-2025-48044
漏洞概述
高严重性漏洞 - CVSS评分8.6
Ash框架在绕过策略条件评估为真但授权检查失败时存在授权绕过漏洞,导致资源可以在没有适当授权的情况下被访问。
受影响版本
- 受影响版本:>= 3.6.3, <= 3.7.0
- 已修复版本:3.7.1
漏洞详情
漏洞原理
当满足以下条件时,资源可以在没有适当授权的情况下被访问:
- 绕过条件评估为true
- 绕过授权检查失败
- 存在其他策略但其条件不匹配
问题代码
位于 lib/ash/policy/policy.ex:69 的漏洞代码:
1
2
3
4
5
|
{%{bypass?: true}, cond_expr, complete_expr}, {one_condition_matches, all_policies_match} ->
{
b(cond_expr or one_condition_matches), # <- 漏洞:仅使用条件
b(complete_expr or all_policies_match)
}
|
授权决策逻辑
最终授权决策为:one_condition_matches AND all_policies_match
当绕过条件为true但绕过策略失败,且后续策略具有不匹配的条件时:
one_condition_matches = cond_expr(绕过条件)= true(漏洞 - 应检查绕过是否实际授权)
all_policies_match = (complete_expr OR NOT cond_expr) 对于每个策略
对于不匹配的策略:(false OR NOT false) = true(策略不适用)
最终结果:true AND true = true(错误授权)
修复方案
将第69行的 cond_expr 替换为 complete_expr:
1
2
3
4
5
|
{%{bypass?: true}, _cond_expr, complete_expr}, {one_condition_matches, all_policies_match} ->
{
b(complete_expr or one_condition_matches), # <- 已修复
b(complete_expr or all_policies_match)
}
|
为保持一致性,第52行也应更新:
1
2
3
4
5
|
{%{bypass?: true}, _cond_expr, complete_expr}, {one_condition_matches, true} ->
{
b(complete_expr or one_condition_matches), # <- 为保持一致性
complete_expr
}
|
漏洞验证
策略配置示例
1
2
3
4
5
6
7
8
9
|
policies do
bypass always() do
authorize_if actor_attribute_equals(:is_admin, true)
end
policy action_type(:read) do
authorize_if always()
end
end
|
非管理员用户可以执行创建操作(本应被拒绝)。
测试用例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
test "bypass policy bug" do
policies = [
%Ash.Policy.Policy{
bypass?: true,
condition: [{Ash.Policy.Check.Static, result: true}], # 条件 = true
policies: [
%Ash.Policy.Check{
type: :authorize_if,
check: {Ash.Policy.Check.Static, result: false}, # 策略 = false
check_module: Ash.Policy.Check.Static,
check_opts: [result: false]
}
]
},
%Ash.Policy.Policy{
bypass?: false,
condition: [{Ash.Policy.Check.Static, result: false}],
policies: [
%Ash.Policy.Check{
type: :authorize_if,
check: {Ash.Policy.Check.Static, result: true},
check_module: Ash.Policy.Check.Static,
check_opts: [result: true]
}
]
}
]
expression = Ash.Policy.Policy.expression(policies, %{})
assert expression == false
# 期望:false(拒绝)
# 主分支实际结果:true(错误授权)
end
|
参考信息
CVSS v4基础指标
可利用性指标:
- 攻击向量:网络
- 攻击复杂度:低
- 攻击要求:无
- 所需权限:低
- 用户交互:无
脆弱系统影响指标: