window.addEventListener("message", handleMessage, false);
....// Called sometime after postMessage is called
function handleMessage(event)
{
// We can check here the sender, the data, or any combination thereof
// So for example, originA could only be allowed to read settingA while
// originB could be allowed to read and write settingB, and read only settingC
if (!allowedMessage(event)) {
return;
}
// At this point we know the petition can be served, go ahead and serve it.
getSetting(event.data).then(settingData => event.source.postMessage(settingData, event.origin));
}
As I said, it's easily told (and IMHO webby enough since we don't actually need any new API, just a new kind of frame which can be just ignored by everybody else) but harder to implement.Hi there.
In the frame of the recent arguments about the permission model and making the apps more webby and as a result more easily updatable (or the other way around), we've been playing with the idea (and trying to prototype) of having certified service-like apps that would encapsulate some permissions.
The rationale behind this is that there are some certified permissions (like settings) that are used by a bunch of apps that only need a small subset of the things the permission actually allow. So we could split the permission (as setting has actually done, in a way that requires Gecko to be aware of the specific settings that Gaia uses, see [1]!) or we could add a Gaia component that has access to the whole setting functionality and mediates on requests to fulfill them or not. Enter the services.
One way to implement the services would be (and that's what we're actually toying with) to use IAC or Datastores to communicate with them). But as we were reminded recently, there's little to no chance of those APIs being actually opened to the web. So... I thought another proposal, that seems webby enough. The idea is to define a new kind of frame, "mozservices". Those frames can be embedded on an app and when they are embedded:
[1] http://hg.mozilla.org/mozilla-central/diff/2a8fd75b667f/dom/apps/src/PermissionsTable.jsm
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
_______________________________________________
dev-b2g mailing list
dev...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g
Hi there.
In the frame of the recent arguments about the permission model and making the apps more webby and as a result more easily updatable (or the other way around), we've been playing with the idea (and trying to prototype) of having certified service-like apps that would encapsulate some permissions.
The rationale behind this is that there are some certified permissions (like settings) that are used by a bunch of apps that only need a small subset of the things the permission actually allow. So we could split the permission (as setting has actually done, in a way that requires Gecko to be aware of the specific settings that Gaia uses, see [1]!) or we could add a Gaia component that has access to the whole setting functionality and mediates on requests to fulfill them or not. Enter the services.
One way to implement the services would be (and that's what we're actually toying with) to use IAC or Datastores to communicate with them). But as we were reminded recently, there's little to no chance of those APIs being actually opened to the web. So... I thought another proposal, that seems webby enough. The idea is to define a new kind of frame, "mozservices". Those frames can be embedded on an app and when they are embedded:
* They're loaded remotely (aka in another process).
* If the app/url referenced on the iframe is already loaded, don't load it again, just return a window object that points to the already loaded URL.
* They don't have opener (which wouldn't make sense anyway since they can be opened from several places at the same time)
* And the window object created by the iframe allows postMessage
With an example:
* On the client app HTML:
<iframe id="settingsService" mozservice src="app://settingsservice.gaiamobile.org" ></iframe>
var settingsService = new SharedWorker("app://settingsservice.gaiamobile.org", { service: true }); // second parameter is new settingsService.port.start();
settingsService.port.postMessage(settingNeed);
(on the client app code)...
...
settingsService.postMessage(settingINeed, "app://settingsservice.gaiamobile.org");
...
* On the service app:
....
....window.addEventListener("message", handleMessage, false);
As I said, it's easily told (and IMHO webby enough since we don't actually need any new API, just a new kind of frame which can be just ignored by everybody else) but harder to implement.// Called sometime after postMessage is called function handleMessage(event) { // We can check here the sender, the data, or any combination thereof // So for example, originA could only be allowed to read settingA while // originB could be allowed to read and write settingB, and read only settingC if (!allowedMessage(event)) { return; } // At this point we know the petition can be served, go ahead and serve it. getSetting(event.data).then(settingData => event.source.postMessage(settingData, event.origin)); }
I lke the iframe proposal mainly for two reasons: it is more natural from the point of view of "getting the same instance" and it's like embedding a component (which reminds me about the <object> tag).
WDYT?
On Thu, Feb 26, 2015 at 12:02 PM, Antonio Manuel Amaya Calvo <antoniomanue...@telefonica.com> wrote:
Hi there.
In the frame of the recent arguments about the permission model and making the apps more webby and as a result more easily updatable (or the other way around), we've been playing with the idea (and trying to prototype) of having certified service-like apps that would encapsulate some permissions.
That would be very cool imho.
The rationale behind this is that there are some certified permissions (like settings) that are used by a bunch of apps that only need a small subset of the things the permission actually allow. So we could split the permission (as setting has actually done, in a way that requires Gecko to be aware of the specific settings that Gaia uses, see [1]!) or we could add a Gaia component that has access to the whole setting functionality and mediates on requests to fulfill them or not. Enter the services.
Part of the design of the new Gaia architecture is to be able to prototype such a thing. Some apps can be built as 'Services' and multiple apps may access those Services to do some stuff.
It is not yet implemented but this is on our 'things to explore' todo list.
One way to implement the services would be (and that's what we're actually toying with) to use IAC or Datastores to communicate with them). But as we were reminded recently, there's little to no chance of those APIs being actually opened to the web. So... I thought another proposal, that seems webby enough. The idea is to define a new kind of frame, "mozservices". Those frames can be embedded on an app and when they are embedded:
What I have been told is that there is a proposal from Google called 'Tubes' to allow cross-origin communication. I may have misunderstood and the name may not be the right one, but sicking knows.
So maybe the cross-origin communication mechanism is still an option (but not IAC, nor DataStore).
In Gaia the prototype would look a bit like:
App:
var c = new Client('settings', /* version */ '1.0');
c.get('some.setting').then(function(value) {
// do something
});
Remote Service:
var s = new Server('settings', /* version */ '1.0' {
get: function(setting) {
// do something
}
});
Where Client and Server are client sides API based on Promises. The postMessage communication, is hidden into the lib in order to make it easier to use any new APIs that may comes one day. (fwiw this APIs is built primarily in order to have a clear communication API between views and workers).
Why I would prefer that over embedding a frame ?
- The iframe trick seems to just be a workaround around the lack of APIs to do cross-origin communication.
- With the frame you need to know the url of the Service, which is something that may change, and it would be cool if third-party developers can create their own Services to replace ours in the future.
- The service does not need to have a window object to return. It simply returns data.One of the cool thing we could build around Services too is the ability for the client to subscribe to some events.
For example:
var c = new Client('contacts', '1.1');
c.addEventListener('oncontactschanged', function(changes) {
// do something
});
While if the iframe does not have an opener (as you describe), it could only react to postMessage. So the iframe needs a way to know who has opened it to push those kind of notifications.
* They're loaded remotely (aka in another process).
* If the app/url referenced on the iframe is already loaded, don't load it again, just return a window object that points to the already loaded URL.
* They don't have opener (which wouldn't make sense anyway since they can be opened from several places at the same time)
* And the window object created by the iframe allows postMessage
With an example:
* On the client app HTML:
<iframe id="settingsService" mozservice src="app://settingsservice.gaiamobile.org" ></iframe>
(on the client app code)...
...
settingsService.postMessage(settingINeed, "app://settingsservice.gaiamobile.org");
...
* On the service app:
....
....window.addEventListener("message", handleMessage, false);
As I said, it's easily told (and IMHO webby enough since we don't actually need any new API, just a new kind of frame which can be just ignored by everybody else) but harder to implement.// Called sometime after postMessage is called function handleMessage(event) { // We can check here the sender, the data, or any combination thereof // So for example, originA could only be allowed to read settingA while // originB could be allowed to read and write settingB, and read only settingC if (!allowedMessage(event)) { return; } // At this point we know the petition can be served, go ahead and serve it. getSetting(event.data).then(settingData => event.source.postMessage(settingData, event.origin)); }
WDYT?
Fwiw, this is just a different API design. I'm just exposing the way I would like to explore it with the new Gaia architecture.
The first focus should really be on: "is there a chance that those kind of services exists ?"
Thanks for launching this discussion.
Vivien.
[1] http://hg.mozilla.org/mozilla-central/diff/2a8fd75b667f/dom/apps/src/PermissionsTable.jsm
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
_______________________________________________
dev-b2g mailing list
dev...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g
On Feb 26, 2015, at 2:30 PM, Vivien Nicolas <vnic...@mozilla.com> wrote:One way to implement the services would be (and that's what we're actually toying with) to use IAC or Datastores to communicate with them). But as we were reminded recently, there's little to no chance of those APIs being actually opened to the web. So... I thought another proposal, that seems webby enough. The idea is to define a new kind of frame, "mozservices". Those frames can be embedded on an app and when they are embedded:
What I have been told is that there is a proposal from Google called 'Tubes' to allow cross-origin communication. I may have misunderstood and the name may not be the right one, but sicking knows.
Thanks for starting this thread Antonio.
On the scenario that you propose, at least for the use case that you provided (settings), it seems that we are moving the permission check from Gecko to Gaia.
On Gecko we currently have signed apps and a list of permissions associated to them. On the content side we don't have any of this information available. Could you elaborate a bit more about how would the Service decide if a 3rd party app can access or not the wrapped resource. In other words, how would third party apps request permission to access the content controlled by the Service?
/ Fernando
On Thu, Feb 26, 2015 at 8:31 PM, Antonio Manuel Amaya Calvo <antoniomanue...@telefonica.com> wrote:BTW, exposing new APIs is not hard... agreeing to make them available to everyone on the web is a loooong process though ;). This way we don't really add anything new to the web, we just use what's currently available on a device efficient way, and can be pegged as implementation details.If only it were that easy :-) We can't add some magic unexplained <iframe> variant to the web, claim victory, and hope nobody notices.
That two things don't change the semantic at all, and as I said they're implementation details, for FirefoxOS only. If FirefoxOS process model were different (and/or if our devices had metric tons of memory ;)) then we wouldn't even need to hint the browser
that "this iframe is special, please see if you can treat it with care".
For the rest, the proposal is not different from having an external
https://webreakcorsforyou.com server that allows itself to be embedded on an iframe and responds to postMessages with an URL with the content of that URL (which the server, not the client, downloads). And that's something we can *already* do on the web,
without needing new browser APIs.
See also the emails here that discuss a very similar idea: https://lists.w3.org/Archives/Public/public-webapps/2014OctDec/thread.html#msg352 https://lists.w3.org/Archives/Public/public-webapps/2014OctDec/thread.html#msg379 I think we'll have to embrace that there are no shortcuts and start figuring out what needs to become a service and what needs to become something the browser needs to expose as an API.
_______________________________________________ dev-b2g mailing list dev...@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-b2g
On Thu, Feb 26, 2015 at 12:02 PM, Antonio Manuel Amaya Calvo <antoniomanue...@telefonica.com> wrote:
Hi there.
In the frame of the recent arguments about the permission model and making the apps more webby and as a result more easily updatable (or the other way around), we've been playing with the idea (and trying to prototype) of having certified service-like apps that would encapsulate some permissions.
That would be very cool imho.
The rationale behind this is that there are some certified permissions (like settings) that are used by a bunch of apps that only need a small subset of the things the permission actually allow. So we could split the permission (as setting has actually done, in a way that requires Gecko to be aware of the specific settings that Gaia uses, see [1]!) or we could add a Gaia component that has access to the whole setting functionality and mediates on requests to fulfill them or not. Enter the services.
Part of the design of the new Gaia architecture is to be able to prototype such a thing. Some apps can be built as 'Services' and multiple apps may access those Services to do some stuff.
It is not yet implemented but this is on our 'things to explore' todo list.
One way to implement the services would be (and that's what we're actually toying with) to use IAC or Datastores to communicate with them). But as we were reminded recently, there's little to no chance of those APIs being actually opened to the web. So... I thought another proposal, that seems webby enough. The idea is to define a new kind of frame, "mozservices". Those frames can be embedded on an app and when they are embedded:
What I have been told is that there is a proposal from Google called 'Tubes' to allow cross-origin communication. I may have misunderstood and the name may not be the right one, but sicking knows.
So maybe the cross-origin communication mechanism is still an option (but not IAC, nor DataStore).
In Gaia the prototype would look a bit like:
App:
var c = new Client('settings', /* version */ '1.0');
c.get('some.setting').then(function(value) {
// do something
});
Remote Service:
var s = new Server('settings', /* version */ '1.0' {
get: function(setting) {
// do something
}
});
Where Client and Server are client sides API based on Promises. The postMessage communication, is hidden into the lib in order to make it easier to use any new APIs that may comes one day. (fwiw this APIs is built primarily in order to have a clear communication API between views and workers).
Why I would prefer that over embedding a frame ?
- The iframe trick seems to just be a workaround around the lack of APIs to do cross-origin communication.
The thing is that postMessage *is* an API designed specifically to do cross origin communication. Or that's how I understood it anyway :). In fact if I wanted to do cross origin communication on the web right now j would have to do it using postMessage. The trick here is that mostly for performance and security reasons we want those iframes to be reusable (have only one actual instance).
- With the frame you need to know the url of the Service, which is something that may change, and it would be cool if third-party developers can create their own Services to replace ours in the future.
That's right, but again, URLs are the standard way to identify objects/elements/resources on the web. So the difference is if the client app wants to use any settings service versus this specific service identified by this URL.
- The service does not need to have a window object to return. It simply returns data.One of the cool thing we could build around Services too is the ability for the client to subscribe to some events.
For example:
var c = new Client('contacts', '1.1');
c.addEventListener('oncontactschanged', function(changes) {
// do something
});
While if the iframe does not have an opener (as you describe), it could only react to postMessage. So the iframe needs a way to know who has opened it to push those kind of notifications.
Hmm that is a fair point. As I had seen this would work on a request/response way only, not on a publisher/subscriber way.
In any case, what I had tried to do with this proposal was to *not* introduce any new API (which then would have to be designed and standardized and what not) but to see if we could do with what we currently have. Note that if we remove the restriction to encapsulate other apps this could even work with what we have right now.
Best,
Antonio
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
_______________________________________________
dev-b2g mailing list
dev...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g
_______________________________________________
dev-b2g mailing list
dev...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g
On 26/02/2015 16:11, Fernando Jiménez Moreno wrote:
Thanks for starting this thread Antonio.
On the scenario that you propose, at least for the use case that you provided (settings), it seems that we are moving the permission check from Gecko to Gaia.
Yes and not. I'm not proposing to move the permission check from Gecko to Gaia, Gecko will still have the same permission check it has now. What I'm proposing is implementing a (set) of proxy/ies of APIs. Some app(s) that will act as proxy/ies for other apps that cannot request the permission directly (because the API is certified or privileged for security reasons or because we don't want to open the API to the web). That way some apps that currently are certified (in Gaia) can be moved to privileged or even web.
On Gecko we currently have signed apps and a list of permissions associated to them. On the content side we don't have any of this information available. Could you elaborate a bit more about how would the Service decide if a 3rd party app can access or not the wrapped resource. In other words, how would third party apps request permission to access the content controlled by the Service?
Ok, again there are two different issues here. On one hand, initially the services would be services for the OS apps (that is, the Gaia apps). Those services will allow moving apps from certified to privileged or even web, if the APIs that they use can be mediated by a "service app". As such, the service can decide to serve or not the request by a combination of the origin (origin URL) and the actual data passed. A hypothetical settings service could use a table like:
{
"https://music.gaiamobile.org" : {
read: ["volume.max", "volume.current", "silentmode"],
write: ["volume.max"]
...
}
(I didn't check the actual settings that the music app uses).
Each service can, and should, have it's own set of rules it applies before serving a request. So we could have a XMLHttpRequest proxy that could serve petitions using SystemXHR from some apps to a concrete set of domains (or *), a disk access proxy that could allow access from some apps to some specific directories and so on. The nice part of this is that since it's all on the Gaia side we will not be introducing any design dependencies between Gecko and Gaia (Gecko doesn't need to know anything about Gaia!).
This is the initial step. I didn't talk anything about third party apps so far :)
If we want to open this to third party apps, then it'll have to be on a controlled way. We can still do it by origin (https only, obviously) and we can download the actual ruleset from a Mozilla/Operator/OEM server. That would allow dynamic configuration of what apps can access what services, allowing Mozilla, an operator or an OEM to add another app without having to change the core/certified apps. For example, if we decide to add a "3D photo camera" at a later point, that requires access to a mediated API, we can just update the ruleset for that service on the Mozilla server (or the operator server, or the OEM server, or even the personal server of the user if the phone has a homebrew build!) to add the rules for https://3dphonecamera.somedeveloper.com and presto, we have a new app that has access to protected resources on a controlled way.
Best,
Antonio
/ Fernando
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
I can't comment on webby-ness, but I do have thoughts about security here.
(OK, just one comment: this sounds like a variation on the existing inter app communications service - its there practically any differences, other than a forward declaration in the app manifest?Just a thought).
In general I think the next step here is to flesh out what some of these services might do? I'm struggling to think of actual services that would support gaia use cases in a safe way but its probably worth exploring, if only to better understand the APIs we need for gaia.
On Fri, Feb 27, 2015 at 2:42 AM, Antonio Manuel Amaya Calvo <antoniomanue...@telefonica.com> wrote:
On 26/02/2015 16:11, Fernando Jiménez Moreno wrote:
Yes and not. I'm not proposing to move the permission check from Gecko to Gaia, Gecko will still have the same permission check it has now. What I'm proposing is implementing a (set) of proxy/ies of APIs. Some app(s) that will act as proxy/ies for other apps that cannot request the permission directly (because the API is certified or privileged for security reasons or because we don't want to open the API to the web). That way some apps that currently are certified (in Gaia) can be moved to privileged or even web.Thanks for starting this thread Antonio.
On the scenario that you propose, at least for the use case that you provided (settings), it seems that we are moving the permission check from Gecko to Gaia.
From a security perspective, you _are_ just implementing more APIs, except in Gaia instead of gecko. The security of these services depends on the security checks they implement. Not saying this is a bad thing (maybe the flexibiity of an update app is useful?) but there's no escaping that the security of device relies on the security checks implemented in these services.
What's more is that these services actually have less information to make a security decision on. They basically only have access to the origin of the page making the request.
then even if
https://someserver.wetrust.com is thoroughly compromised, it *still* would only be able to access to that same services. This is actually better and worse than what we currently do for privileged and certified apps:
I don't envision services as giving uncontrolled access to any of the underlying APIs, but of them giving access, to each origin, to the specific subset of the API than when the origin was submitted/we wrote the app we deemed for it safe to access. So basically
the same that reviewers currently do with privileged apps, only even when the app changes it will still have access to the same subset of the underlying API.
On Gecko we currently have signed apps and a list of permissions associated to them. On the content side we don't have any of this information available. Could you elaborate a bit more about how would the Service decide if a 3rd party app can access or not the wrapped resource. In other words, how would third party apps request permission to access the content controlled by the Service?
Ok, again there are two different issues here. On one hand, initially the services would be services for the OS apps (that is, the Gaia apps). Those services will allow moving apps from certified to privileged or even web, if the APIs that they use can be mediated by a "service app". As such, the service can decide to serve or not the request by a combination of the origin (origin URL) and the actual data passed. A hypothetical settings service could use a table like:
{
"https://music.gaiamobile.org" : {
read: ["volume.max", "volume.current", "silentmode"],
write: ["volume.max"]
...
}
(I didn't check the actual settings that the music app uses).
I know this is contrived example but this seems backwards to me. Shouldn't the settings that the music wants to access be defined in the music app itself?
Now, for Gaia apps, the second part can be automated. That is, the settings app can define in it's manifest, on in some new file read at build time only, the services it need to access, and what subset of those services it need, and the build process can
create the initial/static ruleset for those apps. For third party apps, though, they will have to submit their apps/needs to the ruleset server, the same way they currently submit the privileged apps, if they want to access restricted elements on the phone.
That aside, lets consider the compromise scenario (which is the main challenge hosted apps). In this case, the music app has been compromised and the attacker has access to the same settings as the music app. The service has no way of of knowing that the app is compromised, so the only settings that the service can safely expose to the music app are things that don't matter to much if the music app is compromised.
In general I guess the benefit here is that ability to add new, more finely grained APIs without changing the underlying gecko API. I like the concept, but I'm struggling to think of actual services that we could implement that would bring meaningful powers hosted versions of gaia apps.
Each service can, and should, have it's own set of rules it applies before serving a request. So we could have a XMLHttpRequest proxy that could serve petitions using SystemXHR from some apps to a concrete set of domains (or *), a disk access proxy that could allow access from some apps to some specific directories and so on. The nice part of this is that since it's all on the Gaia side we will not be introducing any design dependencies between Gecko and Gaia (Gecko doesn't need to know anything about Gaia!).
This is the initial step. I didn't talk anything about third party apps so far :)
If we want to open this to third party apps, then it'll have to be on a controlled way. We can still do it by origin (https only, obviously) and we can download the actual ruleset from a Mozilla/Operator/OEM server. That would allow dynamic configuration of what apps can access what services, allowing Mozilla, an operator or an OEM to add another app without having to change the core/certified apps. For example, if we decide to add a "3D photo camera" at a later point, that requires access to a mediated API, we can just update the ruleset for that service on the Mozilla server (or the operator server, or the OEM server, or even the personal server of the user if the phone has a homebrew build!) to add the rules for https://3dphonecamera.somedeveloper.com and presto, we have a new app that has access to protected resources on a controlled way.
So Mozilla just granted access to my photo library to some random third-party that they decided to trust? :) As a user, do I get a say in this?
To me this use case feels more like extensions than apps - maybe we should be considering building extensions (that have full gecko access, and can use that to make security decisions and can provide security UI, like prompts/notifications etc) rather than trying to implement everything as an app?
On 07/03/2015 10:20, Paul Theriault wrote:
Well, yes, it doesn't need us to introduce a new navigator API (going to start differentiating between those and any other kind of APIs ;)) that has to be standardized. More on this later.I can't comment on webby-ness, but I do have thoughts about security here.
(OK, just one comment: this sounds like a variation on the existing inter app communications service - its there practically any differences, other than a forward declaration in the app manifest?Just a thought).
In general I think the next step here is to flesh out what some of these services might do? I'm struggling to think of actual services that would support gaia use cases in a safe way but its probably worth exploring, if only to better understand the APIs we need for gaia.
Things I can think of:
- Mediated systemXHR: allow systemXHR on a per origin and per destination basis, so the contacts app can access Facebook and Gmail, and only some specific URLs on those servers, for example. Or allow any random X app to access only the servers we deem it's safe for it to access to.
- Mediated settings access: Allow the apps only to access the settings they actually need without adding new permissions to Gecko for each specific Gaia setting that needs more access.
- Mediated dial and SMS access: allow some apps to dial and/or send and/or receive SMS including the text, but only from some specific numbers.
On Fri, Feb 27, 2015 at 2:42 AM, Antonio Manuel Amaya Calvo <antoniomanue...@telefonica.com> wrote:
On 26/02/2015 16:11, Fernando Jiménez Moreno wrote:
Yes and not. I'm not proposing to move the permission check from Gecko to Gaia, Gecko will still have the same permission check it has now. What I'm proposing is implementing a (set) of proxy/ies of APIs. Some app(s) that will act as proxy/ies for other apps that cannot request the permission directly (because the API is certified or privileged for security reasons or because we don't want to open the API to the web). That way some apps that currently are certified (in Gaia) can be moved to privileged or even web.Thanks for starting this thread Antonio.
On the scenario that you propose, at least for the use case that you provided (settings), it seems that we are moving the permission check from Gecko to Gaia.
From a security perspective, you _are_ just implementing more APIs, except in Gaia instead of gecko. The security of these services depends on the security checks they implement. Not saying this is a bad thing (maybe the flexibiity of an update app is useful?) but there's no escaping that the security of device relies on the security checks implemented in these services.
Correct, we'red implementing more APIs but those APIs that don't change the APIs exposed by the navigator, and so they're conceptually not much different of me creating a server that exposed a set of REST APIs... which extend the things I can do on the web/using a browser, but I on't have to standardize ;).
And yeah, the security of the device depends on the security checks implemented on the services.
What's more is that these services actually have less information to make a security decision on. They basically only have access to the origin of the page making the request.
They have access to that, and to what each origin is allowed to do. So if https://someserver.wetrust.com has access to:
- Read and send SMS from +123456789
- Have socket access to someserver.com:12345
then even if https://someserver.wetrust.com is thoroughly compromised, it *still* would only be able to access to that same services. This is actually better and worse than what we currently do for privileged and certified apps:
- It's worse because we don't actually check the code of someserver.wetrust.com and it's easier (I hope :P) to compromise a remote server than a locally installed app.
- It's better because even if/when it's compromised, it will still have access exactly the same subset of the device APIs it previously had. Currently, if a privileged app that has access to SystemXHR is compromised, the attacker will get access to *any* server using SystemXHR (ditto if it has access to contacts, or whatever).
I don't envision services as giving uncontrolled access to any of the underlying APIs, but of them giving access, to each origin, to the specific subset of the API than when the origin was submitted/we wrote the app we deemed for it safe to access. So basically the same that reviewers currently do with privileged apps, only even when the app changes it will still have access to the same subset of the underlying API.
Yes and no. The music app will define the settings it want to access in two ways:
On Gecko we currently have signed apps and a list of permissions associated to them. On the content side we don't have any of this information available. Could you elaborate a bit more about how would the Service decide if a 3rd party app can access or not the wrapped resource. In other words, how would third party apps request permission to access the content controlled by the Service?
Ok, again there are two different issues here. On one hand, initially the services would be services for the OS apps (that is, the Gaia apps). Those services will allow moving apps from certified to privileged or even web, if the APIs that they use can be mediated by a "service app". As such, the service can decide to serve or not the request by a combination of the origin (origin URL) and the actual data passed. A hypothetical settings service could use a table like:
{
"https://music.gaiamobile.org" : {
read: ["volume.max", "volume.current", "silentmode"],
write: ["volume.max"]
...
}
(I didn't check the actual settings that the music app uses).
I know this is contrived example but this seems backwards to me. Shouldn't the settings that the music wants to access be defined in the music app itself?
- Using them ;
- And telling the service ruleset: Hey, I'm the music app and I will need access to these settings.
Now, for Gaia apps, the second part can be automated. That is, the settings app can define in it's manifest, on in some new file read at build time only, the services it need to access, and what subset of those services it need, and the build process can create the initial/static ruleset for those apps. For third party apps, though, they will have to submit their apps/needs to the ruleset server, the same way they currently submit the privileged apps, if they want to access restricted elements on the phone.
That aside, lets consider the compromise scenario (which is the main challenge hosted apps). In this case, the music app has been compromised and the attacker has access to the same settings as the music app. The service has no way of of knowing that the app is compromised, so the only settings that the service can safely expose to the music app are things that don't matter to much if the music app is compromised.
Correct. If the hosted app is compromised, the only things it can do on the phone is the same things it could do *before* it was compromised (so the security depends on how strict the ruleset is when giving access to something, and how narrow that access is).
On Sat, Mar 7, 2015 at 9:26 PM, Antonio Manuel Amaya Calvo <antoniomanue...@telefonica.com> wrote:
On 07/03/2015 10:20, Paul Theriault wrote:
Well, yes, it doesn't need us to introduce a new navigator API (going to start differentiating between those and any other kind of APIs ;)) that has to be standardized. More on this later.I can't comment on webby-ness, but I do have thoughts about security here.
(OK, just one comment: this sounds like a variation on the existing inter app communications service - its there practically any differences, other than a forward declaration in the app manifest?Just a thought).
In general I think the next step here is to flesh out what some of these services might do? I'm struggling to think of actual services that would support gaia use cases in a safe way but its probably worth exploring, if only to better understand the APIs we need for gaia.
Things I can think of:
- Mediated systemXHR: allow systemXHR on a per origin and per destination basis, so the contacts app can access Facebook and Gmail, and only some specific URLs on those servers, for example. Or allow any random X app to access only the servers we deem it's safe for it to access to.
Maybe, but seems far simpler to change the SystemXHR permission just to also accept a whitelist of origins that the app will connect with.
(PS contacts app is a bad example I think, since if it was hosted, the contacts app doesn't need to talk to gmail/facebook oauth services, right? I get your point though)
- Mediated settings access: Allow the apps only to access the settings they actually need without adding new permissions to Gecko for each specific Gaia setting that needs more access.
I guess same argument, and there is the risk of exposing dangerous settings to hosted app.
- Mediated dial and SMS access: allow some apps to dial and/or send and/or receive SMS including the text, but only from some specific numbers.
Lots of risks to mitigiate here. An attacker which compromises a hosted gaia app can send 1000 sms messages and cost the user large amounts of money. (I guess you could rate limit). But this is exactly the sort of thing that I would want to surface to the user for them to decide, rather than making the choice for them. It gets very complicated to explain very quickly though.
Some of the prototype use cases we've thought of are:
1. Storing an encryption key on the Secure Element and using it to
encrypt/decrypt email credentials so that we no longer store them in
the clear.
2. Creating a generic key store Secure Element applet and allowing
other apps to generate and store the keys on the Secure Element
instead of on the flash.
3. Implementing a shared secret + time one-time-password applet for
the Secure Element and using that for two-factor auth.
_______________________________________________
dev-b2g mailing list
dev...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g
FYI, we discussed cross-origin service workers last week at the face-to-face meeting:
https://blog.wanderview.com/blog/2015/07/28/service-worker-meeting-highlights/#foreign-fetch
The idea is to permit a service worker to intercept fetch events to its own origin.
- Its more “webby” using HTTP requests instead of RPC-like messags.
- As a consequence its easy to provide offline support for REST APIs build on top of HTTP verbs like GET and POST.
- Its progressive. If a browser does not support this new system, then the requests simply go to the server as they used to.