Skip to content

fix(everything): require key parameter for get-env tool to prevent env leakage#4011

Closed
Will-hxw wants to merge 4 commits intomodelcontextprotocol:mainfrom
Will-hxw:fix/3986-get-env-security
Closed

fix(everything): require key parameter for get-env tool to prevent env leakage#4011
Will-hxw wants to merge 4 commits intomodelcontextprotocol:mainfrom
Will-hxw:fix/3986-get-env-security

Conversation

@Will-hxw
Copy link
Copy Markdown

Summary

  • Change get-env inputSchema from empty object {} to require a key parameter; returns only the specified environment variable value instead of full process.env

Why

Issue #3986: get-env tool returns the entire process.env object without any parameters, potentially leaking all environment variables including API keys and tokens.

Validation

  • Syntax check passed
  • Fix pushed to fork

Will-hxw and others added 4 commits April 21, 2026 04:33
Prevent leaking all process.env variables by requiring a specific key.
This addresses a security concern where the tool was returning the
entire environment without any parameter or filtering.

Issue: #3986

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The get-env tool was failing TypeScript strict mode checks because
the inputSchema was declared as a plain object with 'type: string'
instead of a Zod schema. This causes the type checker to reject
the argument.

Fixes TypeScript errors:
- TS2345: inputSchema type not assignable to parameter type
- TS7006: Parameter 'args' implicitly has an 'any' type
The get-env tool now requires a 'key' parameter. Updated tests to
pass { key: 'TEST_VAR_EVERYTHING' } and { key: 'PATH' } instead
of empty object {}.
The get-env tool returns 'KEY=value' format, not JSON.
Updated assertions accordingly.
@Will-hxw Will-hxw closed this by deleting the head repository Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant