深入解析CVE-2025-25202:Ash Authentication令牌撤销逻辑缺陷漏洞

本文详细分析了Ash Authentication身份验证库中的一个中危安全漏洞(CVE-2025-25202)。该漏洞导致通过特定安装器生成的令牌撤销检查逻辑存在缺陷,使得已撤销的魔术链接、密码重置等令牌在过期前仍可被误判为有效,影响了特定版本的应用程序安全。

漏洞概述

CVE-2025-25202是Ash Authentication身份验证库中存在的一个安全漏洞[citation:1]。Ash Authentication是一个用于Elixir应用程序的身份验证框架[citation:1]。

该漏洞的核心问题在于:通过 mix ash_authentication.install 命令(即新版igniter安装器)生成的 :revoked? 动作中,令牌撤销检查逻辑存在缺陷[citation:5][citation:6]。这导致一个严重的安全后果:已经被撤销的令牌在自然过期之前,仍然会被系统验证为有效,而不是立即失效[citation:5][citation:6]。

影响范围

受影响版本

  • Ash Authentication >= 4.1.0, < 4.4.9 的版本受此漏洞影响[citation:3][citation:5]。
  • 修复版本:4.4.9[citation:1][citation:3]。

受影响应用程序: 仅影响同时满足以下两个条件的应用程序[citation:5]:

  1. 自AshAuthentication v4.1.0起,使用了新的igniter安装程序进行引导。
  2. 使用了以下一项或多项功能:
    • 魔术链接策略(Magic Link Strategy)
    • 密码重置功能(属于密码策略)
    • 确认附加组件
    • 手动撤销令牌

如果未使用新的安装器,则完全不受此漏洞影响[citation:1][citation:6]。

具体影响分析

漏洞对使用不同功能的用户产生了具体影响[citation:5][citation:6]:

受影响功能 漏洞表现 默认令牌有效期
魔术链接策略 魔术链接令牌在过期前可被重复使用。 10分钟[citation:1]
密码重置功能 密码重置令牌在过期前可被重复使用。 3天[citation:5]
确认附加组件 确认令牌在过期前可被重复使用。 3天[citation:5]

修复方案与补丁

官方已发布补丁修复此漏洞[citation:1]。

1. 官方补丁升级 最直接的修复方式是将Ash Authentication升级到4.4.9或更高版本[citation:1][citation:3]。

  • 自动升级:升级后,可以运行 mix igniter.upgrade ash_authentication 命令,该升级工具会自动应用必要的补丁[citation:1][citation:6]。
  • 手动升级:也可以按照升级时编译器给出的警告信息,手动运行 mix ash_authentication.upgrade 4.4.8 4.4.9 命令来完成修复[citation:1][citation:5]。

2. 代码层面修复 修复需要对令牌资源中生成的 :revoked? 通用动作进行两处关键修改[citation:5][citation:6]:

  1. 移除 :jti:token 参数上的 allow_nil?: false 限制。
  2. 确保该动作返回类型为 :boolean

修复后的代码示例如下[citation:5]:

1
2
3
4
5
6
action :revoked?, :boolean do
  description "Returns true if a revocation token is found for the provided token"
  argument :token, :string, sensitive?: true
  argument :jti, :string, sensitive?: true
  run AshAuthentication.TokenResource.IsRevoked
end

临时解决方案

如果无法立即升级,可以采用以下临时解决方案[citation:1][citation:6]:

  • 删除生成的Action:在您的令牌资源中,直接删除自动生成的 :revoked? 通用动作。系统将回退使用AshAuthentication库内部自带的、始终正确的实现。
  • 手动修改代码:按照上述“代码层面修复”的要求,手动修改有缺陷的 :revoked? 动作代码。

漏洞评分与参考

  • CVSS总体评分:6.3(中危)[citation:6]。
  • CWE分类:CWE-269 - 权限管理不当[citation:6]。
  • GitHub安全公告:GHSA-qrm9-f75w-hg4c[citation:6]。
  • 修复提交记录team-alembic/ash_authentication@2dee552[citation:6]。
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计