Skip to content

fix(create-astro): validate integration names to prevent shell injection - #15429

Closed
kaigritun wants to merge 1 commit into
withastro:mainfrom
kaigritun:fix/create-astro-shell-injection
Closed

kaigritun wants to merge 1 commit into
withastro:mainfrom
kaigritun:fix/create-astro-shell-injection

Conversation

@kaigritun

Copy link
Copy Markdown

Description

Fixes #15420

The --add flag was passing user input directly to shell commands, allowing shell metacharacters to be interpreted as shell syntax. For example:

npm create --yes astro poc -- --add "react; open -a Calculator.app;" --install --yes

Would result in open -a Calculator.app being executed.

Changes

  • Added VALID_INTEGRATION_NAME regex pattern that matches valid npm package names (lowercase letters, numbers, hyphens, underscores, dots, and scoped packages)
  • Added isValidIntegrationName() validation function
  • Invalid integration names are now filtered out with a clear error message
  • Added 3 tests for validation behavior:
    • Rejects integration names with shell metacharacters
    • Accepts valid integration names
    • Filters out only invalid names (keeps valid ones)

Testing

All 73 tests pass, including the 3 new tests:

  • rejects integration names with shell metacharacters ✔
  • accepts valid integration names ✔
  • filters out only invalid integration names ✔

Fixes withastro#15420

The --add flag was passing user input directly to shell commands,
allowing shell metacharacters to be interpreted. This adds validation
to ensure integration names match the npm package name pattern before
passing them to the shell.

- Added VALID_INTEGRATION_NAME regex pattern for npm package names
- Added isValidIntegrationName() validation function
- Invalid integration names are filtered out with an error message
- Added tests for validation behavior
@github-actions github-actions Bot added the pkg: create-astro Related to the `create-astro` package (scope) label Feb 6, 2026
@changeset-bot

changeset-bot Bot commented Feb 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 21e445a

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@florian-lefebvre

Copy link
Copy Markdown
Member

Hi, this was already fixed by #15419 unfortunately. Thanks for trying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: create-astro Related to the `create-astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create-astro: --add input is interpreted as shell syntax

2 participants