Did anyone know about sandBoxing in chromeExtension??

276 views
Skip to first unread message

sakthi

unread,
Aug 18, 2023, 12:57:18 PM8/18/23
to Chromium Extensions
Hi there, So i need to import and use an external library for my extension.But Extension blocks the importing,now i cant normally use the library.To overcome this , i saw sandbox will help.But there's no proper explanation docs/video.If you find any doc , plzz share here.


Working:
I injected iframe (frame.html)in bottom of page when the user clicks the extension icon.In that iframe I have three buttons, when the user clicks the button , frame.js handles event for frame.html.I need to import d3 library in my frame.html.So that i can work with d3 in frame.js. But extension prevents importing a 3rd party library.

Jackie Han

unread,
Aug 19, 2023, 4:39:49 AM8/19/23
to sakthi, Chromium Extensions
Extension Manifest V3 doesn't allow embedding remotely hosted code.

1. preferred: usually, you should download the library code and bundle it in your extension.
For your use case, you can download https://d3js.org/d3.v7.min.js to use it offline.

2. alternative: if the code can't be used offline, you can try a sandbox page.
Although extension sandbox pages allow remote code, they have other restrictions that may cause other problems you don't expect.

Some CSP/sandbox references:


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/a5d85a7b-1ae1-47fd-9e54-ce08c732985dn%40chromium.org.

sakthi

unread,
Aug 21, 2023, 1:35:40 AM8/21/23
to Chromium Extensions, Jackie Han, Chromium Extensions, sakthi
Oh okk, But why handlebars used in sandbox page???  https://developer.chrome.com/docs/extensions/mv3/sandboxingEval/
Do we need to compile the code which uses 3rd party library in sandbox and then send back to extension scope??

Jackie Han

unread,
Aug 21, 2023, 1:55:41 AM8/21/23
to sakthi, Chromium Extensions
Oh okk, But why handlebars used in sandbox page???  https://developer.chrome.com/docs/extensions/mv3/sandboxingEval/

I never use handlebars. That article(and its title) talks about "eval()" , which is disabled in extension. So I guess that the library uses "eval()" internally.


Do we need to compile the code which uses 3rd party library in sandbox and then send back to extension scope?

See my previous comment. It has answered this question.

Suzette O'Donnell

unread,
Aug 21, 2023, 1:57:41 AM8/21/23
to Jackie Han, sakthi, Chromium Extensions


Sent from my Bell Samsung device over Canada’s largest network.

From: chromium-...@chromium.org <chromium-...@chromium.org> on behalf of Jackie Han <han.g...@gmail.com>
Sent: Sunday, August 20, 2023 11:55:12 PM
To: sakthi <sakthisab...@gmail.com>
Cc: Chromium Extensions <chromium-...@chromium.org>
Subject: Re: [crx] Did anyone know about sandBoxing in chromeExtension??
 

sakthi

unread,
Aug 21, 2023, 3:04:10 AM8/21/23
to Chromium Extensions, Jackie Han, Chromium Extensions, sakthi
Jjust now saw this post. https://developer.chrome.com/docs/extensions/migrating/improve-security/#remove-remote-code  It says remote codes are not allowed. So there is no way to include 3rd party library , even if i try sandbox logic?

Jackie Han

unread,
Aug 21, 2023, 7:59:51 AM8/21/23
to sakthi, Chromium Extensions
My first reply answered your question. It looks like you don't fully understand. I suggest you read it again, including the reference links.
If you encounter any problems, please attach your detailed code and error.

piyush gupta

unread,
Aug 21, 2023, 1:48:58 PM8/21/23
to Chromium Extensions, Jackie Han, Chromium Extensions, sakthi
Not the expert here, but because I'm also trying to run some code in sandbox, have some thoughts.
Sakthi, it would great help if you can post the code(manifest, sandbox html, the failing script) you're trying to run, you can also post the link to your github repo.

Ques:
1. What happens when you try to fetch the d3.js file from sandbox, what's the error ?
2. Why can't you just bundle d3.js with your extension like Jackie suggested, ?
Reply all
Reply to author
Forward
0 new messages