From b0a3881725def023a477f8dfd012402e49da800f Mon Sep 17 00:00:00 2001 From: wait4xx Date: Mon, 2 Nov 2026 16:57:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(security):=20=E9=A1=B5=E9=9D=A2=E6=96=87?= =?UTF-8?q?=E6=A1=88=20markdown=20=E7=AE=A1=E7=BA=BF=E5=8A=A0=E6=A0=87?= =?UTF-8?q?=E7=AD=BE/=E5=B1=9E=E6=80=A7/=E5=8D=8F=E8=AE=AE=E5=87=80?= =?UTF-8?q?=E5=8C=96=EF=BC=88P0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 方案 10 §7.1 实锤漏洞:renderMarkdown() 用无参 createMarkdownProcessor, 默认 allowDangerousHtml + 无条件 rehype-raw,页面文案(about intro、开源页 叙述、README)的 raw HTML 直通 set:html——script/style/iframe/on* 全不剥。 - 新增 src/lib/rehype-content-sanitize.ts:标签白名单(不含 script/style/ iframe/object/form/link/meta/svg 等,危险标签整棵丢弃、未知标签解包保内容) + 属性白名单(a[href,title,rel]、img[src,alt,width,height,loading]、class/id) + 协议白名单(http/https/mailto + 站内相对 + 小图 data:) - site-content.ts 插件链与文章管线同序:rehypeRaw → 内容净化 → class 白名单 → 链接卡片(副作用为正:页面文案里的独立链接也会成 OG 卡片) - 修两处自身实现坑(实测驱动):hast 的 class 属性名是 className(按 class 过滤会把合法排版类一起剃掉);属性白名单需统一小写比较(驼峰 key 比不到) 验证: 注入载荷实测(