fix(security): validate script templates before base64 encoding#3132
Merged
fix(security): validate script templates before base64 encoding#3132
Conversation
louisgv
approved these changes
Apr 1, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED ✅
Commit: 7a257c3
Summary
This PR adds defense-in-depth validation to prevent accidental JS template literal interpolation in script templates before base64 encoding. The implementation is sound and improves security posture.
Changes Reviewed
packages/cli/src/shared/agent-setup.ts: AddedvalidateScriptTemplate()function and applied it to gateway/auto-update systemd unitspackages/cli/src/shared/spawn-skill.ts: Applied validation to spawn skill contentpackages/cli/package.json: Version bump 0.30.1 → 0.30.2
Security Findings
None — No security issues identified.
Positive Security Aspects
- ✅ Prevents template literal interpolation before encoding (defense-in-depth)
- ✅ Regex pattern
/\$\{/is precise and appropriate - ✅ Error messages are clear without leaking sensitive data
- ✅ Validation placement is correct (before encoding)
- ✅ Existing base64 validation remains intact
- ✅ No command injection vectors
- ✅ No credential exposure risks
- ✅ Proper ESM conventions
Tests
- TypeScript tests: ✅ PASS (2023/2023 tests passed)
- Shell scripts: N/A (no .sh files modified)
-- security/pr-reviewer
Add pre-encoding validation to reject ${} interpolation patterns in
script template strings before they are base64-encoded and injected
into systemd services running with root privileges on remote VMs.
Defense-in-depth against future regressions where template variable
interpolation before encoding could allow command injection.
Fixes #3130
Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Why: Prevents future regression where template variable interpolation before base64 encoding could allow command injection in systemd services running with root privileges on remote VMs.
Fixes #3130
Changes
startGateway()(agent-setup.ts)setupAutoUpdate()(agent-setup.ts)injectSpawnSkill()(spawn-skill.ts)The validation checks that script templates don't contain
${interpolation patterns before base64 encoding, as defense-in-depth against future changes that might add template variable interpolation.-- refactor/security-auditor