Skip to content

Commit 319d3e9

Browse files
hexqiclaude
andcommitted
fix(ci): use allowlist regex for backend_url validation
The previous blocklist regex `[^[:space:]/?#:]+` did not reject `$`, so a backend_url like `https://evil.com/$GITHUB_TOKEN/` passed validation and was written to .env.alpha as `VITE_ORIGIN=...`. Vite processes env files with dotenv-expand, which would expand `$GITHUB_TOKEN` to the runner's secret and bake it into the public gh-pages JS bundle. Switch to positive character classes that only allow URL-safe chars for the host (`a-zA-Z0-9._-`) and path (`a-zA-Z0-9._/~:%-`), blocking `$`, backticks, parentheses, and other dotenv/shell metacharacters while still permitting percent-encoded path segments like `%20`. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 25a2ec4 commit 319d3e9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

.github/workflows/deploy-gh-pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ jobs:
4545
exit 1
4646
fi
4747
48-
if [[ ! "$ENV_BACKEND_URL" =~ ^https?://[^[:space:]/?#:]+(:[0-9]+)?(/[^[:space:]?#]*)?$ ]]; then
49-
echo "::error::backend_url must be an http(s) base URL without query or hash"
48+
if [[ ! "$ENV_BACKEND_URL" =~ ^https?://[a-zA-Z0-9._-]+(:[0-9]+)?(/[a-zA-Z0-9._/~:%-]*)?$ ]]; then
49+
echo "::error::backend_url must be an http(s) base URL using only URL-safe characters (letters, digits, . _ - / ~ : %)"
5050
exit 1
5151
fi
5252

0 commit comments

Comments
 (0)