Skip to content

Mitigate security risk: content script access to chrome.storage.sync#62

Closed
NDevTK wants to merge 1 commit intomainfrom
mitigate-storage-security-1381566129880040394
Closed

Mitigate security risk: content script access to chrome.storage.sync#62
NDevTK wants to merge 1 commit intomainfrom
mitigate-storage-security-1381566129880040394

Conversation

@NDevTK
Copy link
Owner

@NDevTK NDevTK commented Jan 31, 2026

This PR mitigates a security risk where chrome.storage.sync was accessible to website content scripts, potentially allowing malicious sites to modify extension settings.

Changes:

  1. background.js:

    • Updated restore() to prioritize loading settings from chrome.storage.session (trusted runtime storage).
    • Removed the chrome.storage.onChanged listener for options and exclude keys, effectively ignoring direct storage writes from untrusted sources (content scripts).
    • Implemented a new updateOptions message handler that verifies the sender is a trusted extension page before updating state and storage.
    • Updated toggleOption to sync internal changes to chrome.storage.session.
  2. options.js:

    • Replaced direct chrome.storage.sync.set calls with a new sendUpdate function that sends updateOptions messages to the background script.

This architecture ensures that while chrome.storage.sync is still used for persistence and syncing, the authoritative runtime state is protected, and updates are validated.


PR created automatically by Jules for task 1381566129880040394 started by @NDevTK

- Background: Migrated runtime options authority to `chrome.storage.session` and internal state.
- Background: Removed `chrome.storage.onChanged` listener for options to prevent content script tampering.
- Background: Added `updateOptions` message handler to receive trusted updates from extension pages.
- Options: Updated options page to send `updateOptions` messages instead of writing directly to `chrome.storage.sync`.
- This ensures that only trusted extension pages can modify the extension's configuration.

Co-authored-by: NDevTK <31563761+NDevTK@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@NDevTK NDevTK closed this Jan 31, 2026
@NDevTK NDevTK deleted the mitigate-storage-security-1381566129880040394 branch January 31, 2026 13:37
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