Oxonomy

NextJS 超瓜皮漏洞,赶紧升级!

  •  
  •   Oxonomy · Mar 24, 2025 · 8362 views
    This topic created in 589 days ago, the information mentioned may be changed or developed.
    Downloading @next/[email protected]: 41.23 MB/41.23 MB, done
    
    dependencies:
    - next 15.1.0
    + next 15.2.3
    
    Done in 4m 38.6s
    

    NextJS auth middware 漏洞

    漏洞概述

    漏洞编号:CVE-2025-29927 / GHSA-f82v-jwr5-mffw 漏洞类型:授权绕过( CWE-285 ) 严重级别:严重( Critical ) CVSS 评分:9.1/10.0 影响版本:

    11.1.4 至 13.5.6 14.0 至 14.2.24 15.0 至 15.2.2

    漏洞简述

    此漏洞允许攻击者通过添加特定 HTTP 请求头( x-middleware-subrequest )完全绕过在 Next.js 中间件中实现的授权检查,从而获取对受保护资源的未授权访问。由于许多 Next.js 应用仅在中间件层实现授权逻辑,这使得该漏洞的影响范围极广且危害严重。

    虽然 Vercel 修了但是没有完全修,self host 的 nextjs 用户还是会遇到问题

    Cloudflare 和 Vercel CEO 直接推特中门互狙。。。

    Supplement 1  ·  Mar 25, 2025
    21 replies  •  2025-03-26 18:23:21 +08:00
    xavierchow
    xavierchow
    Mar 24, 2025
    1
    升级是一方面,另一方面也是个提醒,健壮的 app 应该避免只在一个 layer 做认证和安全保护
    https://strobes.co/blog/understanding-next-js-vulnerability/#Key_Security_Lessons_From_Nextjs_Vulnerability
    lizhenda
    lizhenda
    Mar 24, 2025
    2
    牛批啊 ...
    ragnaroks
    ragnaroks
    Mar 25, 2025❤️1
    3
    nextjs 的 middleware 设计真的文明用语,第一次见只能有一个 middleware 的框架
    flyqie
    flyqie
    Mar 25, 2025 via Android❤️2
    4
    cat
    cat
    Mar 25, 2025
    5
    @ragnaroks 而且是只为 edge runtime 设计的 middleware ,就离谱,github 上有几个 pr 和 discussions 吵这事
    guhuisec
    guhuisec
    Mar 25, 2025
    6
    吓死人
    NessajCN
    NessajCN
    Mar 25, 2025
    7
    看来我最初的预感是正确的
    最开始用 nextjs 我就觉得这 middleware 不靠谱
    最后还是把 auth 步骤都放到 layout 里
    麻烦是麻烦了点,每个 path 都要写一遍同样的 auth 逻辑,
    但把 cookie 都自己处理了就不必担心这种漏洞了
    qweruiop
    qweruiop
    Mar 25, 2025
    8
    twitter 都炸开了。。。也是醉了。。。
    Xheldon
    Xheldon
    Mar 25, 2025
    9
    没记错的话 middleware 中的 req/res 和别的接口 req/res 对象还有差异,我是懒得看文档了解什么差异了(毕竟 server 端的 req/res 和客户端的 req/res 也有差异我也懒得看。。。),然后鉴权写到单独的文件里面在各个接口都引了一遍。。。完美规避问题[doge]
    v1
    v1
    Mar 25, 2025
    10
    @ragnaroks 我倒是觉得这个设计很不错,模块化中间件,强制使用单个中间件文件,简化配置、防止潜在冲突、优化性能

    [官方文档]
    Note: While only one middleware.ts file is supported per project, you can still organize your middleware logic modularly. Break out middleware functionalities into separate .ts or .js files and import them into your main middleware.ts file. This allows for cleaner management of route-specific middleware, aggregated in the middleware.ts for centralized control. By enforcing a single middleware file, it simplifies configuration, prevents potential conflicts, and optimizes performance by avoiding multiple middleware layers.
    0x676e67
    0x676e67
    Mar 25, 2025
    11
    不如发推特链接看看
    lurenjiauser
    lurenjiauser
    Mar 25, 2025
    12
    这世界就是一个草台班子....
    Zenyet
    Zenyet
    Mar 25, 2025
    13
    @0x676e67 同,想吃瓜
    zealotxxxx
    zealotxxxx
    Mar 25, 2025
    14
    可以追溯到 3 年前的版本了。估计已经产生很多停在这些版本又不维护的项目。乐
    jimages
    jimages
    Mar 25, 2025
    15
    从来不用 middleware 鉴权,主要是不用的页面,有的需要鉴权,有的不需要鉴权,如果按不同页面写鉴权策略写到一个 middleware 逻辑太离散了,所以直接写到 page 里面了,都是每个页面都得粘贴一下有点麻烦。
    KellyAlsa
    KellyAlsa
    Mar 25, 2025
    17
    目前用 nextjs 写网站都只用 output: export 生成静态页面,应该遇不到这种问题
    shunia
    shunia
    Mar 25, 2025
    18
    23 号开始吵架,今天才开始道歉,哈哈哈哈
    kamilic
    kamilic
    Mar 25, 2025
    19
    @ragnaroks 确实傻逼,用到我吐血
    crackidz
    crackidz
    Mar 25, 2025
    20
    只写页面,解决问题=.=
    cccn
    cccn
    Mar 26, 2025
    21
    nextjs 真是越来越难用。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4952 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 66ms · UTC 07:55 · PVG 15:55 · LAX 23:55 · JFK 02:55
    ♥ Do have faith in what you're doing.