You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(security): close remaining /bin/sh -c shell-injection sites in bundle ID flows (#390)
* fix(security): close remaining /bin/sh -c shell-injection sites in bundle ID flows
Follow-up to #289. PR #289 hardened the `useShell=true` path through
`shellEscapeArg`, but four call sites still hand-built `/bin/sh -c`
strings interpolating user-controlled paths and passed them to the
executor with `useShell=false`:
- `src/utils/bundle-id.ts`
- `src/mcp/tools/project-discovery/get_mac_bundle_id.ts`
- `src/mcp/tools/macos/build_macos.ts`
- `src/utils/macos-steps.ts`
All four now invoke `defaults` and `PlistBuddy` directly with an argv
array, removing shell parsing entirely (option 1 from the issue). The
malicious appPath becomes a single positional argument to `defaults` /
`PlistBuddy` and is never interpreted as a shell expression.
Tests:
- The four `UNFIXED:` regression cases in `bundle-id-injection.test.ts`
and `mac-bundle-id-injection.test.ts` are flipped to safe assertions
(no `/bin/sh`, exact argv shape, `useShell=false`).
- New PlistBuddy-fallback cases assert the same shape on the second
branch.
- Existing fixtures in `get_app_bundle_id.test.ts`,
`get_mac_bundle_id.test.ts`, and `build_run_device.test.ts` updated
to the new argv-shape command keys.
- Pre-fix verification: stashed the four source edits and re-ran the
injection suites — 8/8 fail. Restored the fix — 8/8 pass.
Local gates: typecheck, lint, prettier --check, full vitest run
(1772 passed / 0 failed).
Closes#367
* test: Remove stale shell stub from macOS smoke test
---------
Co-authored-by: voidborne-d <voidborne-d@users.noreply.github.com>
Co-authored-by: Cameron Cooke <web@cameroncooke.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
5
5
### Fixed
6
6
7
+
- Fixed remaining `/bin/sh -c` shell-injection sites in bundle ID extraction and macOS launch flows by invoking `defaults` and `PlistBuddy` directly with argv arrays so user-supplied app paths are no longer interpreted by a shell ([#367](https://github.com/getsentry/XcodeBuildMCP/issues/367)).
7
8
- Fixed simulator test JSONL accuracy by keeping preflight discovery observational, preserving only user-supplied test selectors, discovering multiline parameterized Swift Testing tests, and parsing destination-suffixed xcodebuild test result lines.
8
9
- Removed stale physical-device log session status and shutdown cleanup for deprecated standalone device log capture, and corrected the device build-and-run tool description.
9
10
- Fixed mixed Swift Testing and XCTest summaries so simulator test text output no longer overcounts parameterized Swift Testing results or issue lines.
0 commit comments