Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on select file dialog when policy deny it #6340

Closed
alexgor1 opened this issue Dec 18, 2017 · 7 comments
Closed

Crash on select file dialog when policy deny it #6340

alexgor1 opened this issue Dec 18, 2017 · 7 comments

Comments

@alexgor1
Copy link

NWJS Version : 0.27.2
Operating System : OSX 10.11.6, Ubuntu 16.04

Expected behavior

NWJS should ignore file selection in respect to policy without crash.

Actual behavior

NWJS crashes.

How to reproduce

  1. Policy file has value AllowFileSelectionDialogs set to false, so policy does not allow to select file.
  2. Open url to some page with file upload input field. For example:
    nw.Window.open('https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_create', {}, function(win) { });
  3. Click "Try it" button at the right frame
  4. Button "Choose file" will appear. Click it.
  5. NWJS crashes.

Top portion of crash dump on Mac OS X:
Operating system: Mac OS X
10.11.6 15G31
CPU: amd64
family 6 model 60 stepping 3
4 CPUs

GPU: UNKNOWN

Crash reason: EXC_BAD_ACCESS / KERN_INVALID_ADDRESS
Crash address: 0x0
Process uptime: 42 seconds

Thread 0 (crashed)
0 nwjs Framework!SimpleAlertInfoBarDelegate::Create(infobars::InfoBarManager*, infobars::InfoBarDelegate::InfoBarIdentifier, gfx::VectorIcon const*, std::__1::basic_string<unsigned short, base::string16_internals::string16_char_traits, std::__1::allocator > const&, bool) [simple_alert_infobar_delegate.cc : 20 + 0x0]
rax = 0x00007fff59759fd8 rdx = 0x0000000000000000
rcx = 0x00007fff59759fd8 rbx = 0x0000000000000000
rsi = 0x0000000000000026 rdi = 0x0000000000000000
rbp = 0x00007fff59759fc0 rsp = 0x00007fff59759f70
r8 = 0x0000000000000001 r9 = 0x00007fd563c502e8
r10 = 0x00000000ffffffff r11 = 0x0000000000000048
r12 = 0x0000000000000000 r13 = 0x0000000000000026
r14 = 0x00007fff59759fd8 r15 = 0x00007fff59759fd8
rip = 0x0000000109ad5111
Found by: given as instruction pointer in context
1 nwjs Framework!ChromeSelectFilePolicy::SelectFileDenied() [chrome_select_file_policy.cc : 33 + 0x18]
rbp = 0x00007fff5975a110 rsp = 0x00007fff59759fd0
rip = 0x000000010a5a046e
Found by: previous frame's frame pointer
2 nwjs Framework!ui::SelectFileDialog::SelectFile(ui::SelectFileDialog::Type, std::__1::basic_string<unsigned short, base::string16_internals::string16_char_traits, std::__1::allocator > const&, base::FilePath const&, ui::SelectFileDialog::FileTypeInfo const*, int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, NSWindow*, void*) [select_file_dialog.cc : 111 + 0x6]
rbp = 0x00007fff5975a190 rsp = 0x00007fff5975a120
rip = 0x000000010956c2de
Found by: previous frame's frame pointer
3 nwjs Framework!FileSelectHelper::RunFileChooserOnUIThread(base::FilePath const&, std::__1::unique_ptr<content::FileChooserParams, std::__1::default_deletecontent::FileChooserParams >) [file_select_helper.cc : 618 + 0x11]
rbp = 0x00007fff5975a210 rsp = 0x00007fff5975a1a0
rip = 0x0000000107f1fa13
Found by: previous frame's frame pointer
4 nwjs Framework!FileSelectHelper::GetSanitizedFilenameOnUIThread(std::__1::unique_ptr<content::FileChooserParams, std::__1::default_deletecontent::FileChooserParams >) [file_select_helper.cc : 526 + 0x8]
rbp = 0x00007fff5975a2a0 rsp = 0x00007fff5975a220
rip = 0x0000000107f1f6c2
Found by: previous frame's frame pointer
5 nwjs Framework!base::internal::Invoker<base::internal::BindState<void (FileSelectHelper::)(std::__1::unique_ptr<content::FileChooserParams, std::__1::default_deletecontent::FileChooserParams >), scoped_refptr, base::internal::PassedWrapper<std::__1::unique_ptr<content::FileChooserParams, std::__1::default_deletecontent::FileChooserParams > > >, void ()>::RunOnce(base::internal::BindStateBase) [bind_internal.h : 194 + 0x2]
rbp = 0x00007fff5975a3f0 rsp = 0x00007fff5975a2b0
rip = 0x0000000107f208e9
Found by: previous frame's frame pointer
6 nwjs Framework!base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*) [callback.h : 64 + 0x3]
rbp = 0x00007fff5975a540 rsp = 0x00007fff5975a400
rip = 0x000000010828e684
Found by: previous frame's frame pointer

It was tested on several versions (0.26.5, 0.26.6, 0.27.1, 0.27.2) and on two platforms (Mac OS X, Linux Ubuntu).

I found old similar bug which is close to this one:
https://bugs.chromium.org/p/chromium/issues/detail?id=442192

@rogerwang
Copy link
Member

Thanks for reporting. This is fixed in git and will be available in the next nightly build.

@mkazlauskas
Copy link

@alexgor1 how do you apply chrome policy to your nw.js app? I need this same "AllowFileSelectionDialogs" policy but can't get it to work.

@alexgor1
Copy link
Author

alexgor1 commented Feb 6, 2018

@mkazlauskas, put your JSON policy to /etc/chromium/policies/managed/ folder for Linux or edit ~/Library/Preferences/io.nwjs.nwjs.plist for MacOS

@mkazlauskas
Copy link

I actually need it on Windows. Tried following https://support.google.com/chrome/a/answer/187202?hl=en without success (only applies to actual Chrome browser).

@alexgor1
Copy link
Author

alexgor1 commented Feb 6, 2018

I haven't tried to do it for Windows, but i think the rule is the same. You have to use Chromium settings instead of Chrome and try to find own nwjs way like they have for MacOS. This is link to starting point https://www.chromium.org/administrators/configuring-policy-for-extensions

@mkazlauskas
Copy link

mkazlauskas commented Feb 6, 2018

Thanks @alexgor1 . It seems like it needs application identifier e.g. gihmafigllmhbppdfjnfecimiohcljba in HKLM\Software\Policies\Google\Chrome\3rdparty\extensions\gihmafigllmhbppdfjnfecimiohcljba\policy. Any idea how to get this for my app? I can see it in local files URLs, but it would be great if I could somehow set those policies in the installer. If you have any resources on this identifier please let me know.

Edit: the link you posted is useful, but it's about custom app/extension policies (not default policies). I was successfully set AllowFileSelectionDialogs for both Chrome and Chromium, yet it still won't work on nw.js.

Where did you get info about MacOS nw.js policies path?

@alexgor1
Copy link
Author

alexgor1 commented Feb 7, 2018

@mkazlauskas For MacOS i saved settings for nwjs over defaults and searched for applied changes in Preferences, I think you have to use some registry monitor to see where nwjs looks for policy

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

No branches or pull requests

3 participants