Skip to content
IAM Insights

Briefing · Article · source · published · Boston Identity

Macaroons, 2014: bearer tokens any holder can narrow but not widen, checkable only by the service that minted them

In this 2014 NDSS paper, four Google researchers and two university co-authors propose macaroons, bearer credentials with a chained HMAC signature. Any holder can add caveats that narrow what the token allows, and nobody can take one away. The authors concede the main cost themselves: only the service that minted a macaroon can verify it. Their prototype added 470 microseconds a request on 2013 hardware.

NDSS Symposium 2014 (Google Research) · Arnar Birgisson, Joe Gibbs Politz, Úlfar Erlingsson, Ankur Taly, Michael Vrable, Mark Lentczner · February 23, 2014 · read

share
15,831 words. With Arnar Birgisson et al., author, Google; Chalmers; Brown.
01

What's happening

Finding4
BI-FIND-2014-0001Lead finding

Any macaroon holder can add caveats to narrow it and pass it on without asking the issuer, but cannot remove one, because its signature is a chain of HMACs.

A macaroon is a bearer credential whose signature is a chain of HMACs: each caveat added to it is signed with the signature before it, and only the last signature travels with the token. So any holder can narrow a macaroon (to a range of storage chunks, to reads only, to one client IP) and pass it on without asking the issuer, but cannot remove a caveat. A third-party caveat goes further: it needs a separate discharge macaroon from another service, which the authors require to be bound to the authorizing macaroon before it is sent, so it cannot be replayed elsewhere.

high confidencebest source: vendor, technicalobserved Feb 2014EvidenceSection 2Section 1
flag a problem with BI-FIND-2014-0001
Figure steps
  1. The storage service mints the macaroon from a random nonce and signs it with its own secret key.
  2. A holder adds a caveat limiting it to chunks 100 to 500. The new signature is an HMAC over the old one, and the old one is dropped.
  3. A second caveat limits it to reads. Only the last signature, 0a..9f, is sent with the token.
  4. The storage service rebuilds the chain from its key and checks it against 0a..9f. No one without that key can check it.
Fig. 1

Each caveat is signed with the signature before it, and only the last signature travels, so a holder can narrow a macaroon but cannot strip a caveat back off.

Drawn from the paper's figure 3Source dated February 23, 2014Passage: Section 2

Swipe for the full figure →

BI-FIND-2014-0002

Only the service that minted a macaroon can check it, the authors say, because verifying needs the secret root key, and that key can also rewrite the macaroon.

The authors name the design's main limit themselves: only the target service that minted a macaroon can check it, because verifying needs the secret root key, and that key can rewrite the macaroon. Against public-key systems such as SPKI/SDSI, they write that macaroons "have no real advantage other than their efficiency and ease of adoption." They sketch a public-key variant but judge it costly, citing 54 milliseconds to generate an RSA key pair against under 3 microseconds for an HMAC.

flag a problem with BI-FIND-2014-0002
BI-FIND-2014-0003

Verifying a macaroon took 69 to 359 microseconds on 2013 hardware, depending on the runtime, and the paper reports no production use.

On 2013 hardware, verifying a macaroon took 69 to 359 microseconds depending on the runtime. In the authors' own image-sharing web app on a local network, checking a macaroon with four caveats added an average of 470 microseconds a request, and discharging third-party login caveats in a browser frame added about 3 milliseconds per image. The app also passed authority down a chain of shrinking lifetimes: one year for the forum service, 15 minutes for the user's browser, 2 seconds for an image-editor frame. The paper reports no production use.

high confidencebest source: vendor, technicalobserved Feb 2014EvidenceMeasurements and discussion
flag a problem with BI-FIND-2014-0003
BI-FIND-2014-0004

The authors say cloud authorization in 2014 rested almost wholly on unconditional bearer tokens, and propose re-issuing cookies and OAuth tokens as macaroons.

The paper's starting point is that cloud authorization in 2014 rested "near exclusively" on pure bearer tokens, secrets that grant unconditional authority: session cookies, API keys, OAuth tokens, SAML or OpenID assertions and unlisted URLs. Public-key certificate systems that could do better had seen little use. The authors propose re-issuing cookies and OAuth 2.0 tokens as macaroons, so a client could bind a cookie to its IP address or a short lifetime and OAuth security guidance could become mandatory caveats. None of these proposals is deployed in the paper.

medium confidencebest source: vendor, technicalobserved Feb 2014EvidenceSection 1Applications: sharing, cookies, OAuth2
flag a problem with BI-FIND-2014-0004
02

Section by section

6

showing 6 of 6

