Is a NPAPI plugin what I am looking for? - npapi

I need to develop a mini ClickOnce plugin for Firefox, Chrome, Operah and Safari (preferably, one that works on all of the above).
My plugin needs to be able to run an application in a one-click fashion. In other words, by going to a specific URL, my application will run on the target machine (no prompts / dialogs shown). Unfortunately, ClickOnce is only available with IE, and I am unhappy with the ClickOnce plugins that currently exist. I would like to develop a tailored ClickOnce plugin that suits my specific needs.
I read about FireBreath, which sounded like a perfect solution for me. I also read about the difference between an extension and a plugin and I think a plugin is what I am looking for. I just wanted to make sure with you guys that I am on the right path. Is what I want to achieve possible with FireBreath / NPAPI plugins? Can a plugin download an executable and then run it on a target machine?

Yes, NPAPI will allow you to do what you want. You can run arbitrary native code using an NPAPI plugin, and control it via JavaScript on the web page side. Users will have to download and install your plugin though, so it only makes sense if this is something users will use more than once.
You'll obviously have to be very, very careful about security though. If you make a plugin whose sole purpose is to download and run code without user interaction then you'll need to be absolutely certain that there's no way for a malicious page to use your plugin.

Related

Clickonce: Appropriate for web site that is only supported in Chrome?

We are looking for an easy way for our users to download and install a small client widget (it is a windows app) used with our (much larger) web app.
Our web app is currently only supported in Chrome.
Our concern is that the clickonce support piece may be missing from most Chrome installs.
The questions:
-- Is clickonce really going to be useful in this situation?
-- What is the best option for "one click" download-and-install for Chrome on windows?
ClickOnce uses NPAPI which is being removed from Chrome. You will need to look at NaCl, Native Messaging or PPAPI instead of ClickOnce. There used to be browser extensions that you could use, however they have been removed from the store (or no longer work).
Using Chrome should not matter, so yes Click once will be useful in this situation.
The only thing you need to worry about is your clients using Windows and the appropriate version of the .net framework. I hope this helps.

chrome/chromium extension: run a executable/script via the context menu

I'm writing a small chrome extension for personal use and I would like to run an executable via the context menu and pass certain information as arguments to said executable.
What the simplest and/or cleanest way to achieve this? To me it seems that it is impossible due to chrome's sandboxing.
This can be accomplished via NPAPI Plugins.
Code running in an NPAPI plugin has the full permissions of the
current user and is not sandboxed or shielded from malicious input by
Google Chrome in any way. You should be especially cautious when
processing input from untrusted sources, such as when working with
content scripts or XMLHttpRequest.
However, I should also include their warning.
Warning
NPAPI is being phased out. Consider using alternatives.
NPAPI is a really big hammer that should only be used when no other
approach will work.
via Start an external application from a Google Chrome Extension?
Alternatives to NPAPI
There are several alternatives to NPAPI. In cases where standard web
technologies are not yet sufficient, developers and administrators can
use NaCl, Apps, Native Messaging API, and Legacy Browser Support to
transition from NPAPI. Moving forward, our goal is to evolve the
standards-based web platform to cover the use cases once served by
NPAPI.
via http://blog.chromium.org/2013/09/saying-goodbye-to-our-old-friend-npapi.html
Another way, suggested here, is with Java.
Java applets: http://docs.oracle.com/javase/tutorial/deployment/applet/
Implementing Policy: http://docs.oracle.com/javase/tutorial/security/userperm/policy.html
Use sendNativeMessage:
There is chrome.runtime.sendNativeMessage which can be used to send a
message to a native application and chrome.runtime.connectNative which
allows for a more persistent connection.
So, you can't directly execute a command, but you can have a native
app do it for you.
You can find more info on Native Messaging in the docs.
via https://stackoverflow.com/a/19917672/1085891

Calling Windows API from Native Client/Pepper Plugin

