版本比较
cy3's site todos
正文
增加 62 行删除 8 行
11233455678791091112111314151617181319201521222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869网址:[chenyuan33.github.io](chenyuan33.github.io)。网址:[chenyuan33.github.io](https://chenyuan33.github.io/)。私信/回复/Issue 等均可提建议/bug。
私信/回复/Issue 等均可提建议。:::error[cy3's site]
已完成:- 个性化/自定义/设置:主题颜色配置、跟随系统主题、高对比度主题、自定义侧边栏、自定义语言- 快捷键- [Quarks 问题](https://www.luogu.com.cn/chat?uid=1145260):东西太多内存会炸,获取最大时间复杂度 $O(n)$,`ConvertQuark` 没有检验,存档可被篡改
- [x] 侧边栏(@[chenyuan3](/user/559528),$2025/10/14$):::
处理中::::error[[note.ms 链接](https://note.ms/DDDEEEBUG) / [来自](https://www.luogu.com.cn/chat?uid=1145260)]
- [ ] Markdown 编辑器(@[chenyuan3](/user/559528),$2025/10/14$)> - [x] V-01 `mdeditor`、`mdToHtml`、`inlineMdToHtml` 考虑增加 [安全模式] / [Safe Mode] 默认开启,此时使用 `DOMPurify.sanitize` 过滤输出或返回的 HTML。> - [ ] V-02 需要添加 browser-update 的 `integrity`;需要添加 FontAwesome 的 CORS> - [ ] V-03 将 `/helper.js` 的 `addMessage` 和 `/jstools/` 下的函数添加参数表示禁用所有 HTML、启用部分 HTML(使用 `DOMPurify.sanitize` 过滤)、启用所有 HTML,其中启用所有 HTML 可能不会实施;名称等不使用 `innerHTML` 直接修改> - [ ] V-04 限制存档字符串大小、JSON 深度和数组长度;将各维度获取器数量、维度数量限制,未来可采用“仅通过各维度获取器数量”进行获取;导入前做 schema 校验;自动保存降频> - [x] V-05 不考虑(~~也许我只是不小心当那天是愚人节了呢~~)
待处理:内容相对于[此 commit](https://github.com/chenyuan33/chenyuan33.github.io/tree/f7fc0ad6f155e5eacc461c16e73c8c2e39d15a5a)。
- [ ] Issue 请求添加友情链接(@[chenyuan3](/user/559528),$2025/10/14$)**V-01 Markdown 编辑器 DOM XSS**
位置:[jstools/md.js (line 154)](D:/纠漏洞/chenyuan33.github.io/jstools/md.js:154)、[jstools/md.js (line 542)](D:/纠漏洞/chenyuan33.github.io/jstools/md.js:542)、[tool/mdeditor.html (line 13)](D:/纠漏洞/chenyuan33.github.io/tool/mdeditor.html:13)
`mdtohtml()` 只在代码块分支转义 `<` / `>`,普通 Markdown 文本会原样拼进 HTML,随后通过 `innerHTML` 渲染。PoC:在 `/tool/mdeditor.html` 输入:
```<img src=x onerror=alert(document.domain)>```
影响:任意脚本可在 `chenyuan33.github.io` 同源上下文执行,读取/篡改 `localStorage` 中的语言、主题、游戏存档等前端数据,并可做页面钓鱼或篡改展示。
建议:使用成熟 Markdown 渲染器并接入 `DOMPurify.sanitize()`;如果只是展示 HTML 源码,使用 `textContent`;若必须允许部分 HTML,采用白名单策略。
**V-02 第三方脚本供应链风险**
位置:[helper.js (line 5)](D:/纠漏洞/chenyuan33.github.io/helper.js:5)、[helper.js (line 195)](D:/纠漏洞/chenyuan33.github.io/helper.js:195)、[helper.js (line 228)](D:/纠漏洞/chenyuan33.github.io/helper.js:228)、[game/quarks/index.html (line 7)](D:/纠漏洞/chenyuan33.github.io/game/quarks/index.html:7)
站点加载 FontAwesome Kit、giscus、browser-update、cdnjs BigNumber/MathJax 等第三方资源,但未配置 `integrity`。其中 `//browser-update.org/update.min.js` 还使用协议相对 URL。
影响:任一第三方脚本源被劫持或返回恶意 JS,都会获得本站前端执行权限。协议相对 URL 在非 HTTPS 环境下还有降级风险。
建议:固定版本、使用 `https://`、增加 SRI;能自托管的静态依赖尽量自托管;删除不必要的动态第三方脚本;配合 CSP 限制 `script-src`。
**V-03 通用 HTML 注入 sink 设计不安全**
位置:[helper.js (line 52)](D:/纠漏洞/chenyuan33.github.io/helper.js:52)、[helper.js (line 83)](D:/纠漏洞/chenyuan33.github.io/helper.js:83)、[jstools/dialog.js (line 19)](D:/纠漏洞/chenyuan33.github.io/jstools/dialog.js:19)、[jstools/dialog.js (line 28)](D:/纠漏洞/chenyuan33.github.io/jstools/dialog.js:28)、[jstools/contentTabs.js (line 7)](D:/纠漏洞/chenyuan33.github.io/jstools/contentTabs.js:7)
`addMessage()`、`createDialog()`、`contentTabs()` 默认把传入内容当 HTML 拼接。当前多数调用是静态/i18n 内容,但这是高风险 API 形态,后续只要接入用户输入就会直接变成 XSS。Markdown 编辑器的漏洞就是同类模式的实例。
建议:默认用 `textContent`;需要 HTML 的地方显式命名为 `unsafeHtml` 并统一消毒;按钮文案、tab 名称等不要走 `innerHTML`。
**V-04 游戏存档导入前端 DoS**
位置:[game/quarks/main.js (line 28)](D:/纠漏洞/chenyuan33.github.io/game/quarks/main.js:28)、[game/quarks/main.js (line 57)](D:/纠漏洞/chenyuan33.github.io/game/quarks/main.js:57)、[game/quarks/main.js (line 89)](D:/纠漏洞/chenyuan33.github.io/game/quarks/main.js:89)、[game/quarks/main.js (line 467)](D:/纠漏洞/chenyuan33.github.io/game/quarks/main.js:467)
`updateData()` 对用户粘贴的 base64 JSON 做递归转换,缺少长度、深度、数组规模限制,并且每 50ms 写一次 `localStorage`。恶意超大/深层存档可导致页面卡死、内存膨胀或频繁存储写入。
建议:限制存档字符串大小、JSON 深度和数组长度;导入前做 schema 校验;自动保存降频或按变更节流。
**V-05 历史 Git 暴露风险**
位置:历史提交 `cbb8d677` 中的 `admin/blog.html:59-60`、`admin/admin.js:9-15`
Git 历史里曾存在 `/admin` 管理页,浏览器中输入 GitHub Token 后直接调用 GitHub Contents API。未发现硬编码 Token,但这种管理方式不应出现在公开 Pages 仓库历史里。
建议:确认过去是否使用过真实 PAT;如果使用过,立即轮换;以后用 GitHub Actions、受控后台或 OAuth,不把管理工具放入公开静态站历史。
:::