Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/plugins/system/meta/HTMLMetaHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ function merge(parentObj, props, value) {
return;
}

// Prototype pollution guard: never let attacker-controlled meta tag names
// (e.g. <meta property="__proto__:NODE_OPTIONS">) write into Object.prototype.
if (props.some(function(p) { return p === '__proto__' || p === 'constructor' || p === 'prototype'; })) {
return;
}

var currentNodeName = props[props.length - 1];

// Add 'url' to 'og:video'. And other same cases.
Expand Down
9 changes: 9 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,15 @@ export function unifyDate(date) {

export function lowerCaseKeys(obj) {
for (var k in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, k)) {
// Skip inherited keys (e.g. from an already polluted prototype).
continue;
}
// Prototype pollution guard: never copy dangerous keys coming from
// attacker-controlled JSON (e.g. oembed `{"__proto__":{...}}`).
if (k === '__proto__' || k === 'constructor' || k === 'prototype') {
continue;
}
var lowerCaseKey = k.toLowerCase();
if (lowerCaseKey != k) {
obj[lowerCaseKey] = obj[k];
Expand Down
Loading