René's URL Explorer Experiment


Title: [Security] Harden CLI dev command against injection on Windows by RinZ27 · Pull Request #1904 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: [Security] Harden CLI dev command against injection on Windows by RinZ27 · Pull Request #1904 · modelcontextprotocol/python-sdk

X Title: [Security] Harden CLI dev command against injection on Windows by RinZ27 · Pull Request #1904 · modelcontextprotocol/python-sdk

Description: I was looking through the CLI code and spotted a potential security risk when using the mcp dev command on Windows. Because shell=True is required for npx, passing raw arguments can lead to command injection if a user provides a file path containing shell metacharacters. I decided to use shlex.quote to sanitize these arguments before they are joined into the final command string. This way, I ensure that any special characters are safely escaped, keeping the execution restricted to the intended command. I've verified the fix and it correctly handles paths with spaces and other characters.

Open Graph Description: I was looking through the CLI code and spotted a potential security risk when using the mcp dev command on Windows. Because shell=True is required for npx, passing raw arguments can lead to command...

X Description: I was looking through the CLI code and spotted a potential security risk when using the mcp dev command on Windows. Because shell=True is required for npx, passing raw arguments can lead to command...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/1904

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a869aecb-9e11-6973-9a29-b386e27e6dd4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9B22:10B6B6:A6F7335:DDD033E:696E21C9
html-safe-nonce40e57c9bc0e76b744b77a0cef0484dc010a8ae9e0e3afd8038a441c7be45f1e2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjIyOjEwQjZCNjpBNkY3MzM1OkRERDAzM0U6Njk2RTIxQzkiLCJ2aXNpdG9yX2lkIjoiODAzMjg5MjIzMDQyNDIwNzgxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac865951df795e0063c27ed674d5c71697ca35bc324427a23b2fe4e5a358933ebe
hovercard-subject-tagpull_request:3184015299
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/1904/files
twitter:imagehttps://avatars.githubusercontent.com/u/222222878?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/222222878?s=400&v=4
og:image:altI was looking through the CLI code and spotted a potential security risk when using the mcp dev command on Windows. Because shell=True is required for npx, passing raw arguments can lead to command...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None2fbe8cba5e260284c10af515699ff9bb2d6ace05ab6c2e2e585b71d93b2812c3
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7fb3bc5c995a876085291706b75cf9b08900c338
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F1904%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F1904%2Ffiles
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
Reloadhttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
Reloadhttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
modelcontextprotocol https://patch-diff.githubusercontent.com/modelcontextprotocol
python-sdkhttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3k https://patch-diff.githubusercontent.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 21.2k https://patch-diff.githubusercontent.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk
Issues 239 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/issues
Pull requests 94 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pulls
Actions https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/actions
Projects 0 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/projects
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/security
Please reload this pagehttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
Insights https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pulse
Code https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk
Issues https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/issues
Pull requests https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pulls
Actions https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/actions
Projects https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/projects
Security https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/security
Insights https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
RinZ27https://patch-diff.githubusercontent.com/RinZ27
modelcontextprotocol:mainhttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/tree/main
RinZ27:fix/windows-command-injection-v2https://patch-diff.githubusercontent.com/RinZ27/python-sdk/tree/fix/windows-command-injection-v2
Conversation 0 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904
Commits 1 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/commits
Checks 23 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/checks
Files changed 1 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
[Security] Harden CLI dev command against injection on Windows https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#top
Show all changes 1 commit https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
15a6166 [Security] Fix potential command injection on Windows in CLI dev command RinZ27 Jan 17, 2026 https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/commits/15a61662fccc548dbaf14e717028d948843fde06
Clear filters https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
Please reload this pagehttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
Please reload this pagehttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files
src/mcp/cli/cli.pyhttps://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#diff-ed6a22760239e76508d462209c10b7f07612896965b7808478261a9c529b796e
View file https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/blob/15a61662fccc548dbaf14e717028d948843fde06/src/mcp/cli/cli.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/{{ revealButtonHref }}
https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#diff-ed6a22760239e76508d462209c10b7f07612896965b7808478261a9c529b796e
https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#diff-ed6a22760239e76508d462209c10b7f07612896965b7808478261a9c529b796e
https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#diff-ed6a22760239e76508d462209c10b7f07612896965b7808478261a9c529b796e
https://patch-diff.githubusercontent.com/modelcontextprotocol/python-sdk/pull/1904/files#diff-ed6a22760239e76508d462209c10b7f07612896965b7808478261a9c529b796e
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.