fix: don't add content script entry to web_accessible_resources when no loader is emitted#1131
Open
Toumash wants to merge 1 commit intocrxjs:mainfrom
Open
fix: don't add content script entry to web_accessible_resources when no loader is emitted#1131Toumash wants to merge 1 commit intocrxjs:mainfrom
Toumash wants to merge 1 commit intocrxjs:mainfrom
Conversation
…no loader is emitted When a content script has no imports, exports, or dynamic imports, the plugin wraps it in an IIFE and lists it directly in content_scripts[].js. Chrome injects these scripts itself — they don't need to be fetched via chrome.runtime.getURL(), so listing them in web_accessible_resources is unnecessary and exposes them to web pages. Per Chrome docs: 'Content scripts themselves do not need to be allowed.' Only add the entry to web_accessible_resources when a loader was actually emitted (i.e. loaderName is set), since the loader uses chrome.runtime.getURL() to dynamically import the real entry. Closes crxjs#1130
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
web_accessible_resourceswhen no loader is emitted (i.e., scripts with no imports, exports, or dynamic imports)content_scripts[].jsand injected by Chrome itself — they don't needweb_accessible_resourcesand exposing them is a minor security concern (fingerprinting)What changed
plugin-webAccessibleResources.ts: Changed the condition at the WAR generation step to only add the entry file whenloaderNameis set on the content script (meaning a loader was actually emitted and useschrome.runtime.getURL()to fetch the entry):Scripts with a loader still work correctly — the loader uses
chrome.runtime.getURL()to dynamically import the real entry, so it must remain in WAR.Tests
mv3-content-script-no-war-entry) that builds a simple content script extension, loads it in Chromium, verifies the content script executes correctly, and asserts the entry is NOT inweb_accessible_resourcesCloses #1130