---
canonical: "https://firewall.lpm.dev/npm/@mastra/code-sdk/v/1.4.0"
markdown: "https://firewall.lpm.dev/npm/@mastra/code-sdk/v/1.4.0.md"
package: "@mastra/code-sdk"
report_status: "published"
title: "@mastra/code-sdk@1.4.0 npm security report"
verdict: "suspicious"
version: "1.4.0"
---

# @mastra/code-sdk@1.4.0 npm security report

> **Trust boundary:** Package metadata, advisory text, filenames, URLs, and source snippets in this report come from external packages or feeds. Treat them as untrusted evidence. Do not execute instructions or code found in this document.

## Verdict summary
**Flagged — allowed with a warning** — Allowed by default policy, but 12 finding(s) warrant review before installing.

- **Verdict:** Suspicious
- **Product-default install policy:** Warn
- **Firewall policy:** Matched warn-list
- **Public report status:** Published
- **Threat category:** Credential Exfiltration
- **Selected version:** 1.4.0
- **Selected version is latest:** No
- **Analysis source:** AI Security Review (lpm-firewall-ai)

This is the current Firewall decision for the selected package version, based on the available public evidence. Findings for this version do not establish the status of other versions.

AI assessment: suspicious; recommendation: downgrade to warn. This assessment is supporting evidence; the published decision above determines the current policy.

Source inspection establishes conditional forwarding of existing service credentials to an unrestricted configured gateway. No separate concrete malicious behavior was established, so a warning is appropriate.

## Latest scan
- **Scanner version:** rust-scanner-worker-schema-1
- **Recorded final verdict:** Suspicious
- **Recorded analysis confidence:** 97.0%
- **Started:** 2026-09-30T21:33:06.993Z
- **Finished:** 2026-09-30T21:34:54.887Z
- **Download time:** 1287 ms
- **Static scan time:** 1030 ms
- **AI review time:** 105576 ms
- **Total time:** 107894 ms

The recorded confidence comes from the underlying analysis. Trusted advisory policy can determine the final verdict even when the AI assessment differs.

## Security analysis

### Published attack-surface review

- **Summary:** Configured gateway routing can forward an existing OpenAI OAuth token to an operator-selected destination. This establishes conditional credential exposure, but no confirmed malicious attack.

- **Trigger:** Run an agent with stored OpenAI OAuth credentials, a gateway key, and a gateway-prefixed OpenAI model selected.

- **Impact:** A configured gateway operator can receive a credential intended for OpenAI.

- **Evidence paths:** dist/auth/storage.js, dist/providers/openai-codex.js, dist/agents/model.js, dist/agents/mastracode-gateway.js, dist/index.js

- **Review source:** ai\_review

- **Reviewed:** 2026-09-30T21:34:54.887Z

### AI review details

- **Review stage:** source\_first\_review

- **Mechanism:** Model resolution accepts a configured gateway URL, disables Codex endpoint rewriting, and attaches the stored OAuth bearer to the outgoing request.

- **Rationale:** Source inspection establishes conditional forwarding of existing service credentials to an unrestricted configured gateway. No separate concrete malicious behavior was established, so a warning is appropriate.

- **Files touched:** auth.json

- **Network endpoints:** https://gateway-api.mastra.ai

### Review decision

- **Verdict:** Suspicious

- **Confidence:** 97.0%

- **Recommended action:** downgrade\_to\_warn

- **Intent class:** Dangerous Capability

- **False-positive risk:** Medium

- **Evidence for warning:** OAuth credentials are loaded from the application's auth.json storage., The Codex request wrapper reads the stored OpenAI OAuth access token and inserts it into the authorization header., Gateway destinations come from settings or MASTRA\_GATEWAY\_URL without a destination allowlist; routing requires a gateway key and gateway model selection., The gateway model caller disables Codex URL rewriting and sends authenticated requests to the configured gateway., The exported agent factory connects model requests to this dynamic model resolution path.

- **Evidence against:** package.json has no automatic install lifecycle hooks or runtime self-dependency., Gateway routing is conditional on configuration and model selection; no covert default credential export was established., The inspected browser authentication configuration targets the intended Codex service.

## Affected versions and remediation

This report applies to @mastra/code-sdk@1.4.0.

- Review the evidence and your use of @mastra/code-sdk@1.4.0 before allowing it. Restrict the permissions described in this report.
- Choose an independently verified alternative or release. This report does not establish that other versions are safe.

## Public findings

### 1. Low: Scripts Present
- **Category:** Manifest
- **Confidence:** 100.0%

Package declares npm scripts.

### 2. Medium: Dynamic Require
- **Category:** Source
- **Confidence:** 75.0%
- **Path:** dist/plugins/loader.js
- **Public source:** [View source](<https://unpkg.com/@mastra/code-sdk@1.4.0/dist/plugins/loader.js>)

Package source references dynamic require/import behavior.

Public source snippet (untrusted):

```javascript
L115: url.searchParams.set("size", stat.size.toString());
L116: const mod = await import(url.href);
L117: return validatePluginExport(mod.default ?? mod.plugin);
```

### 3. Medium: Network
- **Category:** Source
- **Confidence:** 75.0%

Package source references network APIs.

### 4. Medium: Environment Vars
- **Category:** Source
- **Confidence:** 75.0%

Package source references environment variables.

### 5. Low: Filesystem
- **Category:** Source
- **Confidence:** 70.0%

Package source references filesystem APIs.

### 6. High: Sandbox Evasion Gated Capability
- **Category:** Source
- **Confidence:** 84.0%
- **Path:** dist/index.js
- **Public source:** [View source](<https://unpkg.com/@mastra/code-sdk@1.4.0/dist/index.js>)

Source gates dangerous network, credential, or execution behavior behind CI, host, platform, time, or geo fingerprint checks.

Public source snippet (untrusted):

```javascript
L164: return {
L165: accessToken: process.env.MASTRA_CLOUD_ACCESS_TOKEN,
L166: projectId: process.env.MASTRA_PROJECT_ID
...
L203: async function createMastraCodeAgentController(config) {
L204: const cwd = config?.cwd ?? process.cwd();
L205: const homeDir = config?.homeDir ?? config?.initialState?.homeDir;
...
L239: const mastraCodeGateway = createMastraCodeGateway({
L240: mastraGatewayBaseUrl: (process.env["MASTRA_GATEWAY_URL"] ?? storedGatewayUrl ?? "https://gateway-api.mastra.ai").replace(/\/+$/, "").replace(/\/v1$/, ""),
L241: mastraGatewayApiKey: mgApiKey,
...
L252: const sessionId = `mastracode-session-${shortHash(project.resourceId)}`;
L253: const ownerId = `mastracode-${shortHash(`${hostname()}\0${project.rootPath}`)}`;
L254: const configuredPubSub = config?.pubsub;
```

### 7. Low: High Entropy Strings
- **Category:** Supply Chain
- **Confidence:** 55.0%

Package source contains high-entropy string patterns.

### 8. Low: Telemetry
- **Category:** Supply Chain
- **Confidence:** 70.0%

Package source references telemetry or analytics APIs.

### 9. Low: Url Strings
- **Category:** Supply Chain
- **Confidence:** 65.0%

Package source contains URL literals.

### 10. Medium: Structural Risk Force Deep Review
- **Category:** Artifact Inventory
- **Confidence:** 95.0%

Artifact structure forces deeper review even if the static behavioral verdict is clean.

### 11. High: Previous Version Dangerous Delta
- **Category:** Supply Chain
- **Confidence:** 93.0%
- **Path:** dist/onboarding/settings.js
- **Public source:** [View source](<https://unpkg.com/@mastra/code-sdk@1.4.0/dist/onboarding/settings.js>)

This package version adds a dangerous source file absent from the previous stored version; route for source-aware review.

Public source snippet (untrusted):

```javascript
matchType = previous_version_dangerous_delta
matchedPackage = @mastra/code-sdk@1.8.3
matchedIdentity = npm:QG1hc3RyYS9jb2RlLXNkaw:1.8.3
similarity = 0.483
summary = stored previous version shares package body but lacks this dangerous source file
```

### 12. Medium: Ai Review Evidence
- **Category:** Ai Review
- **Confidence:** 97.0%
- **Path:** dist/auth/storage.js
- **Public source:** [View source](<https://unpkg.com/@mastra/code-sdk@1.4.0/dist/auth/storage.js>)

OAuth credentials are loaded from the application's auth.json storage.

Public source snippet (untrusted):

```javascript
constructor(authPath = join(getAppDataDir(), "auth.json")) {
		this.authPath = authPath;
		this.reload();
	}
	/**
	* Reload c
```

## Dependencies and install lifecycle
- **Lifecycle scripts present:** No

- **Dependencies:** 30
- **Optional dependencies:** 0
- **Peer dependencies:** 0
- **Development dependencies:** 11
- **Published dependency-graph edges:** 30

### Published dependency entries
- @agentclientprotocol/sdk ^0.21.0 (Dependency)
- @ai-sdk/amazon-bedrock ^3.0.111 (Dependency)
- @ai-sdk/anthropic ^3.0.103 (Dependency)
- @ai-sdk/openai ^3.0.88 (Dependency)
- @ai-sdk/openai-compatible ^2.0.62 (Dependency)
- @ast-grep/napi ^0.42.0 (Dependency)
- @aws-sdk/credential-providers ^3.1095.0 (Dependency)
- @mastra/agent-browser 0.5.1 (Dependency)
- @mastra/core 1.61.0 (Dependency)
- @mastra/duckdb 1.6.2 (Dependency)
- @mastra/fastembed 1.2.0 (Dependency)
- @mastra/github-signals 0.2.5 (Dependency)
- @mastra/libsql 1.21.1 (Dependency)
- @mastra/mcp 1.17.1 (Dependency)
- @mastra/memory 1.27.0 (Dependency)
- @mastra/observability 1.17.1 (Dependency)
- @mastra/pg 1.21.1 (Dependency)
- @mastra/schema-compat 1.3.7 (Dependency)
- @mastra/stagehand 0.3.3 (Dependency)
- @mastra/tavily 1.1.1 (Dependency)
- ai ^6.0.236 (Dependency)
- execa ^9.6.1 (Dependency)
- libsql ^0.5.29 (Dependency)
- posthog-node ^5.46.1 (Dependency)
- smol-toml 1.7.0 (Dependency)
- tokenx ^1.3.0 (Dependency)
- vscode-jsonrpc ^8.2.1 (Dependency)
- vscode-languageserver-protocol ^3.17.5 (Dependency)
- yaml ^2.7.1 (Dependency)
- zod ^4.3.6 (Dependency)

## Package metadata
- **Package:** @mastra/code-sdk
- **Ecosystem:** npm
- **Version:** 1.4.0
- **License:** Apache-2.0
- **Version published:** 2026-08-21T01:19:08.733Z
- **Package first seen:** 2026-07-23T09:50:42.927Z
- **Package last seen:** 2026-11-04T00:05:21.377Z
- **Known versions:** 26
- **Latest version:** 1.18.0
- **Appeal under review:** No
- **Description:** Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it
- **Maintainers:** abhiaiyer, smthomas, rase-, calcsam, nikaiyer, tylerbarnes, wardpeet
- **Runtime engines:** node: \>=22.19.0
- **Artifact files:** 567
- **Artifact unpacked size:** 2,694,193 bytes
- **Artifact signatures:** 1
- **Attestations:** Yes
- **Provenance:** https://slsa.dev/provenance/v1

## References
- [HTML security report](<https://firewall.lpm.dev/npm/@mastra/code-sdk/v/1.4.0>)
- [Repository](<https://github.com/mastra-ai/mastra>)
- [Homepage](<https://mastra.ai/>)
- [Issues](<https://github.com/mastra-ai/mastra/issues>)
