GitHub检测到敏感信息处理方案

存个报错的解决方案,之前没遇到过

问题原因

用元宝的时候直接将元宝给我的图片链接插到了文章里,没有注意到元宝给你的图片链接是会带着你的腾讯云Secret ID,所以git报错了

报错内容如下,同时我在删除源文件后也就是2025/09/05/百度网盘7.59 Windows客户端命令注入漏洞/index.html这个文件后还是报错,那大概率就是git自己的缓存依旧存在,所以需要清除缓存重新生成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
remote: Resolving deltas: 100% (61/61), completed with 24 local objects.
remote: error: GH013: Repository rule violations found for refs/heads/main.
remote:
remote: - GITHUB PUSH PROTECTION
remote: —————————————————————————————————————————
remote: Resolve the following violations before pushing again
remote:
remote: - Push cannot contain secrets
remote:
remote:
remote: (?) Learn how to resolve a blocked push
remote: https://docs.github.com/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#resolving-a-blocked-push
remote:
remote:
remote: —— Tencent Cloud Secret ID ———————————————————————————
remote: locations:
remote: - commit: 105a8fc43f4e05ebfdf83c1263a0ed44f226bc3e
remote: path: 2025/09/05/百度网盘7.59 Windows客户端命令注入漏洞/index.html:32
remote: - commit: 105a8fc43f4e05ebfdf83c1263a0ed44f226bc3e
remote: path: 2025/09/05/百度网盘7.59 Windows客户端命令注入漏洞/index.html:34
remote: - commit: 105a8fc43f4e05ebfdf83c1263a0ed44f226bc3e
remote: path: 2025/09/05/百度网盘7.59 Windows客户端命令注入漏洞/index.html:303
remote: - commit: 105a8fc43f4e05ebfdf83c1263a0ed44f226bc3e
remote: path: 2025/09/05/百度网盘7.59 Windows客户端命令注入漏洞/index.html:322
remote: - commit: 105a8fc43f4e05ebfdf83c1263a0ed44f226bc3e
remote: path: local-search.xml:11
remote:
remote: (?) To push, remove secret from commit(s) or follow this URL to allow the secret.
remote: https://github.com/t0pbarry/t0pbarry.github.io/security/secret-scanning/unblock-secret/32HuSRm4czIzDbv1DCmPZqLBsKK
remote:
remote:
remote:
To https://github.com/t0pbarry/t0pbarry.github.io.git
! [remote rejected] HEAD -> main (push declined due to repository rule violations)
error: failed to push some refs to 'https://github.com/t0pbarry/t0pbarry.github.io.git'
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (/Users/winter/Desktop/MyArticle/hexo/hexo-blog/node_modules/hexo-deployer-git/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:507:28)
at ChildProcess._handle.onexit (node:internal/child_process:294:12)

解决方案

根据您提供的Hexo部署日志和GitHub推送错误,问题核心在于 生成的静态文件(index.htmllocal-search.xml)中包含硬编码的腾讯云Secret ID,触发GitHub推送保护机制。以下是完整解决方案:


🔍 问题根源

  1. 敏感信息泄露点
    GitHub检测到以下文件中存在腾讯云Secret ID:

    1
    2
    3
    - /2025/09/05/百度网盘7.59 Windows客户端命令注入漏洞/index.html
    → 第3234303322
    - /local-search.xml → 第11
  2. 信息泄露路径

    文件类型 生成来源 敏感信息位置
    index.html Hexo编译Markdown文章生成 文章代码片段
    local-search.xml hexo-generator-search插件生成 文章内容索引

🛠️ 修复方案

✅ 步骤1:定位并清除敏感信息

1
2
3
4
5
6
7
8
9
10
11
12
# 1. 定位包含Secret ID的源文件
grep -r "AKID" ./source/_posts/

# 2. 编辑漏洞文章Markdown文件
# 文件路径:source/_posts/百度网盘7.59 Windows客户端命令注入漏洞.md
# 删除以下行中的腾讯云Secret ID:
# - 第32行附近:POC请求示例
# - 第34行附近:XML代码块
# - 第303/322行附近:复现步骤

# 3. 验证清理结果
grep "AKID" ./source/_posts/*.md # 应无输出

✅ 步骤2:重置Hexo生成缓存

1
2
3
4
5
6
7
8
# 清除旧编译文件
hexo clean

# 重新生成静态文件(确保无敏感信息)
hexo generate

# 检查生成文件
grep "AKID" ./public/**/*.html ./public/*.xml # 应无输出

✅ 步骤3:安全部署

1
2
3
# 强制更新部署仓库
rm -rf .deploy_git # 删除旧部署缓存
hexo deploy # 执行到这里已经一切正常了

⚠️ 密钥管理强化

  1. 立即重置泄露密钥
    登录腾讯云控制台 → 访问密钥 → 禁用/删除泄露的Secret ID。

  2. 预防硬编码
    在Markdown中使用​​环境变量占位符​​:

    1
    2
    3
    4
    5
    6
    ```xml
    <!-- 错误方式 -->
    <secret_id>AKID[直接跟ID]</secret_id>

    <!-- 正确方式 -->
    <secret_id>{{ env.TENCENT_SECRET_ID }}</secret_id>
    1
    通过Hexo[环境变量插件](https://github.com/hexojs/hexo-inject-env)动态注入。
  3. 提交前扫描
    安装预提交检测:

    1
    2
    3
    4
    5
    6
    # 安装GitLeaks
    brew install gitleaks

    # 添加预提交钩子
    echo 'gitleaks protect --staged -v' > .git/hooks/pre-commit
    chmod +x .git/hooks/pre-commit

GitHub检测到敏感信息处理方案
http://example.com/2025/09/05/GitHub检测到敏感信息/
作者
Winter
发布于
2025年9月5日
许可协议