CVE-2026-104844 PostCSS Selector Parser 拒绝服务漏洞
影响攻击者可构造恶意选择器导致解析线程阻塞,造成拒绝服务
PostCSS Selector Parser 是一个可与 PostCSS 集成但非必需的 CSS 选择器解析库。在 7.1.6 之前的版本中,src/parser.js 的 splitWord() 因未将句点和井号作为分词分隔符,可能把扁平选择器作为单个词元处理,从而携带大量 class 或 ID 索引。uniqs() 去重、逐索引的 class/ID 成员检查以及 Sass 插值过滤均对索引数组进行重复线性扫描,使解析复杂度随索引数量呈二次增长。
影响范围
PostCSS Selector Parser 7.1.6 之前的版本;具体受影响版本范围以官方公告为准,暂无更多公开信息。
漏洞详情
该漏洞属于算法复杂度问题(拒绝服务)。由于分词器未将 . 和 # 视为词边界,攻击者可构造包含大量 class/ID 索引的单个选择器词元,触发去重与成员检查的重复线性扫描,导致解析时间呈平方级增长。maxNestingDepth 防护无法缓解,因为恶意选择器可保持零嵌套深度。
利用条件与风险
利用前提是暴露的请求路径中同步解析不可信选择器;普通构建时解析可信源不受影响。实战中可造成同步解析线程被长时间占用,形成拒绝服务。
修复建议
升级至 7.1.6 或更高版本。临时缓解措施:避免在暴露的请求路径中同步解析不可信选择器,或对输入选择器的长度与索引数量进行限制;暂无其他公开缓解信息。
PostCSS Selector Parser is a CSS selector parser that integrates with PostCSS but does not require it. Prior to 7.1.6, src/parser.js splitWord() can receive a flat selector as one word token carrying many class or ID indexes because period and hash characters are not tokenizer word delimiters. The uniqs() deduplication and per-index class and ID membership checks repeatedly scan the class and ID index arrays, while a separate Sass-interpolation filtering pass also performs repeated linear scanning. Together, these passes make parsing quadratic in the number of indexes and allow a crafted selector to occupy a synchronous parser thread. The maxNestingDepth guard does not mitigate the issue because the hostile selector can have zero nesting depth. Only consumers that synchronously parse untrusted selectors in an exposed request path are affected; ordinary build-time parsing of trusted sources is not affected. This issue is fixed in version 7.1.6.