Skip to content

fix: pass host/port via env vars to prevent child process injection#3

Open
Alex647648 wants to merge 1 commit intodimensionalOS:masterfrom
Alex647648:fix/child-process-injection
Open

fix: pass host/port via env vars to prevent child process injection#3
Alex647648 wants to merge 1 commit intodimensionalOS:masterfrom
Alex647648:fix/child-process-injection

Conversation

@Alex647648
Copy link

Summary

  • Replace direct string interpolation of host and port in the child process script with environment variables (MCP_HOST, MCP_PORT)
  • Eliminates any potential script injection vector from plugin config values

Motivation

The discoverToolsSync function interpolated port as a raw number and host via JSON.stringify directly into a Node.js script string passed to execFileSync. While host was escaped, port was not — if the type guard in getPort were bypassed (e.g. via a malformed config), arbitrary code could be injected into the child process.

Using environment variables is inherently safe since they are never evaluated as code.

Test plan

  • Verify tool discovery still works with default and custom host/port
  • Confirm environment variables are correctly read in the child process

…hild process

The discoverToolsSync function previously interpolated host and port
directly into a script string executed via execFileSync. While host
was escaped with JSON.stringify, port was interpolated as a raw number.
If type checking were bypassed, this could allow script injection.

Now both values are passed as environment variables (MCP_HOST, MCP_PORT)
which eliminates any interpolation-based injection risk.
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