fix(security): prevent command and path injection in instance handling#122
Merged
Conversation
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>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
…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>
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.
Remediate CodeQL critical command-line-injection (cs/command-line-injection)
and high path-injection (cs/path-injection) findings.
shell-text sanitization, and ResolveWithin (canonicalize + base-dir containment).
base directory in LogEndpoints, InstanceEndpoints, UploadBackupHandler and
DockerPokManagerClient (rejects path traversal).
concatenated string in LocalDockerService, LocalDockerComposeService and
DockerPokManagerClient (prevents argument injection).
values/keys, custom command tokens) before building shell commands in
PokManagerClient; validate container names in SshDockerService.
(security-extended) to stop emitting code-quality noise.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com