Skip to content

Commit bbce656

Browse files
szachovyCopilot
andcommitted
Fix command injection in change_permissions_to_root
Replace ssh_client.exec_command(f'chmod 600 {filepath}') with sftp_client.chmod(filepath, 0o600). The shell-interpolated filepath allowed injection of arbitrary commands via crafted filenames. Closes #85 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0ab8ce7 commit bbce656

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* CI workflow to build and push service images to GitHub Container Registry on master merge. (#97)
1717
* Pull-first with local build fallback for container images during deployment. (#97)
1818

19+
### Fixed
20+
21+
* Command injection in change_permissions_to_root via SFTP chmod instead of shell exec. (#85)
22+
1923
### Changed
2024

2125
* Completed [ARCHITECTURE.md](./docs/ARCHITECTURE.md) (#93)

src/remote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ def upload_file(self, content: str | bytes, remote_file_path: str) -> None:
160160
self.sftp_client.putfo(io.BytesIO(content), remote_file_path)
161161

162162
def change_permissions_to_root(self, filepath: str) -> None:
163-
self.ssh_client.exec_command(f"chmod 600 {filepath}")
163+
self.sftp_client.chmod(filepath, 0o600)

0 commit comments

Comments
 (0)