Prototype pollution in emit function
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- —
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub.
Summary
### Summary A prototype pollution in derby can crash the application, if the application author has atypical HTML templates that feed user input into an object key. Attribute keys are almost always developer-controlled, not end-user-controlled, so this shouldn't be an issue in practice for most applications. ### Details ``` emit(context: Context, target: T) { const node = traverseAndCreate(context.controller, this.segments); node[this.lastSegment] = target; this.addListeners(target, node, this.lastSegment); } ``` The emit() function in src/templates/templates.ts is called without sanitizing the variable `this.lastSegment `. The variable `this.lastSegment ` can be set to `__proto__`, and this will pollute the prototype of Javascipt Object (`node['__proto__'] = target`). ### PoC To reproduce this vulnerability, you can adjust the test case `ignores DOM mutations in components\' create()` in `test/dom/ComponentHarness.mocha.js`. ``` it('ignores DOM mutations in components\' create()', function() { function Box() {} Box.view = { is: 'box', - source: '<index:><div class="box" as="boxElement"></div>' + source: '<index:><div class="box" as="__proto__"></div>' }; Box.prototype.create = function() { this.boxElement.className = 'box-changed-in-create'; }; var harness = runner.createHarness('<view is="box" />', Box); expect(harness).to.render('<div class="box"></div>'); }); ``` When `as` attribute is controlled by attackers, the variable in `this.lastSegment` will exactly take value` __proto__` and prototype pollution happens. ### Patch Add a check on `this.lastSegment` can prevent this attack. ``` emit(context: Context, target: T) { const node = traverseAndCreate(context.controller, this.segments); + if (this.lastSegment.includes('__proto__') || this.lastSegment.includes('prototype')) { + throw new Error('Unsafe code detected'); + } node[this.lastSegment] = target; this.addListeners(target, node, this.lastSegment); } ```
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | derby (npm) | before 2.3.2 | 2.3.2 | Patch available | GHSA-82jv-9wjw-pqh6 |
| — | derby (npm) | 3.0.0 to before 3.0.2 | 3.0.2 | Patch available | GHSA-82jv-9wjw-pqh6 |
| — | derby (npm) | 4.0.0-beta1 to before 4.0.0-beta.11 | 4.0.0-beta.11 | Patch available | GHSA-82jv-9wjw-pqh6 |
- derby (npm) Vendor— Affected before 2.3.2 Fixed in 2.3.2 Patch available GHSA-82jv-9wjw-pqh6
- derby (npm) Vendor— Affected 3.0.0 to before 3.0.2 Fixed in 3.0.2 Patch available GHSA-82jv-9wjw-pqh6
- derby (npm) Vendor— Affected 4.0.0-beta1 to before 4.0.0-beta.11 Fixed in 4.0.0-beta.11 Patch available GHSA-82jv-9wjw-pqh6
Remediation
- Fix · GHSA-82jv-9wjw-pqh6 derby (npm) Fixed in 2.3.2 Advisory →
- Fix · GHSA-82jv-9wjw-pqh6 derby (npm) Fixed in 3.0.2 Advisory →
- Fix · GHSA-82jv-9wjw-pqh6 derby (npm) Fixed in 4.0.0-beta.11 Advisory →
Timeline
- 2026-10-03 Threatist record created from GHSA-82jv-9wjw-pqh6
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences