Files
Sec-Interview/Chapter2/2-11.md
T
2026-01-02 01:48:18 +08:00

27 lines
1.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### 黑名单拦截了所有常见标签和事件,但页面仍然需要支持富文本渲染,你会从哪些方向尝试突破?
1. 黑名单通常基于已知的威胁列表,但 HTML 标准在不断演进,总有漏网之鱼
**多媒体标签的嵌套属性**:除了 `video`,还有 `audio``track``embed`
**交互式元素**`details``summary` 标签
**SVG 内部的深层逻辑**SVG 不仅仅是图片,它是 XML
2. 如果富文本允许 `style` 标签或 `style` 属性,即使无法执行 JS,也能造成极高危害
**利用 `content` 与伪元素**:在某些特定环境下,CSS 甚至可以触发特定的交互行为或点击劫持
3. 富文本渲染往往伴随着前端框架(如 Vue、Angular、React
**双大括号语法**:如果后端直接把富文本内容丢进了前端模板的渲染区域,可以尝试注入模板指令
4. 黑名单通常使用正则匹配,而正则很难处理复杂的 HTML 解析状态
**利用畸形编码**:在支持富文本的编辑器(如 TinyMCE, CKEditor)中,测试其对 `\r``\n``\0` 的处理。有时编辑器会将这些字符过滤掉,但过滤后的字符串恰好拼凑成了恶意代码