Ash Authentication令牌撤销逻辑漏洞分析与修复指南

本文详细分析Ash Authentication v4.1.0至v4.4.8版本中令牌撤销检查逻辑的漏洞,该漏洞导致已撤销的令牌在过期前仍可重复使用,影响魔法链接、密码重置等功能的安全机制。

CVE-2025-25202:Ash Authentication令牌撤销检查逻辑漏洞

漏洞概述

Ash Authentication在通过mix ash_authentication.install生成的操作中存在有缺陷的令牌撤销检查逻辑。该漏洞影响使用新安装程序(自AshAuthentication v4.1.0起)引导的应用程序。

影响范围

受影响版本

  • Erlang包:ash_authentication
  • 受影响版本:>= 4.1.0, < 4.4.9
  • 已修复版本:4.4.9

受影响功能

  • 魔法链接策略:魔法链接令牌在过期前可重复使用(默认有效期为10分钟)
  • 密码策略中的密码重置:密码重置令牌在过期前可重复使用(默认有效期为3天)
  • 确认附加组件:确认令牌在过期前可重复使用(默认有效期为3天)

技术细节

漏洞根源

在生成的令牌资源中,:revoked?通用操作的:jti:token选项未允许nil值,且未正确返回:boolean类型。这导致已撤销的令牌在被验证时仍被视为有效。

修复方案

版本4.4.9已修复此漏洞,并提供了编译时警告和升级器。

自动修复

1
mix igniter.upgrade ash_authentication

或手动运行升级器:

1
mix ash_authentication.upgrade 4.4.8 4.4.9

手动修复

修改:revoked?操作如下:

1
2
3
4
5
6
7
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

临时解决方案

  1. 删除生成的令牌资源中的:revoked?通用操作,系统将使用AshAuthentication内部正确的实现
  2. 按照上述说明手动修改操作定义

安全指标

  • 严重程度:中等
  • CVSS评分:6.3
  • 弱点类型:CWE-269 权限管理不当

参考信息

  • GitHub Advisory: GHSA-qrm9-f75w-hg4c
  • 修复提交:team-alembic/ash_authentication@2dee552
  • NVD详情:https://nvd.nist.gov/vuln/detail/CVE-2025-25202
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计