Skip to content

Commit 0b4112d

Browse files
authored
Merge pull request #102 from yubin-jee/devin/1772171680-fix-remote-property-injection-admin
fix: remediate js/remote-property-injection in src/routes/admin.js
2 parents a96605e + 5f272a2 commit 0b4112d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/routes/admin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ router.post('/import-config', (req, res) => {
5151
});
5252
});
5353

54-
// VULN: Prototype pollution via merge (CWE-1321)
54+
// Secure settings update with property injection prevention
55+
const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
56+
5557
router.post('/update-settings', (req, res) => {
5658
const userSettings = req.body;
57-
const settings = {};
59+
const settings = Object.create(null);
5860
Object.keys(userSettings).forEach(key => {
61+
if (DANGEROUS_KEYS.has(key)) {
62+
return; // skip dangerous property names to prevent prototype pollution
63+
}
5964
settings[key] = userSettings[key];
6065
});
6166
res.json({ settings });

0 commit comments

Comments
 (0)