Skip to content

fix(security): validate upload paths to prevent file exfiltration (PM…#296

Merged
gaurav-singh-9227 merged 1 commit into
browserstack:mainfrom
ruturaj-browserstack:PMAA-107-upload-path-traversal-fix
May 18, 2026
Merged

fix(security): validate upload paths to prevent file exfiltration (PM…#296
gaurav-singh-9227 merged 1 commit into
browserstack:mainfrom
ruturaj-browserstack:PMAA-107-upload-path-traversal-fix

Conversation

@ruturaj-browserstack
Copy link
Copy Markdown
Collaborator

…AA-107)

All four file-upload paths (testmanagement uploadFile, applive uploadApp, appautomate uploadApp, and the shared uploadFileToBrowserStack helper used by Espresso/XCUITest) previously only checked fs.existsSync before streaming the file to BrowserStack cloud. A prompt-injected LLM turn could exfiltrate arbitrary user-readable files (SSH keys, .env, credentials).

Adds a shared validateUploadPath utility that canonicalizes the path via realpathSync, enforces a per-call extension allowlist, caps file size (4 GB for apps to match BrowserStack's upload limit, 100 MB for TM attachments), blocks hidden-directory traversal (.ssh, .aws, .env, etc.), and optionally enforces containment inside MCP_UPLOAD_BASE_DIR when configured.

Covers CWE-22 / CWE-434 / OWASP A01:2025.

…AA-107)

All four file-upload paths (testmanagement uploadFile, applive uploadApp,
appautomate uploadApp, and the shared uploadFileToBrowserStack helper used
by Espresso/XCUITest) previously only checked `fs.existsSync` before
streaming the file to BrowserStack cloud. A prompt-injected LLM turn could
exfiltrate arbitrary user-readable files (SSH keys, .env, credentials).

Adds a shared `validateUploadPath` utility that canonicalizes the path via
`realpathSync`, enforces a per-call extension allowlist, caps file size
(4 GB for apps to match BrowserStack's upload limit, 100 MB for TM
attachments), blocks hidden-directory traversal (`.ssh`, `.aws`, `.env`,
etc.), and optionally enforces containment inside `MCP_UPLOAD_BASE_DIR`
when configured.

Covers CWE-22 / CWE-434 / OWASP A01:2025.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gaurav-singh-9227 gaurav-singh-9227 merged commit 11cd835 into browserstack:main May 18, 2026
1 check passed
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.

2 participants