Skip to content

Security: Potential prototype pollution in settings merge - #1916

Open
tomaioo wants to merge 1 commit into
hypothesis:mainfrom
tomaioo:fix/security/potential-prototype-pollution-in-setting
Open

Security: Potential prototype pollution in settings merge#1916
tomaioo wants to merge 1 commit into
hypothesis:mainfrom
tomaioo:fix/security/potential-prototype-pollution-in-setting

Conversation

@tomaioo

@tomaioo tomaioo commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Security: Potential prototype pollution in settings merge

Problem

Severity: Low | File: src/background/settings.ts:L16

In src/background/settings.ts, the settings object is created using spread syntax with ...rawSettings. While this is generally safe, if rawSettings were ever to contain __proto__, constructor, or prototype keys (which could happen if the JSON file were tampered with), it could lead to prototype pollution. Additionally, the code imports raw JSON and spreads it directly. The replace operation on apiUrl also doesn't validate that apiUrl is actually a string before calling .replace().

Solution

Validate the structure and types of rawSettings before spreading. Use Object.create(null) for the base object or validate that no dangerous keys exist. Ensure apiUrl is a string before calling string methods on it.

Changes

  • src/background/settings.ts (modified)

In `src/background/settings.ts`, the settings object is created using spread syntax with `...rawSettings`. While this is generally safe, if `rawSettings` were ever to contain `__proto__`, `constructor`, or `prototype` keys (which could happen if the JSON file were tampered with), it could lead to prototype pollution. Additionally, the code imports raw JSON and spreads it directly. The `replace` operation on `apiUrl` also doesn't validate that `apiUrl` is actually a string before calling `.replace()`.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant