René's URL Explorer Experiment


Title: Python: model MCP server handler parameters (`mcp`, `fastmcp`) as remote sources · Issue #22702 · github/codeql · GitHub

Open Graph Title: Python: model MCP server handler parameters (`mcp`, `fastmcp`) as remote sources · Issue #22702 · github/codeql

X Title: Python: model MCP server handler parameters (`mcp`, `fastmcp`) as remote sources · Issue #22702 · github/codeql

Description: Description of the issue MCP (Model Context Protocol) servers expose tools to LLM agents. Every parameter of a tool, resource or prompt handler is chosen by the model, which prompt injection can steer, or by any client that can reach the...

Open Graph Description: Description of the issue MCP (Model Context Protocol) servers expose tools to LLM agents. Every parameter of a tool, resource or prompt handler is chosen by the model, which prompt injection can st...

X Description: Description of the issue MCP (Model Context Protocol) servers expose tools to LLM agents. Every parameter of a tool, resource or prompt handler is chosen by the model, which prompt injection can st...

Opengraph URL: https://github.com/github/codeql/issues/22702

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python: model MCP server handler parameters (`mcp`, `fastmcp`) as remote sources","articleBody":"**Description of the issue**\n\nMCP (Model Context Protocol) servers expose tools to LLM agents. Every parameter of a tool,\nresource or prompt handler is chosen by the model, which prompt injection can steer, or by any\nclient that can reach the server over HTTP. That makes these parameters remote input. CodeQL\nhas no models for the Python MCP SDKs, so in an MCP server the security queries have no source to\nstart from.\n\n**Evidence.** [mcp-vulnbench](https://github.com/Alex-Hofer/mcp-vulnbench) pins real, publicly\ndisclosed vulnerabilities in open-source Python MCP servers as vulnerable/fixed commit pairs with\nfunction-level ground truth. It covers command injection, path traversal, SSRF, SQL injection and\ncode injection.\n- With the `security-extended` suite, CodeQL 2.27.1 detects 1 of 26 cases in v0.1.0, and that\n  single hit comes from `py/shell-command-constructed-from-input` through its library-input source.\n- Example misses:\n  - CVE-2025-68144: argument injection in `mcp-server-git`'s `git_diff`;\n  - CVE-2026-43901: path traversal in Wireshark-MCP;\n  - CVE-2026-57496: SSRF in NetLicensing-MCP.\n- With the prototype models below (v0.2.0), the same CodeQL finds 13 of 28 cases. The models were\n  written on a development half of 12 cases and frozen before the other 16 were measured; on that\n  held-out half CodeQL goes from 0 to 9 detected cases (56 %), at 0.27 to 1.09 alarms per KLOC.\n  A detection means a finding of the right class inside a function the fix changed or the sink\n  function; nothing CodeQL found before is lost. Details:\n  [docs/results-v0.2.0.md](https://github.com/Alex-Hofer/mcp-vulnbench/blob/main/docs/results-v0.2.0.md).\n\n**Proposal.** Source models of kind `remote` as Models-as-Data in\n`python/ql/lib/semmle/python/frameworks/`, next to the existing `Stdlib.model.yml` sources and the\n`openai`/`anthropic` sink models, plus `typeModel` rows for the import aliases. With them the\nexisting queries work unchanged and interprocedurally:\n`py/command-line-injection`, `py/path-injection`, `py/full-ssrf`, `py/code-injection` and\n`py/sql-injection`. Coverage:\n- `mcp` 1.x `FastMCP`: `tool()`, `resource()`, `prompt()`, `add_tool(fn)`.\n- `mcp` 2.x `MCPServer` (the renamed FastMCP): the same entry points.\n- The low-level `Server`, two generations:\n  - 1.x decorators `call_tool()`, `read_resource()`, `get_prompt()`;\n  - 2.x constructor handlers `on_call_tool` and friends, where `params.arguments` / `params.uri`\n    is the source.\n- `fastmcp` 2.x–4.x:\n  - `tool` and `prompt` (bare, called or as a plain call), `resource()`;\n  - `add_tool`, `add_prompt`, `Tool.from_function`, `fastmcp.tools.tool`;\n  - the transport headers via `get_http_headers()` and `get_http_request().headers`.\n- Both SDKs: the bearer token of the `Authorization` header, where token verifiers receive it\n  (`verify_token` in subclasses of `TokenVerifier`, and of `AuthProvider` in `fastmcp`) and through\n  `get_access_token().token`. Real servers build file paths and queries from it.\n\nA prototype pack with a test fixture (one handler per row) is in\n[models/codeql/mcp](https://github.com/Alex-Hofer/mcp-vulnbench/tree/main/models/codeql/mcp):\n- without the models the fixture has 0 alerts, with them every expected alert appears;\n- documented limits:\n  - Pydantic-typed parameters (attribute reads are not taint steps; a QL model like the one for\n    FastAPI's Pydantic parameters would cover them);\n  - headers read through the `Context` object;\n  - handlers behind a project decorator (auth or error handling), which is common in real\n    servers. With `functools.wraps` the API graph loses the handler. Without it, the source\n    lands on the wrapper, and the call `func(*args, **kwargs)` does not lead back to the\n    handler. The Flask and FastAPI modeling avoids this by reading the decorator list\n    (`result.getADecorator()`).\n\nThe library test would follow `library-tests/frameworks/asyncpg/MaDTest.ql`: a `MaDTest.ql`\nimporting `experimental.meta.MaDTest`, and a fixture where every row has a handler with a\n`# $ mad-source__remote=...` expectation.\n\n**One observation while preparing this.** Data-extension sources are `ThreatModelSource`s but not\n`RemoteFlowSource`s. Three stable queries, `py/nosql-injection`, `py/xml-bomb` and `py/xxe`, take\n`RemoteFlowSource` directly, while the other security customizations take\n`ActiveThreatModelSource`. Remote sources from data extensions therefore never reach those three\nqueries. I checked this with CodeQL 2.27.1 (`security-extended`) on a small file:\n- the same three sinks, once fed from a Flask request and once from an MCP tool parameter\n  (a data-extension source of kind `remote`);\n- a control where the MCP parameter reaches `os.system`.\n\nThe Flask variants alert (`py/xxe`, `py/xml-bomb`, `py/nosql-injection`) and so does the control\n(`py/command-line-injection`). The MCP variants of the three queries stay silent.\n\n\u003cdetails>\u003csummary>Reproducer\u003c/summary>\n\n```python\nimport os\nimport xml.etree.ElementTree as ET\n\nimport pymongo\nfrom flask import Flask, request\nfrom lxml import etree\nfrom mcp.server.fastmcp import FastMCP\n\nmcp = FastMCP(\"probe\")\napp = Flask(__name__)\nusers = pymongo.MongoClient().db.users\n\n\n# MCP tool parameters: MaD sources of kind remote\n@mcp.tool()\ndef mcp_xxe(xml: str) -> str:\n    parser = etree.XMLParser(resolve_entities=True)\n    return str(etree.fromstring(xml, parser=parser))  # MCP-XXE\n\n\n@mcp.tool()\ndef mcp_bomb(xml: str) -> str:\n    return ET.fromstring(xml).tag  # MCP-BOMB\n\n\n@mcp.tool()\ndef mcp_nosql(name: str) -> str:\n    return str(list(users.find({\"$where\": \"this.name == '\" + name + \"'\"})))  # MCP-NOSQL\n\n\n@mcp.tool()\ndef mcp_shell(command: str) -> int:\n    return os.system(command)  # MCP-SHELL (control: the models are active)\n\n\n# Flask request data: RemoteFlowSource, the control for the three queries\n@app.route(\"/xxe\")\ndef flask_xxe():\n    parser = etree.XMLParser(resolve_entities=True)\n    return str(etree.fromstring(request.args[\"xml\"], parser=parser))  # FLASK-XXE\n\n\n@app.route(\"/bomb\")\ndef flask_bomb():\n    return ET.fromstring(request.args[\"xml\"]).tag  # FLASK-BOMB\n\n\n@app.route(\"/nosql\")\ndef flask_nosql():\n    name = request.args[\"name\"]\n    return str(list(users.find({\"$where\": \"this.name == '\" + name + \"'\"})))  # FLASK-NOSQL\n```\n\n\u003c/details>\n\n**Questions**\n1. Is Models-as-Data the form you prefer here? A QL module (`semmle/python/frameworks/Mcp.qll`)\n   could also:\n   - find handlers behind project decorators through the decorator list, as `Flask.qll` does;\n   - cover Pydantic-typed parameters;\n   - reach the three queries above.\n   In the benchmark's development half, 2 of 8 misses are servers with such decorators.\n2. Is `remote` the right threat-model kind? Over stdio the input comes from the local client\n   process, but its content is chosen by an LLM that reads remote content.\n3. Should the three queries above move to `ActiveThreatModelSource`? I can do that in a separate PR.\n\nI'm happy to open a PR with the models, the library test and a change note.\n","author":{"url":"https://github.com/Alex-Hofer","@type":"Person","name":"Alex-Hofer"},"datePublished":"2026-09-30T02:48:23Z","url":"https://github.com/github/codeql/issues/22702"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1a022ab3-8236-787d-30ec-dddd88aa068f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAAE8:38057F:AA9011:EBD2BF:6AF98F09
html-safe-nonced8380dadb81d0f3e719c7245ff673caa09254a3578537a28a886ac4c4455f4c4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUU4OjM4MDU3RjpBQTkwMTE6RUJEMkJGOjZBRjk4RjA5IiwidmlzaXRvcl9pZCI6IjgxODE5Njc3MDYzMjA4OTk4NDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac98127242c35948a99f812a1446c74679a53405e97b15f12623e593c5dcc6967f
hovercard-subject-tagissue:5640094952
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/codeql/22702/issue_layout
twitter:imagehttps://opengraph.githubassets.com/265b00a316c5283c0001e8b20c98090b736ef7e1560714393a71d57457332880/github/codeql/issues/22702
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/265b00a316c5283c0001e8b20c98090b736ef7e1560714393a71d57457332880/github/codeql/issues/22702
og:image:altDescription of the issue MCP (Model Context Protocol) servers expose tools to LLM agents. Every parameter of a tool, resource or prompt handler is chosen by the model, which prompt injection can st...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAlex-Hofer
hostnamegithub.com
expected-hostnamegithub.com
None612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7
turbo-cache-controlno-preview
go-importgithub.com/github/codeql git https://github.com/github/codeql.git
octolytics-dimension-user_id9919
octolytics-dimension-user_logingithub
octolytics-dimension-repository_id143040428
octolytics-dimension-repository_nwogithub/codeql
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id143040428
octolytics-dimension-repository_network_root_nwogithub/codeql
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release072e34035c13c31543fba9f025cbbbda4210dae4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/github/codeql/issues/22702#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fissues%2F22702
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgithub%2Fcodeql%2Fissues%2F22702
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=github%2Fcodeql
Reloadhttps://github.com/github/codeql/issues/22702
Reloadhttps://github.com/github/codeql/issues/22702
Reloadhttps://github.com/github/codeql/issues/22702
githubhttps://github.com/github
codeqlhttps://github.com/github/codeql
Codehttps://github.com/github/codeql
Issues1k (1k)https://github.com/github/codeql/issues
Pull requests516 (516)https://github.com/github/codeql/pulls
Discussionshttps://github.com/github/codeql/discussions
Actionshttps://github.com/github/codeql/actions
Projectshttps://github.com/github/codeql/projects
Security and qualityhttps://github.com/github/codeql/security
Insightshttps://github.com/github/codeql/pulse
https://github.com/github/codeql
New issuehttps://github.com/login?return_to=https://github.com/github/codeql/issues/22702
New issuehttps://github.com/login?return_to=https://github.com/github/codeql/issues/22702
Python: model MCP server handler parameters (mcp, fastmcp) as remote sourceshttps://github.com/github/codeql/issues/22702#top
https://github.com/Alex-Hofer
Alex-Hoferhttps://github.com/Alex-Hofer
on Sep 30, 2026https://github.com/github/codeql/issues/22702#issue-5640094952
mcp-vulnbenchhttps://github.com/Alex-Hofer/mcp-vulnbench
CVE-2025-68144https://github.com/advisories/GHSA-9xwc-hfwc-8w59
CVE-2026-43901https://github.com/advisories/GHSA-3r68-x3xc-rxpg
CVE-2026-57496https://github.com/advisories/GHSA-hxpf-9xvq-wph8
docs/results-v0.2.0.mdhttps://github.com/Alex-Hofer/mcp-vulnbench/blob/main/docs/results-v0.2.0.md
models/codeql/mcphttps://github.com/Alex-Hofer/mcp-vulnbench/tree/main/models/codeql/mcp
https://github.com/jketema
jketemahttps://github.com/jketema
on Sep 30, 2026https://github.com/github/codeql/issues/22702#issuecomment-5912454884
@Alex-Hoferhttps://github.com/Alex-Hofer
https://github.com/Alex-Hofer
Alex-Hoferhttps://github.com/Alex-Hofer
on Oct 3, 2026https://github.com/github/codeql/issues/22702#issuecomment-5973469576
#22749https://github.com/github/codeql/pull/22749
mcp-vulnbench v0.5.0https://github.com/Alex-Hofer/mcp-vulnbench/releases/tag/v0.5.0
https://github.com/Alex-Hofer
Alex-Hoferhttps://github.com/Alex-Hofer
on Oct 4, 2026https://github.com/github/codeql/issues/22702#issuecomment-5979759037
#22750https://github.com/github/codeql/pull/22750
#22703https://github.com/github/codeql/pull/22703
#22750https://github.com/github/codeql/pull/22750
#22750https://github.com/github/codeql/pull/22750
#22703https://github.com/github/codeql/pull/22703
#22703https://github.com/github/codeql/pull/22703
@Tito0015https://github.com/Tito0015
docs/comparison-codeql-22750.mdhttps://github.com/Alex-Hofer/mcp-vulnbench/blob/main/docs/comparison-codeql-22750.md
#22750https://github.com/github/codeql/pull/22750
Sign up for freehttps://github.com/signup?return_to=https://github.com/github/codeql/issues/22702
Sign in to commenthttps://github.com/login?return_to=https://github.com/github/codeql/issues/22702
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.