-
Notifications
You must be signed in to change notification settings - Fork 3
Fix SCP support, but break jail #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,21 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Permit scp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case $SSH_ORIGINAL_COMMAND in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'scp'*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Permit scp when run in internal source/dest/dir mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # NOTE: adding path does not protect from rogue symlinks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scp -f $HOME/"*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $SSH_ORIGINAL_COMMAND | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scp -t $HOME/"*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $SSH_ORIGINAL_COMMAND | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scp -d $HOME"*) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $SSH_ORIGINAL_COMMAND | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1
to
+12
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1
to
+13
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| # Permit standard sftp - by path, as `internal-sftp` works only in sshd_config |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executing $SSH_ORIGINAL_COMMAND without proper sanitization or validation is a security risk. The command should be parsed and validated more thoroughly to prevent command injection attacks.
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| "scp -t $HOME/"*) | |
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| "scp -d $HOME"*) | |
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| "/usr/lib/openssh/sftp-server") | |
| $SSH_ORIGINAL_COMMAND | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-f" ] && [[ "$3" == $HOME/* ]]; then | |
| exec scp -f "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| "scp -t $HOME/"*) | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-t" ] && [[ "$3" == $HOME/* ]]; then | |
| exec scp -t "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| "scp -d $HOME"*) | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-d" ] && [[ "$3" == $HOME* ]]; then | |
| exec scp -d "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| "/usr/lib/openssh/sftp-server") | |
| exec /usr/lib/openssh/sftp-server |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executing $SSH_ORIGINAL_COMMAND without proper sanitization or validation is a security risk. The command should be parsed and validated more thoroughly to prevent command injection attacks.
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| "scp -t $HOME/"*) | |
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| "scp -d $HOME"*) | |
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| "/usr/lib/openssh/sftp-server") | |
| $SSH_ORIGINAL_COMMAND | |
| # Parse and validate arguments for 'scp -f' | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-f" ] && [[ "$3" == $HOME/* ]]; then | |
| exec scp -f "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| "scp -t $HOME/"*) | |
| # Parse and validate arguments for 'scp -t' | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-t" ] && [[ "$3" == $HOME/* ]]; then | |
| exec scp -t "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| "scp -d $HOME"*) | |
| # Parse and validate arguments for 'scp -d' | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-d" ] && [[ "$3" == $HOME* ]]; then | |
| exec scp -d "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| "/usr/lib/openssh/sftp-server") | |
| # Only allow exact match for sftp-server | |
| if [ "$SSH_ORIGINAL_COMMAND" = "/usr/lib/openssh/sftp-server" ]; then | |
| exec /usr/lib/openssh/sftp-server | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executing $SSH_ORIGINAL_COMMAND without proper sanitization or validation is a security risk. The command should be parsed and validated more thoroughly to prevent command injection attacks.
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| "scp -t $HOME/"*) | |
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| "scp -d $HOME"*) | |
| $SSH_ORIGINAL_COMMAND | |
| ;; | |
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| "/usr/lib/openssh/sftp-server") | |
| $SSH_ORIGINAL_COMMAND | |
| # Parse and validate the command | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-f" ] && [[ "$3" == $HOME/* ]]; then | |
| exec scp -f "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| "scp -t $HOME/"*) | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-t" ] && [[ "$3" == $HOME/* ]]; then | |
| exec scp -t "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| "scp -d $HOME"*) | |
| set -- $SSH_ORIGINAL_COMMAND | |
| if [ "$1" = "scp" ] && [ "$2" = "-d" ] && [[ "$3" == $HOME* ]]; then | |
| exec scp -d "$3" | |
| else | |
| echo "Access Denied" | |
| exit 1 | |
| fi | |
| ;; | |
| # Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config | |
| "/usr/lib/openssh/sftp-server") | |
| exec /usr/lib/openssh/sftp-server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executing
$SSH_ORIGINAL_COMMANDwithout proper sanitization or validation is a security risk. The command should be parsed and validated more thoroughly to prevent command injection attacks.