scripts/make-site.sh: avoid eval and validate DOCSY_VERS to prevent command injection#2422
scripts/make-site.sh: avoid eval and validate DOCSY_VERS to prevent command injection#2422thesmartshadow wants to merge 9 commits intogoogle:mainfrom
Conversation
|
Hi maintainers this PR removes unsafe Current status shows:
If you can:
I verified:
Thanks! |
|
Hi maintainers All checks are green except workflows that require maintainer approval. |
|
HI @thesmartshadow. Thanks for the PR. Given that this is a script for internal usage, I'll be focusing on other priorities before I can get to this one. I'll get back to it as soon as I can. |
|
Hi @chalin, thanks a lot for the update and for taking a look. Totally understand that there are other priorities and that this script is mainly used internally. No rush on my side happy to wait, and also happy to adjust or split the patch if there’s anything you’d like changed. Thanks again! |
Summary
This PR hardens
scripts/make-site.shby removing unsafe shellevalusage and validating user-controlled inputs (notably-v/DOCSY_VERS) to prevent OS command injection during Hugo module operations.Background / Root Cause
DOCSY_VERSis provided via the-vflag and is incorporated into the Hugo module reference. The script previously usedevalfor Hugo module commands, which can turn attacker-influenced data into shell syntax (command separators / metacharacters), resulting in unintended command execution.Fix
evalfrom Hugo / Hugo-module invocation paths and pass arguments safely.DOCSY_VERSandDOCSY_REPO(reject whitespace / shell metacharacters and unexpected patterns).Why this matters (realistic threat model)
Docsy’s own documentation references automated build/publish workflows (e.g., PR deploy previews). In real build/preview pipelines, values such as refs/branches/tags and other derived parameters can become attacker-influenced (directly or indirectly) and reach scripts like
make-site.sh. WhenDOCSY_VERSis concatenated into a string executed viaeval, shell metacharacters can be interpreted as commands (build-time OS command injection). This can impact the CI runner, secrets available to the job, and the integrity of generated/published artifacts (supply-chain risk).Security impact
This is a build-time hardening change. If
-vis influenced by untrusted CI inputs or build automation parameters, the previousevalusage could enable command execution in the build environment, potentially impacting:Security classification
evalwith attacker-influenced dataTesting
./scripts/make-site.sh -s HUGO -v mainstill works as expected.-vvalues are rejected and do not get executed.References