My intention is to create a chrome plugin for the windows users. Is that possible to call windows api from Native Client /PPAPI. If possible how?
I am answering my question, as after some study, I found the answer from West a bit not right. I tried calling windows APIs in Pepper(PPAPI) Plugin and it works fine with a command line switch "--register-pepper-plugins" (not the --no-sandbox as specified by West). It seems safer to use this command line attribute as it is only registering a plugin in to the Chrome browser and not removing any sandbox. I thought of adding an answer after finding an actual pepper plugin existing in use, which uses the switch (the NetFlix pepper plugin for chromeos ).
Got more information to add. Chrome API is available which provides the multi-monitor information : chrome.systemInfo.display object provides all the necessary information. The chrome documentation is not updated. Important thing to note is that, the permission "systemInfo.display" is to be added in the manifest to use this object. Two bugs are reported in the functionality of this object.
1. The monitor name is same for all monitors "Generic PnP Monitor", the documentation claims to provide the user friendly name of monitors.
2. There is an event which should get invoked on resolution change of monitors, but the event is never getting invoked.
Currently the implementation is only for Windows OS. Support for other OS are on the way. Documentation says that the API is only available for Chrome App, but I haves tested that and the API is available on Chrome Extensions as well.
Unfortunately, the short answer is 'no'. Native Client is designed to be OS-independent and as safe as JavaScript. Think of Native Client as native code that has the same capabilities and restrictions as JavaScript. A Native Client module that made Windows API calls would break both of those design principles: it wouldn't run on, e.g., a Mac, and it would be a major security risk (imagine browsing to a web page that decides to erase files from your harddrive).
Since you mention Chrome, it may be interesting to you to know that web apps - whether they use JavaScript or Native Client - can request additional permissions as packaged apps in Chrome Web Store. However, native OS calls are still not possible for the reasons listed above.
NPAPI plugins do not have these restrictions, but the future of NPAPI, at least in Chrome, is uncertain (see the last paragraph of http://blog.chromium.org/2012/07/npapi-plug-ins-in-windows-8-metro-mode.html).
For development purposes, it is possible to turn Chrome's outer sandbox off with the command-line flag --no-sandbox and then run PPAPI plugins that make direct OS calls. This is meant for developers and is not a suitable option to be used by end-users.
If you could say a bit more about what you're trying to achieve, there may be ways to do this with Native Client/Pepper.

Building a leaner XulRunner for HTML/JavaScript usage?

Is there a way to make a leaner HTML/Javascript -oriented build/package of the Mozilla XulRunner components, excluding some of the heavier XUL-platform features?
Background:
We are building a cross-platform application with a HTML/JavaScript GUI. The host app is running on .NET/Mono, and the GUI is rendered using Mozilla XulRunner via the GeckoFx wrapper. Everything is working great.
We have one issue: the XulRunner (9.0.x) components weighing at 28MB make the application installer a bit larger than we'd like. The XulRunner does not need to be deployed separately if the user already has Firefox installed, but we would want to reduce the footprint for the users who don't.
We've already excluded all XulRunner executables from the official release build to get the package down to its current size.
It occurs to me that we are only using a small subset of the XulRunner platform. We do not require any of the XUL features, only HTML, JavaScript and CSS. This leads me to think that we might be able to make a custom build which excludes some of the parts we don't need, but I'm not well-versed in the Mozilla build arcana.
Any help would be greatly appreciated!
You will typically use build options like --disable-tests (don't build those test executables) and --enable-optimize/--disable-debug. Also, you should be able to use --disable-xul option. However, you need to be aware that options like --disable-xul create builds that aren't quite as well tested as the official XULRunner. Other options that should be ok in a simple application:
--disable-jsd Disable JavaScript debug library
--disable-plugins Disable plugins support
--disable-view-source Disable view source support
--disable-accessibility Disable accessibility support
--disable-printing Disable printing support
--disable-crashreporter Disable breakpad crash reporting
--disable-mathml Disable MathML support
--disable-installer Disable building of installer
--disable-updater Disable building of updater
--disable-activex Disable building of ActiveX control
--disable-activex-scripting Disable building of ActiveX scripting support (win32)
--disable-feeds Disable feed handling and processing components
You can find other options by searching for MOZ_ARG_DISABLE_BOOL in configure.in.

How to write a secure NPAPI plugin that would interact only with a specific chrome extension?

I want to write a chrome extension that would automatically (without user interaction) read and upload a file from the local storage based on some event. I understand this is not directly possible because of the security model of the web and browsers.
After researching online I found that this can be achieved through an NPAPI plugin. From what I understand, I can write a chrome extension that will interact (via NPRuntime API) to the NPAPI plugin and request for a file to be uploaded. The plugin would retrieve the file and respond with the file data.
Question 1: Is the architecture conceived above a reasonable/efficient way of achieving my task?
If so, then my concern is on the security of this method.
Question 2: Since my plugin would be reading (and maybe writing) stuff from (and to) local storage, how would I code it in a secure manner so that it's not misused by other malicious sites/extensions? My plugin should work only with my extension and not with any other site/extensions. How would I achieve this? In other words, what kind of measures should I take to secure the interactions between my chrome extension and NAAPI plugin so that there is no room for malicious attacks?
Several FireBreath users have created plugins with FireBreath for use with Chrome and packaged them inside a Chrome Extensions (CRX). If you make the plugin "private" inside the extension then only that chrome extension can use the plugin. Note that no other browsers support this method.
You could of course do the same thing with any other NPAPI plugin, but FireBreath saves you a ton of time when you don't have to implement everything yourself.