Skip to content

fix(security): add base64 validation consistency in agent-setup.ts#2988

Merged
louisgv merged 1 commit intomainfrom
fix/issue-2986
Mar 25, 2026
Merged

fix(security): add base64 validation consistency in agent-setup.ts#2988
louisgv merged 1 commit intomainfrom
fix/issue-2986

Conversation

@la14-1
Copy link
Member

@la14-1 la14-1 commented Mar 25, 2026

Why: wrapperB64, unitB64, and timerB64 were interpolated into shell single-quoted strings without the validation guard that settingsB64 already has. This adds defense-in-depth consistency.

Changes

  • Added /^[A-Za-z0-9+/=]+$/ validation for wrapperB64, unitB64, timerB64 in agent-setup.ts
  • Matches existing pattern already used for settingsB64 (line 152)
  • No behavior change for valid inputs; throws early on unexpected base64 output
  • Patch version bump to 0.26.2

Fixes #2986

-- refactor/security-auditor

Previously only `settingsB64` had a validation check. Added the same
`/^[A-Za-z0-9+/=]+$/` guard for wrapperB64, unitB64, and timerB64
before they are interpolated into shell commands, closing the consistency gap.

Fixes #2986

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review

Verdict: APPROVED
Commit: ce847df

Findings

No security issues found. The changes add appropriate defense-in-depth validation.

Analysis:

  • Adds base64 charset validation (regex /^[A-Za-z0-9+/=]+$/) before embedding into shell commands
  • Validates 3 base64 strings across 2 functions (startGateway, setupAutoUpdate)
  • Input source is trusted (hardcoded systemd units/wrapper scripts), not external user input
  • Node.js Buffer.toString('base64') is spec-compliant and deterministic
  • Validation acts as defense-in-depth against hypothetical future refactoring risks
  • Pattern consistent with existing security measures (e.g., issue #2133)

Tests

  • agent-setup tests: PASS (25/25)
  • biome lint: PASS (0 errors)
  • version bump: ✅ 0.26.1 → 0.26.2
  • curl|bash safety: N/A (TypeScript changes only)
  • macOS compat: N/A (TypeScript changes only)

-- security/pr-reviewer

@louisgv louisgv added the security-approved Security review approved label Mar 25, 2026
@louisgv louisgv merged commit 82ab6d3 into main Mar 25, 2026
6 checks passed
@louisgv louisgv deleted the fix/issue-2986 branch March 25, 2026 22:16
la14-1 pushed a commit that referenced this pull request Mar 26, 2026
…3006)

Add /^[A-Za-z0-9+/=]+$/ validation after each .toString("base64") call
in delegateCloudCredentials() and injectEnvVars(), consistent with the
pattern established in agent-setup.ts by #2988.

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
louisgv added a commit that referenced this pull request Mar 26, 2026
…3006) (#3007)

Add /^[A-Za-z0-9+/=]+$/ validation after each .toString("base64") call
in delegateCloudCredentials() and injectEnvVars(), consistent with the
pattern established in agent-setup.ts by #2988.

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-approved Security review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Unsafe base64 shell interpolation in agent setup scripts

2 participants