[1]

Why bearer tokens fall short and what macaroons add

Arnar Birgisson et al., Google; Chalmers; Brown

Standards

The authors argue that cloud authorization rests almost entirely on pure bearer tokens such as cookies, API keys and OAuth tokens, while public-key credentials like SPKI/SDSI have seen little use. Macaroons keep the simplicity of a bearer token and add caveats: attenuation, confinement to a context the target checks, and caveats a third party must discharge. Against SPKI/SDSI they claim no advantage beyond efficiency and ease of adoption.

technical artifactfrom published text + figures

[2]

Chained-HMAC construction, caveats and operations

Arnar Birgisson et al., Google; Chalmers; Brown

Standards

A macaroon is an identifier, caveat list and a terminal HMAC signature chained over each caveat, so a holder can add caveats but not remove them. Third-party caveats embed an encrypted root key; a discharge macaroon proves holder-of-key and must be bound to the authorizing macaroon to stop replay to other services. Pseudocode gives Create, AddCaveat, PrepareForRequest, Verify.

technical artifactfrom published text + figures

[3]

Security and expressiveness, limits of HMAC

Arnar Birgisson et al., Google; Chalmers; Brown

Standards

Security of the chained MAC is sketched from HMAC unforgeability, with outside proofs (López-Alt) cited and the need for authenticated encryption on caveat identifiers noted. Macaroons are claimed at least as expressive as SPKI/SDSI. Main limit: only the minting target can verify, since verification needs the root key.

technical artifactfrom published text

[4]

Implementation concerns: key ids, root keys, revocation, local discharge

Arnar Birgisson et al., Google; Chalmers; Brown

Standards

Practical guidance from prototypes: encode key identifiers by database index or encryption, derive caveat root keys unpredictably (e.g. HMAC of the signature and a nonce), avoid root-key reuse across targets, discharge caveats locally in browser frames, revoke by short lifetimes, version targets, and consider disjunctive caveats. Negation is advised only at predicate level.

technical artifactfrom published text

[5]

Applications: sharing, cookies, OAuth2

Arnar Birgisson et al., Google; Chalmers; Brown

Standards

The authors propose three uses. Unlisted sharing URLs would carry a third-party caveat naming a group. Cookies issued as macaroons would let a client bind a cookie to its IP address or a short lifetime, so a stolen one is worth less. OAuth 2.0 tokens recast as macaroons would turn security guidelines into mandatory caveats. The paper reports no deployment of any of them.

opinionfrom published text

[6]

Measurements and discussion

Arnar Birgisson et al., Google; Chalmers; Brown

Standards

The authors timed their code on a 2.33 GHz Core2 machine with Python 2.7, Chrome 27 and Node 0.10. A native HMAC-SHA-256 took under 3 microseconds, against 458 microseconds to sign with RSA and 54 milliseconds to make an RSA key pair, and verifying a macaroon took 69 to 359 microseconds. Their image-sharing prototype added 470 microseconds a request on a local network and about 3 milliseconds for third-party discharges. They contrast this with OAuth 2.0's coarse, long-lived tokens.

technical artifactfrom published text + figures

Terms used

Macaroons
Bearer credentials that can be attenuated by chained HMAC caveats without contacting the issuer.
Bearer token
A token that works for whoever holds it, so a stolen copy can be replayed until it expires.
HMAC
Hash-based message authentication code (HMAC): a keyed hash that proves a message came from someone holding a shared secret; both sides use the same key, so it cannot prove which of them signed.
SPKI/SDSI
Simple Public Key Infrastructure (SPKI) and Simple Distributed Security Infrastructure (SDSI): a certificate model (RFC 2693) that binds authorization to keys rather than names.
API key
A long-lived secret string that lets software call a service; anyone who copies it can use it until someone revokes it.
OAuth
The web's standard framework for delegated authorization — letting one application act at another on a user's (or machine's) behalf without sharing passwords.
SAML
Security Assertion Markup Language (SAML): an XML-based (Extensible Markup Language) standard for single sign-on, in which an identity provider sends signed assertions about a user to an application.
HMAC-SHA-256
Hash-based message authentication code (HMAC) built on the SHA-256 (Secure Hash Algorithm, 256-bit) hash: it combines a shared secret key with the hash to check message integrity and possession of that key.

Cited in our columns

Read next

Was this briefing useful?

Share this briefing

Every finding, forecast and open question on this site has a permanent ID. If we reword one, its ID stays the same, so a citation keeps pointing to the same claim.

Follow us on LinkedInRSS feed

Working on an identity problem this research touches? Talk to Boston Identity