Background
From a conversation on here quite some time ago we were talking about security when one loses their Blockstack account or lost their phone with their Blockstack / dApps logged in. I think a solution for this would be quite important, and while a session manager for Browser is something more akin to making another type of browser (which I’m working on), a session manager for Apps could certainly be created with what we have already.
The biggest thing that Blockstack gives apps is a private key to use for Gaia among other things. If this is able to be revoked, in a sense, then the app is unable to access the user’s data anymore. However, these private keys are used for many things within the app, and this would be taking a step backwards; forwards would be allowing the app to specify whatever private key they want, not changing it on the fly.
However, with the addition of Association Tokens in the Gaia v1(.3) authentication scheme, we are now able to track what user ID the app is tied to, along with an extra token to put information in that which the App never touches.
Proposal
My proposal would be to add an app-sessions.json
to the root gaia hub of a particular user (in the same “folder” as the profile.json
). This file would be of the following schema:
[
{
childToAssociate: "compressed public key in hex of the app",
exp: 1549745395,
sid: "UUIDv4"
}
]
(this is basically the association token but using a session id (sid
) instead of a salt (why do we have salt in there?), along with the lack of an iss
since that is simply the root bucket address)
The sid
field would have to be added to the association token. Optionally, the token (and schema) could also include a (short) friendly name such as the app domain in a desc
or tag
field, so when users need to reject certain sessions they know which ones they are dealing with.
The browser would update this file every time an app session is added, or a session is removed (or periodically cleaned via the expiration date). The Gaia Hub, if it detects an association token with a sid
, could then check the app-sessions.json
file in the iss
uer’s root bucket to make sure the session hasn’t been revoked.
Summary & Takeaway:
Problems that would be solved:
- Apps would no longer be able to access the user’s data if their session is revoked
- this curbs rogue apps and those that are logged in on devices which are lost
Changes that would occur:
- Add a session ID (
sid
) to the Gaia Association Token - Add an
app-sessions.json
file to the user’s root Gaia bucket - Make the Gaia Hub check the Association Tokens which have a
sid
against the issuer’sapp-sessions.json
file to make sure it’s not allowing access to a revoked app session - Make the browser handle sessions in its UI and authentication steps
Recommended but optional items:
- Apps should check to see why they were revoked from the Gaia Hub, and if they no longer have an active session they should “log out” by themselves. Perhaps this could be done by the error response sent by the Gaia Hub when it detects they have a bad session?
Discussion items:
- If two browsers are authenticating apps at the same time, one will override the other in the
session.json
“POST race” to Gaia Hub. This isn’t a huge issue but it’s something to consider - The user should also be able to specify whether or not they require apps to use an Association Token (especially with this feature).
- I honestly don’t know how this will work outside of a full deprecation for apps that don’t use association tokens at all – and how do we force apps to use association tokens when they are optional? They have their own private/public key to use on the Gaia Hub, so if there’s no address limiting then is there any way to stop them from pretending to be “dumb” apps or even users?
Edits / Addendums
The app-sessions.json
could also have the following extra metadata inside of each entry for more security and ease of use:
[
{
"appDomain": "app.domain.com",
"browserId": "UUIDv4",
"desc": "signed by blockstack.browser.org on chrome, win64",
"signature": "jwt style signature of the signed entry"
}
]
-
appdomain
: Lists the app domain so it’s easier to see where the token belongs (or should belong) -
browserId
: Lists the browserId so if a browser session is compromised all tokens from the listed browserId could be revoked. -
desc
: A user friendly description generated by the browser -
signature
: A signature generated from the data by the browser to make sure the data isn’t tampered with
All of these additional fields would be generated by the browser and only used by the browser (would not be inside the association token at all!), except for the signature
field, which could be additionally used by the GaiaHub to make sure the specific entry it is testing against hasn’t been tampered with. Technically it could also use the appDomain
field if it was in “strict” mode, only allowing the token to be used from the specific domain, but that is probably too strict.