Skip to content

SEC-07: the access-token check reads Keycloak's typ claim, not the RFC 9068 typ header, and accepts a token with no typ #184

Closed
1 of 1 issue completed

Description

@ephico2real2

Part of #14

What is wrong: cmapi decides that a token is an access token from Keycloak's typ claim in the payload (Bearer). It does not read the typ of the JOSE header. RFC 9068 (JWT Profile for OAuth 2.0 Access Tokens), section 4: the resource server "MUST verify that the "typ" header value is "at+jwt" or "application/at+jwt"" and must "reject tokens carrying any other value". A token with no typ claim passes today's check.

Where: cmapi/src/cmapi/core/auth.py:168-170 on b83391c: if claims.get("typ") not in (None, "Bearer").

How to prove it: A test signs a token that has the right issuer, audience and key, and no typ claim, as an ID token of another issuer profile can have. Today Authenticator.authenticate accepts it. After the fix the token is refused with 401, or the pull request shows why cmapi cannot ask for more from Keycloak and what else stops an ID token (the audience check).

Measured or inferred: Read from the code on 2026-11-13. Not tested against a real Keycloak token: realm cmapi is not on CRC yet. The contracts review of diagram-kit PR 64 found it.

Severity: Medium, until the research says what Keycloak 26 puts in the header.

What must hold after the fix: cmapi refuses a token that is not an access token, by a rule that is written down with its source. Where cmapi differs from RFC 9068, docs/14 says so and why.

Research: Mandate, before the code: (1) what typ RHBK 26.6 puts in the JOSE header of an access token (historically JWT, with typ: Bearer in the payload), and whether a realm or client setting makes it at+jwt. Read the Keycloak source or its documents for 26.x, and measure a token from the realm test of deploy/tests/realm-test.py when containers are permitted again (#157). (2) RFC 9068 section 4 and RFC 8725 section 3.11 (explicit typing). (3) What stops an ID token today: its audience is the client, not cmapi-<instance>. Options: require the claim typ to be Bearer (no None), accept the header at+jwt also, or make the accepted values configuration of the Authenticator in instance.yaml.

Solution (inline, not applied): Not written here.

Class: INV. The fix adds a check to the token verification.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    bug
    class:INV
    status:open
    sev:medium
    Backlog
    on Nov 13, 2026
  2. added a commit that references this issue on Nov 13, 2026
  3. added
    In-Progress
    and removed
    Backlog
    on Nov 13, 2026
  4. ephico2real2 commented on Nov 13, 2026

    @ephico2real2
    OwnerAuthor

    In-Progress: draft pull request for branch access-token-type. Built: the header check, the legacy setting, the client attribute in the realm files and in the sync, the tests and the documents. The service suite passes natively (637 passed). Codex reviewed seven claims: four confirmed, and five findings (C4, C5, C7, E1, E2) wait for a ruling and their fixes. The realm test on a real Keycloak runs in GitHub's manifests job.

  5. added 2 commits that reference this issue on Nov 13, 2026
  6. added
    Done
    and removed
    In-Progress
    on Nov 13, 2026
  7. ephico2real2 commented on Nov 13, 2026

    @ephico2real2
    OwnerAuthor

    Done: pull request #195 merged to main (9a5a9d6). GitHub Actions run 43521078691 was green on the exact head 079ecf4 (six jobs). The realm test on a real Keycloak passed in the manifests job (realm cases failed: 0): the access token of cmapi-docs, cmapi-automation and svc-payments-ci has the header typ: at+jwt, the token of cmapi-directory has JWT, and the sync puts the attribute back on a realm that has it off. Native on macOS: the service suite 690 passed, and Codex's 36 review cases pass (6 failed before the fixes). Review by Codex gpt-6.1-sol, each finding ruled in docs/reviews/2026-11-13-issue-184/README.md. Not measured: a token exchange (C4 is from Keycloak's source), and anything on CRC: realm cmapi is not there.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Donebugclass:INVsev:mediumstatus:open

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions