Sandbox not allowing injecting JS code?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Sandbox not allowing injecting JS code?

Postby ajitchavan » Thu Aug 05, 2021 4:17 am

While sandbox is enabled, injecting javascript code using ExecuteJavaScript() getting an error at first line of JS code.

[0804/090146.960527:WARNING:display_handler_impl.cc(107)] [JS][https://www.google.com/?gws_rd=ssl](1)Uncaught SyntaxError: Unexpected end of input

If we use --no sandbox flag we do not get any error and can browse.
ajitchavan
Techie
 
Posts: 27
Joined: Mon Mar 16, 2020 7:03 am

Re: Sandbox not allowing injecting JS code?

Postby magreenblatt » Thu Aug 05, 2021 9:54 am

What OS and CEF version? What URL have you loaded, what JS code are you injecting, and triggered by what method or action?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Sandbox not allowing injecting JS code?

Postby ajitchavan » Fri Aug 06, 2021 12:11 am

Hi Magreenblatt,
Below are the details,
1] OS: "Ubuntu 20.04.2 LTS" server
2] CEF_VERSION: "89.0.18+gb36241d+chromium-89.0.4389.114"
3] JS code: we are adding code to parse websites HTML. Also tried with simple console log but it gives error at first line itself.
Code is injected inside OnContextCreated() using frame and context received.
4] Trigger point: We listen to DOMContentLoaded event.

Same code works when we use --no sandbox flag.
ajitchavan
Techie
 
Posts: 27
Joined: Mon Mar 16, 2020 7:03 am

Re: Sandbox not allowing injecting JS code?

Postby magreenblatt » Fri Aug 06, 2021 11:22 am

What is the JS code that’s failing? Have you tried reducing the code to identify the exact failure condition?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Sandbox not allowing injecting JS code?

Postby ajitchavan » Fri Aug 06, 2021 11:53 am

Yes I tried reducing code and only added console. Even for that getting same error.
And error shows at line number 1 itself.

[0804/090146.960527:WARNING:display_handler_impl.cc(107)] [JS][https://www.google.com/?gws_rd=ssl](1)Uncaught SyntaxError: Unexpected end of input
ajitchavan
Techie
 
Posts: 27
Joined: Mon Mar 16, 2020 7:03 am

Re: Sandbox not allowing injecting JS code?

Postby HarmlessDave » Sun Aug 08, 2021 1:17 pm

What happens if you manually post your javascript into a Google Chrome F12 console window? We inject a few scripts for different purposes at work (but not in sandbox mode), and more than once the problem has been a typo like missing ";" or "}" or other syntax error. You might also need to remove any hard returns from your string.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Sandbox not allowing injecting JS code?

Postby ajitchavan » Mon Aug 09, 2021 2:09 am

There are no syntax error such as missing or extra ";" or "}" .For us as well scripts work when we run with no sandbox(--no-sandbox). But when we run same js code with sandbox getting an error at first line itself
ajitchavan
Techie
 
Posts: 27
Joined: Mon Mar 16, 2020 7:03 am

Re: Sandbox not allowing injecting JS code?

Postby Czarek » Mon Aug 09, 2021 6:48 am

Any other messages in logs?
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Sandbox not allowing injecting JS code?

Postby ajitchavan » Wed Aug 11, 2021 12:19 am

There are other logs but those are not relevant to this. It is because I am running application as normal user not as root. For sandbox I can not run it with root user.

Code: Select all
[size=85][0802/115406.958164:ERROR:simple_backend_impl.cc(81)] Failed to create directory: /home/code/cache/Code Cache/wasm
[0802/115406.964797:ERROR:disk_cache.cc(184)] Unable to create cache
[0802/115407.007398:ERROR:database.cc(1707)] Cookie sqlite error 14, errno -2: unable to open database file, sql: -- sqlite3_open()
[0802/115407.007568:ERROR:sqlite_persistent_store_backend_base.cc(97)] Unable to open Cookie DB.
[0802/115407.073511:WARNING:render_app.cc(206)] OnBrowserCreated-renderer mirroring
[0802/115407.262980:WARNING:dom_mirror_js.h(48)] cwd: looking for ext in /extensions/dom_mirroring/
[0802/115407.265028:WARNING:display_handler_impl.cc(107)] [JS][https://www.google.com/?gws_rd=ssl](1)Uncaught SyntaxError: Unexpected end of input
[0802/115407.271337:WARNING:display_handler_impl.cc(107)] [JS][https://www.google.com/?gws_rd=ssl](1)Uncaught SyntaxError: Unexpected end of input
[0802/115407.318766:WARNING:display_handler_impl.cc(107)] [JS][https://www.google.com/?gws_rd=ssl](1)Uncaught SyntaxError: Unexpected end of input[/size]
ajitchavan
Techie
 
Posts: 27
Joined: Mon Mar 16, 2020 7:03 am

Re: Sandbox not allowing injecting JS code?

Postby Czarek » Wed Aug 11, 2021 5:24 am

Does your JS error occur for any injected code? Try some basic code like "void(0)".

The disk errors you have may be relevant.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 34 guests