Repository navigation
The bundle budget builds through Vite's API, with no shell - #567
Merged
Merged
Conversation
The script ran npx vite build through execSync with the output path in double quotes from JSON.stringify, which leaves $( ) and backticks to the shell: a checkout path holding them ran as a command. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
npm run budgetbuilds the dashboard through Vite's API instead of a shell command.Why
CodeQL's
js/shell-command-injection-from-environmentflagsfrontend/scripts/bundle_budget.mjs. It ranexecSync(`npx vite build --sourcemap --outDir ${JSON.stringify(out)} --emptyOutDir`), whereoutis the absolute path ofdist-budgetin the checkout.JSON.stringifyputs the path in double quotes, inside which the shell still expands$( )and backticks, so a checkout under a directory whose name holds them would run that text as a command. The script now calls Vite'sbuild()with the same options; Vite readsvite.config.tsas its CLI does, and no shell sees the path.Scope and risk
frontend/scripts/bundle_budget.mjsonly, which CI andnpm run budgetrun. The build options are those of the CLI flags it replaces (sourcemap,outDir); the script already removes the output directory before the build, so--emptyOutDiris dropped.Compatibility, rollout and rollback
Tests
npm --prefix frontend run budgetbuilds the same chunks, with the same hashes, as the previous script on the same tree (stylesheets 36.6 kB and boot scripts 186.5 kB gzipped, index chunk 119.5 kB) and endsbundle-budget: OK. Biome passes on the script.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code; ran the budget before and after the change.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code