Skip to content

Harden SSH command execution and temporary files - #3

Open
santiagocasas wants to merge 1 commit into
snez:masterfrom
santiagocasas:security/harden-command-execution
Open

santiagocasas wants to merge 1 commit into
snez:masterfrom
santiagocasas:security/harden-command-execution

Conversation

@santiagocasas

Copy link
Copy Markdown

What this changes

This tightens up the places where the plugin builds SSH commands and temporary files.

The old code passed interpolated strings to a local shell. That meant a specially crafted
host or command could be interpreted locally instead of being handed to SSH as plain data.
The files used to disable local tools also had predictable names under /tmp.

This PR:

  • uses execFileSync() with argument arrays for SSH connection management;
  • validates SSH host aliases before using them;
  • passes the whole remote Bash command to SSH as one safely quoted argument;
  • creates a private temporary directory for disabled-tool files;
  • uses random names for blocked write targets; and
  • creates the sentinel file with 0600 permissions.

Commands containing pipes, redirects, &&, or similar shell syntax still work on the
remote host. They are no longer evaluated by the local shell while the SSH command is
being assembled.

I kept this PR limited to the command-execution and temporary-file hardening. Connection
health checks, fail-closed behavior, and the launcher are separate follow-up PRs.

Checks

  • Ran git diff --cached --check.
  • Reviewed the generated SSH argument lists and command quoting.
  • This repository does not currently have an automated test suite.

AI assistance

The code and this PR description were generated with help from GPT-5.6-Sol.

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.

1 participant