Skip to content

6.6 - An API key can mint itself a more powerful key #159

Description

@determined-001

Complexity: Medium - 150 Points · type:security

Milestone: M2 - Multi-tenant platform

Band lever: hold-B (a leaked narrow key reaches seller funds)

Context
apps/api/src/routes/api-keys.ts gates the whole router on the
api-keys:manage scope, then accepts the scopes array from the request body
and issues a key carrying them.

Problem
Nothing checks that the requested scopes are a subset of the calling key's
scopes. Any combination of ALL_SCOPES is accepted, including
offramp:initiate. So a key deliberately issued narrow — say, an integration
key scoped only to api-keys:manage so it can rotate credentials — is
effectively a root key.

The escalation reaches money: POST /links/:id/cash-out accepts a caller-supplied
payoutFields object that overrides the seller's saved payout destination for
that cash-out, with no re-confirmation. Leaked narrow key → self-issued
offramp:initiate key → proceeds redirected.

What needs to be done

  1. In the create-key handler, when the caller is authenticated by API key
    (rather than a browser session), reject any requested scope the calling key
    does not itself hold — 403, naming the offending scopes.
  2. Leave session-authenticated callers able to request any scope: the seller
    logging in with their wallet is the authority the keys derive from.
  3. Consider the same subset rule for any future key-update path.
  4. Tests: narrow key requesting a broader scope is rejected; narrow key
    requesting an equal-or-narrower scope succeeds; session caller is unaffected.

Key files

  • apps/api/src/routes/api-keys.ts:43 — create-key handler
  • apps/api/src/services/api-keys.ts:56 — scope validation
  • apps/api/src/middleware/ — where the auth variables distinguish key vs session
  • apps/api/src/services/link-service.ts:944 — the payoutFields override this protects

Done when

  • A key without offramp:initiate cannot create a key that has it.
  • A wallet-session caller can still issue any scope they own.
  • Regression test covers both arms.

Tracked in ISSUES.md — issue 6.6.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stellar WaveDrips Wave Program - opt an issue in by applying this labelarea:authwallet-native auth + multi-tenancycomplexity:medium150 pointstype:security

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions