MCP07
- Location
plugin/dist/src/tools/common/files.js:208- Finding
Unrestricted Local File Upload Can Disclose Gateway-Owned Sensitive Files ## Remediation Suggestions 1. **Replace model-selected filesystem paths with trusted attachment identifiers.** Resolve opaque attachment IDs through gateway-managed metadata rather than accepting arbitrary `filePath` values. 2. **Enforce attachment ownership and provenance.** Bind each uploadable attachment to its sender, session, and authorized workflow. Reject files without a matching trusted record. 3. **Restrict filesystem access if path support is unavoidable.** - Use a dedicated attachment directory. - Canonicalize the permitted root and candidate path, then enforce path-aware containment. - Reject symbolic-link escapes. - Use platform-appropriate symlink-safe opening and verify the opened file descriptor to reduce check-to-read race conditions. - Do not rely on string-prefix checks or file-extension validation as authorization. 4. **Require trusted approval for exceptional exports.** Any upload outside the authorized attachment set should require host-enforced approval bound to the specific file and destination, not merely an instruction in the tool description. 5. **Reduce exposure and resource consumption.** Run the gateway with least-privilege filesystem access, apply upload-size limits, and restrict outbound destinations to approved backend origins. 6. **Add regression tests.** Verify rejection of configuration files outside the attachment root, symlink escapes, cross-session attachments, unregistered paths, and oversized files. Confirm that legitimate caller-owned attachments still upload successfully.
- Content
View full analysis
Vulnerability Details
File Location:
plugin/dist/src/tools/common/files.js:178–230— model-controlled path handling, filesystem access, and upload invocation.plugin/dist/src/tools/common/files.js:108–133— authenticated multipart transmission.plugin/dist/index.js:33–35— registration of the exposed upload tool.
Vulnerability Type: Externally Controlled File Path Leading to Sensitive Information Disclosure — CWE-73 / CWE-200
Risk Level: High
Confidence: High for the unrestricted read-and-upload capability; attacker retrieval from storage depends on backend access controls.Technical Analysis
The model-exposed
common-file-uploadtool accepts a filesystem path supplied through tool arguments:js const filePath = typeof params?.filePath === "string" ? params.filePath.trim() : "";Execution validates the caller's channel identity and backend configuration, then checks that the selected path is a nonempty regular file. These checks do not establish that the file belongs to the caller or originated from an attachment in the current conversation.
The file is then read and packaged for transmission. The following complete read-and-package segment occurs at
plugin/dist/src/tools/common/files.js:208–211:js const fileBuffer = await fsp.readFile(filePath); const fileBlob = new Blob([fileBuffer], { type: contentType }); const formData = new FormData(); formData.append("file", fileBlob, uploadFileName);The upload is initiated at line 230:
js resp = await postFormDataWithAuth({ config, baseUrl, headers: ctxHeaders, timeout }, UPLOAD_FILE_PATH, formData);The multipart helper transmits the supplied contents using the configured backend URL and authentication token:
js const url = `${ctx.baseUrl}${path}`; const headers = withAuthorizationHeader(ctx.headers, token); let resp; try { resp = await fetch(url, { method: "POST", headers, body: formData, signal: AbortSignal. ...[truncated 2846 chars]
