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

mutually recursive discharge macaroons cause infinite recursion #40

Closed
rogpeppe opened this issue Sep 14, 2017 · 2 comments
Closed

mutually recursive discharge macaroons cause infinite recursion #40

rogpeppe opened this issue Sep 14, 2017 · 2 comments

Comments

@rogpeppe
Copy link
Contributor

The following code causes a RuntimeError exception to be raised due to infinite recursion:

import pymacaroons
import base64

m1 = pymacaroons.Macaroon(location="", identifier="root-id", key="root-key")
m1.add_third_party_caveat("bob",  "bob-caveat-root-key", "bob-is-great")
m2 = pymacaroons.Macaroon(location="bob", identifier="bob-is-great", key="bob-caveat-root-key")
m2.add_third_party_caveat("charlie", "bob-caveat-root-key", "bob-is-great")
m2 = m1.prepare_for_request(m2)
pymacaroons.Verifier().verify(m1, "root-key", [m2])

An attacker could use this as a denial-of-service attack.

@ecordell
Copy link
Owner

Thanks for noticing this! This is definitely a major problem (assuming separate parties are issue the root/discharge macaroons).

How does libmacaroons handle this case? Disallow cycles or allow them but detect them and move on?

@rogpeppe
Copy link
Contributor Author

Both libmacaroons and my Go macaroons package fail gracefully on cycles. libmacaroons makes sure that the number of used macaroons doesn't exceed the provided number of discharges. The Go macaroon package ensures that the use count of every discharge macaroon is exactly one (and fails immediately if the count goes above one).

See also rescrv/libmacaroons#48 (comment)

ecordell added a commit that referenced this issue Jan 8, 2019
used more than once. This prevents an infinite recursion on a discharge
that requires itself.

This is a breaking change to the python verifier API, but not to the
macaroon protocol API.

fixes #40
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

2 participants