Tiptap: mergeAttributes() turns an own __proto__ key into inherited executable DOM attributes
影響パッケージ
| パッケージ | 影響を受ける版 → 修正版 | |
|---|---|---|
| ueberdosistiptap |
2.0.0-alpha.0 以上 3.30.4 未満→ 3.30.4 |
3.30.4 |
| npm@tiptap/core |
2.0.0-alpha.0 以上 2.27.3 未満→ 2.27.3 |
2.27.3 |
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。
Summary
@tiptap/core's public mergeAttributes() helper uses ordinary bracket assignment on keys returned by Object.entries(). An own __proto__ key from JSON therefore invokes the legacy prototype setter on the fresh merged object. The function returns an object whose prototype is attacker-controlled, while Object.keys() and ordinary own-property checks show no attacker attributes.
When that result is used as a ProseMirror DOMOutputSpec attribute object, prosemirror-model's DOMSerializer.renderSpec() enumerates it with for...in and applies inherited values with setAttribute(). In a browser proof, inherited src and onerror values were copied to an `` and the error handler executed once. This is per-object prototype manipulation; the proof does not modify global Object.prototype.
Root cause
The affected loop is conceptually:
const mergedAttributes = { ...items }
for (const [key, value] of Object.entries(item)) {
const exists = mergedAttributes[key]
// ...
mergedAttributes[key] = value
}
Object.entries(JSON.parse('{"__proto__": {...}}')) includes __proto__. Reading mergedAttributes['__proto__'] resolves the inherited Object.prototype; assigning to the same key invokes Object.prototype.__proto__'s setter and replaces mergedAttributes' prototype.
Browser reproduction
The following shape was tested with exact @tiptap/core 3.29.2 and prosemirror-model 1.25.11:
const input = JSON.parse(`{
"__proto__": {…
出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
参照URL
- advisory github.com
- package github.com
- web github.com
- web github.com
- web github.com
- web vulncheck.com
- web nvd.nist.gov
- web github.com
- web github.com
- web github.com