runPrettierStep breaks on shell-sensitive filenames
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 197
- Forks
- 51
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 94
Description
I ran across a potential issue in the wizard UI flow after the agent finishes making changes and the wizard tries to run the post-run formatting step.
From the user's perspective, this would show up near the end of a wizard run when the terminal says it is running Prettier on changed files. If one of the changed or untracked files has a name containing a space, quote, semicolon, or another shell-sensitive character, the formatting step may fail or format the wrong path.
I traced it in the repo to runPrettierStep: it gets changed/untracked files from git status --porcelain=v1, joins those filenames into one string, then interpolates that into a shell command:
childProcess.exec(
`npx prettier --ignore-unknown --write ${changedOrUntrackedFiles}`,
...
)
Relevant code:
src/utils/setup-utils.tsbuilds the changed-file list from Git status output.src/steps/run-prettier.tsjoins that list and passes it tochildProcess.exec.
This looks like it can break on ordinary filenames with spaces, quotes, or other shell-sensitive characters. It may also be worth checking whether a malicious filename could change what the shell executes, since the filenames are interpolated into the command string.
A simple reproduction should be something like:
- In a test project, create or modify a file with a name containing a space, quote, semicolon, or other shell-sensitive character.
- Ensure the project has Prettier declared in
package.json. - Run a wizard flow that reaches the post-run Prettier step.
- Observe whether Prettier formats the intended file, fails, or interprets the filename incorrectly.
I think the safer shape is probably to keep filenames as argv entries and use spawn/execFile instead of exec, but I have not fully tested the behavior yet.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reading src/utils/setup-utils.ts to verify how git status output becomes the changed-file list, then inspect src/steps/run-prettier.ts and reproduce the wizard flow with a filename containing spaces or shell-sensitive characters. Confirm that the post-run step passes filenames safely as separate arguments, formats the intended files, and does not interpret filename contents as shell commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100