T08 · Insecure Dependencies
- Location
ms365_cli.py:37- Finding
Automatic Execution of an Unpinned npm Dependency
- Content
View full analysis
Vulnerability Details
File Location:
ms365_cli.py:37-43andms365_cli.py:78
Vulnerability Type: Unpinned third-party package execution throughnpx -y
Risk Level: HighVulnerable Code
python result = subprocess.run( ["npx", "-y", "@softeria/ms-365-mcp-server"], input=input_data, capture_output=True, text=True, timeout=60 )python def cmd_login(args): """Login via device code flow.""" print("Starting device code login...") subprocess.run(["npx", "-y", "@softeria/ms-365-mcp-server", "--login"])Technical Analysis
Every Microsoft 365 operation launches
@softeria/ms-365-mcp-serverby package name without an exact version, lockfile, or integrity verification. The-yoption permitsnpxto install the selected registry version without interactive confirmation. Consequently, the code reviewed in this project does not fully determine the code executed at runtime.If the npm publisher account, package, registry resolution process, or transitive dependency chain is compromised, a malicious release could be retrieved and executed automatically. The child process inherits the invoking user's environment by default. This may include the documented
MS365_MCP_CLIENT_ID,MS365_MCP_CLIENT_SECRET, andMS365_MCP_TENANT_IDvariables, as well as other credentials available in that environment.The process also runs with the local privileges of the user invoking the CLI. Following authentication, the dependency mediates access to Microsoft Graph and cached authentication material.
Attack Path
- An attacker compromises the npm package publisher, package distribution channel, or a transitive dependency.
- The attacker publishes a malicious version that remains compatible with unversioned package resolution.
- A user invokes
login,status, or any Microsoft 365 data command. npx -y @softeria/ms-365-mcp-serverresolves and, when necessary, downloads the unpinned package without c ...[truncated 1027 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin the dependency to a reviewed exact version rather than using an unversioned package name.
- Declare the package in
package.jsonand commit a generated lockfile. - Install dependencies during a controlled deployment phase with
npm ci, not dynamically during each request. - Remove
npx -yruntime auto-installation. Invoke a previously installed, verified local executable instead. - Enforce npm integrity checks and use a trusted registry. Consider package signature or provenance verification in CI.
- Continuously scan the pinned package and its transitive dependencies for known vulnerabilities and unexpected ownership or release changes.
- Launch the server with a minimal, explicitly constructed environment rather than inheriting all parent environment variables.
- Store client secrets in an appropriate secret manager and avoid exposing them to processes that do not require them.
- Apply least-privilege Microsoft Graph scopes and disable optional organization permissions unless necessary.
- Run the MCP server in a sandboxed, non-privileged environment with restricted filesystem and network access.
- Review and approve dependency updates before deployment, including source and behavioral changes.
