Skip to content

Commit 48e5e31

Browse files
Potential fix for code scanning alert no. 92: Prototype-polluting assignment (#1018)
Potential fix for [https://github.com/implerhq/impler.io/security/code-scanning/92](https://github.com/implerhq/impler.io/security/code-scanning/92) To fix the issue, we need to prevent the use of special keys like `__proto__`, `constructor`, and `prototype` in the `path` array. This can be achieved by validating each key in the `path` array before using it to navigate or modify the `obj` object. If any key matches one of these special values, the function should throw an error or ignore the operation. The best way to fix this is to add a validation step for `path` at the beginning of the `setValue` function. This ensures that no special keys are used, preventing prototype pollution. _Suggested fixes powered by Copilot Autofix. Review carefully before merging._
2 parents 649f80f + 31e42db commit 48e5e31

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

libs/services/src/rss-xml/rssxml.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ export class RSSXMLService {
498498
}
499499

500500
async setValue(obj: Record<string, any>, path: string[], value: any, attributes?: any): Promise<void> {
501+
// Validate path to prevent prototype pollution
502+
const forbiddenKeys = ['__proto__', 'constructor', 'prototype'];
503+
if (path.some(key => forbiddenKeys.includes(key))) {
504+
throw new Error('Invalid path: contains forbidden keys');
505+
}
506+
501507
let current = obj;
502508

503509
// Navigate to parent

0 commit comments

Comments
 (0)