Skip to content

Commit 4860988

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 4860988

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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

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

0 commit comments

Comments
 (0)