Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2026-05-03 - [Security] Add command safety check to execCommand
**Vulnerability:** Execution of unsecure binaries found in the current directory (binary planting) when using `execCommand`.
**Learning:** Core utility functions for command execution should consistently apply safety checks to prevent PATH-hijacking-like attacks in the current working directory.
**Prevention:** Always use `parseCommand` and `checkCommandSafety` in command execution wrappers to validate the binary location before invoking execution libraries like `execa`.
11 changes: 11 additions & 0 deletions packages/cli-kit/src/public/node/system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ describe('execCommand', () => {
// Then
expect(execaCommand).toHaveBeenCalledWith('cat', expect.objectContaining({stdin: 'inherit'}))
})

test('raises an error if the command to run is found in the current directory', async () => {
// Given
vi.mocked(which.sync).mockReturnValueOnce('/currentDirectory/command')

// When
const got = system.execCommand('command', {cwd: '/currentDirectory'})

// Then
await expect(got).rejects.toThrowError('Skipped run of unsecure binary command found in the current directory.')
})
})

describe('isStdinPiped', () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli-kit/src/public/node/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export async function execCommand(command: string, options?: ExecOptions): Promi
env.FORCE_COLOR = '1'
}
const executionCwd = options?.cwd ?? cwd()
const [cmd] = parseCommand(command)
if (cmd) {
checkCommandSafety(cmd, {cwd: executionCwd})
}
try {
await execaCommand(command, {
env,
Expand Down
Loading