Skip to content

fix(security): prevent command and path injection in instance handling#122

Merged
JerrettDavis merged 3 commits into
mainfrom
fix/security-codeql-remediation
Jun 23, 2026
Merged

fix(security): prevent command and path injection in instance handling#122
JerrettDavis merged 3 commits into
mainfrom
fix/security-codeql-remediation

Conversation

@JerrettDavis

Copy link
Copy Markdown
Owner

Remediate CodeQL critical command-line-injection (cs/command-line-injection)
and high path-injection (cs/path-injection) findings.

  • Add PokManager.Domain.Common.SafePath with identifier/file-token validation,
    shell-text sanitization, and ResolveWithin (canonicalize + base-dir containment).
  • Validate instanceId/backupId and resolve all user-derived paths within their
    base directory in LogEndpoints, InstanceEndpoints, UploadBackupHandler and
    DockerPokManagerClient (rejects path traversal).
  • Pass process arguments via ProcessStartInfo.ArgumentList instead of a single
    concatenated string in LocalDockerService, LocalDockerComposeService and
    DockerPokManagerClient (prevents argument injection).
  • Validate identifiers and sanitize free-form text (chat messages, config
    values/keys, custom command tokens) before building shell commands in
    PokManagerClient; validate container names in SshDockerService.
  • Switch the CodeQL workflow to the security-focused query suite
    (security-extended) to stop emitting code-quality noise.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Remediate CodeQL critical command-line-injection (cs/command-line-injection)
and high path-injection (cs/path-injection) findings.

- Add PokManager.Domain.Common.SafePath with identifier/file-token validation,
  shell-text sanitization, and ResolveWithin (canonicalize + base-dir containment).
- Validate instanceId/backupId and resolve all user-derived paths within their
  base directory in LogEndpoints, InstanceEndpoints, UploadBackupHandler and
  DockerPokManagerClient (rejects path traversal).
- Pass process arguments via ProcessStartInfo.ArgumentList instead of a single
  concatenated string in LocalDockerService, LocalDockerComposeService and
  DockerPokManagerClient (prevents argument injection).
- Validate identifiers and sanitize free-form text (chat messages, config
  values/keys, custom command tokens) before building shell commands in
  PokManagerClient; validate container names in SshDockerService.
- Switch the CodeQL workflow to the security-focused query suite
  (security-extended) to stop emitting code-quality noise.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

JerrettDavis and others added 2 commits June 22, 2026 20:02
…reated from user input'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Add SafePath.SanitizeLogValue and apply it when logging user-derived
values (cache keys/patterns, instance ids, docker-compose paths, executed
commands) so attacker-controlled CR/LF cannot forge log entries
(cs/log-forging). Instance-id sourced log entries are additionally covered
by the identifier validation added earlier.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread src/Infrastructure/PokManager.Infrastructure/Caching/InMemoryCacheService.cs Dismissed
@JerrettDavis JerrettDavis merged commit 2d58582 into main Jun 23, 2026
17 checks passed
@JerrettDavis JerrettDavis deleted the fix/security-codeql-remediation branch June 23, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants