mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(HTTP Request Node): Fix prototype pollution vulnerability (#15463)
This commit is contained in:
@@ -7,7 +7,7 @@ import type {
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
import { isSafeObjectProperty, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
import { getGoogleAccessToken } from '../../GenericFunctions';
|
||||
|
||||
@@ -82,8 +82,6 @@ export async function googleApiRequestAllItems(
|
||||
const isValidDate = (str: string) =>
|
||||
moment(str, ['YYYY-MM-DD HH:mm:ss Z', moment.ISO_8601], true).isValid();
|
||||
|
||||
const protoKeys = ['__proto__', 'prototype', 'constructor'];
|
||||
|
||||
// Both functions below were taken from Stack Overflow jsonToDocument was fixed as it was unable to handle null values correctly
|
||||
// https://stackoverflow.com/questions/62246410/how-to-convert-a-firestore-document-to-plain-json-and-vice-versa
|
||||
// Great thanks to https://stackoverflow.com/users/3915246/mahindar
|
||||
@@ -108,7 +106,7 @@ export function jsonToDocument(value: string | number | IDataObject | IDataObjec
|
||||
} else if (typeof value === 'object') {
|
||||
const obj: IDataObject = {};
|
||||
for (const key of Object.keys(value)) {
|
||||
if (value.hasOwnProperty(key) && !protoKeys.includes(key)) {
|
||||
if (value.hasOwnProperty(key) && isSafeObjectProperty(key)) {
|
||||
obj[key] = jsonToDocument((value as IDataObject)[key] as IDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import isPlainObject from 'lodash/isPlainObject';
|
||||
import set from 'lodash/set';
|
||||
import {
|
||||
deepCopy,
|
||||
setSafeObjectProperty,
|
||||
type ICredentialDataDecryptedObject,
|
||||
type IDataObject,
|
||||
type INodeExecutionData,
|
||||
@@ -48,7 +49,7 @@ function redact<T = unknown>(obj: T, secrets: string[]): T {
|
||||
return obj.map((item) => redact(item, secrets)) as T;
|
||||
} else if (isObject(obj)) {
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
(obj as IDataObject)[key] = redact(value, secrets);
|
||||
setSafeObjectProperty(obj, key, redact(value, secrets));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user