-
Notifications
You must be signed in to change notification settings - Fork 0
Product route: PUT replaces entire object with unsanitized input #15
Copy link
Copy link
Open
Labels
Description
Severity: High
Category: Security
Description
In api/src/routes/product.ts (line 115), products[index] = req.body allows a client to inject arbitrary properties (prototype pollution risk) and also loses the original productId if the client omits it.
// Current — wholesale replacement
products[index] = req.body;Suggested Fix
Merge explicitly and preserve the ID:
products[index] = { ...req.body, productId: products[index].productId };Or better yet, whitelist allowed fields:
const { name, description, price, supplierId, stockLevel, imgName } = req.body;
products[index] = { ...products[index], name, description, price, supplierId, stockLevel, imgName };Affected File
api/src/routes/product.ts(line 115)
Reactions are currently unavailable