Ash Authentication 令牌撤销逻辑漏洞详解 (CVE-2025-25202)

本文详细描述了 Ash Authentication 库中一个影响令牌撤销检查逻辑的安全漏洞(CVE-2025-25202)。该漏洞导致已撤销的令牌在过期前仍可被验证为有效,影响了使用魔法链接、密码重置和确认功能的应用程序。

Ash Authentication 存在有缺陷的令牌撤销检查逻辑(CVE-2025-25202)

摘要

影响 使用新版 igniter 安装程序(自 AshAuthentication v4.1.0 起)引导的应用程序,并且使用了魔法链接策略、密码重置、确认功能或手动撤销令牌的应用程序会受到影响,即被撤销的令牌仍被允许验证为有效。如果您没有使用新的安装程序,则绝对不受影响。此外,除非您在应用程序中实现了任何类型的自定义令牌撤销功能(在这种情况下,即使是粗略的测试也会发现此问题),否则您不会受到显著影响。对用户的影响如下:

  • 对于使用魔法链接策略的用户,魔法链接令牌在过期之前可以被重复使用,而不是立即被撤销。默认情况下,魔法链接令牌的有效期为 10 分钟。
  • 对于使用密码策略中的密码重置功能的用户,密码重置令牌在过期之前可以被重复使用,而不是立即被撤销。默认情况下,密码重置令牌的有效期为 3 天。
  • 对于使用确认插件的用户,确认令牌在过期之前可以被重复使用,而不是立即被撤销。默认情况下,密码重置令牌的有效期为 3 天。

补丁 该缺陷已在 4.4.9 版本中修复。此外,如果用户升级,会显示编译时警告并提供修复说明。4.4.9 版本附带了一个升级器,因此如果您使用 mix igniter.upgrade ash_authentication,所需的补丁将自动为您应用。否则,您可以按照错误消息中的描述手动运行升级器。

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[warning] Warning while compiling Tunez.Accounts.Token:

The `:jti` and `:token` options to the `:revoked?` action must allow nil values and it must return a `:boolean`.

This was an error in our igniter installer previous to version 4.4.9, which allowed revoked tokens to be reused.

To fix this, run the following command in your shell:

    mix ash_authentication.upgrade 4.4.8 4.4.9

Or:

  - remove `allow_nil?: false` from these action arguments, and
  - ensure that the action returns `:boolean`.

  like so:

    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

解决方法 删除令牌资源中生成的 :revoked? 通用操作。这将导致其使用 AshAuthentication 内部的操作,该操作一直是正确的。或者,手动进行上述更改。

参考 请参阅 Ash Discord 上的 #ash_authentication 频道。

参考

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计