Secure development

Developing browser extensions with safe permissions and messaging

Browser origins: browser, code, gate arranged to illustrate developing browser extensions with safe permissions and messaging.

Developing browser extensions with safe permissions and messaging connects a security requirement to the behaviour of a real feature. The relevant controls need to remain effective across custom code, integrations and the production configuration. Understanding developing browser extensions with safe permissions and messaging helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Authorisation determines which resources and operations an established identity may use. It must be enforced where protected data is read or changed. User interface restrictions, obscure identifiers and documentation can help usability, but they do not replace the service's own permission decision.

Browser extensions sometimes request more permissions than they actually need. This can grant them access to all tabs, browsing history, and even sensitive user data. If an extension is compromised, it could lead to serious privacy risks.

Follow the Principle of Least Privilege (PoLP) and request only the permissions that are absolutely necessary. Use optional permissions whenever possible instead of granting full access upfront. Regularly audit and remove any permissions that are no longer needed. In Manifest V3, declare URL access separately in host_permissions or optional_host_permissions.

Why it matters

Consider a realistic failure: a browser extension requests broad host access and trusts messages from unintended pages.

A missing check can expose another account's information or let an ordinary user perform a privileged action. The result should be described by the actual records and operations reached, including whether access crosses a customer or organisational boundary.

Implementation guidance should be applied to a real feature and its deployment. Framework defaults, custom handlers and integrated services all influence whether the intended protection remains effective.

How penetration testers check for it

Trace the relevant feature from its entry point to the data or operation it protects, including custom code and alternate paths.

  • Compare users with different roles and ownership relationships.
  • Exercise read, change, delete and alternate access paths.
  • Test nested resources, background processing and state changes.
  • Confirm rejection as well as the legitimate successful journey.

How to fix it

Use the appropriate maintained mechanisms and verify the result in the actual production configuration.

  • Configure content_security_policy.extension_pages in manifest.json and load scripts from the extension package. Do not apply ordinary webpage nonce or hash recommendations to Chrome Manifest V3 extension pages: their allowed script sources are restricted. Keep inline script execution blocked and restrict other resource types to those the extension needs.
  • Options Page: Use a dedicated options page for displaying user-specific data or settings.
  • Side Panel: Use the side panel to show a persistent UI in a separate pane, isolated from the page content. (FYI, "Side Panel" is a Chromium term. Firefox calls it "Sidebar".).
  • Validate sender.id to ensure the message originates from your own extension.
  • Enforce permission checks at each protected operation.
  • Maintain regression cases for unauthorised users and changed permissions.

A successful response alone does not prove unauthorised access. Establish whose resource was affected and what the caller was legitimately entitled to do.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss secure development and code review.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo