-
-
Notifications
You must be signed in to change notification settings - Fork 742
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
include stricter shell as recommended ssh configuration #8318
Comments
Interesting idea - did you practically try some alternative, small shells with borg 1.x client/server setup? |
@ThomasWaldmann on my backup server, i indeed did the two recommended steps with a username "borg" and debian's reduces bourne shell "/bin/dash":
dash is debian's "posix-compliant no-additional-features" shell. Just now, i did not (yet) evaluate any other shells, since i would instead invest the time in trying out the idea with the borg-as-login-shell wrapper. |
Looking through the list of debian packages in the "shells" section [1], posh might be another candidate, besides dash, as small /bin/sh implementation. dash would still have the advantage of being an essential package in debian and therefore being installed anyway (and supposedly therefore with greater scrutiny by debian developers or the debian security team). However, regarding the topic of this github issue, i would not recommend writing any linux-distribution specific wordings into the borg documentation. I would rather point out the considerations, that using a dedicated user and a minimal shell are good practices. |
…borgbackup#8318 so long as it can be assumed that the user has configured a POSIX compliant login shell, using a simple command [1] looks cleaner, as no ``export`` or ``;`` [1] Section "2.9.1 Simple Commands" in volume "Shell & Utilities" of POSIX.1-2024
…borgbackup#8318 so long as it can be assumed that the user has configured a POSIX compliant login shell, using a simple command [1] looks cleaner, as no ``export`` or ``;`` are used. [1] Section "2.9.1 Simple Commands" in volume "Shell & Utilities" of POSIX.1-2024
…borgbackup#8318 so long as it can be assumed that the user has configured a POSIX compliant login shell, using a simple command [1] looks cleaner, as no ``export`` or ``;`` are used. [1] Section "2.9.1 Simple Commands" in volume "Shell & Utilities" of POSIX.1-2024
see borgbackup#8318 so long as it can be assumed that the user has configured a POSIX compliant login shell, using a simple command [1] looks cleaner, as no ``export`` or ``;`` are used. [1] Section "2.9.1 Simple Commands" in volume "Shell & Utilities" of POSIX.1-2024
I have started writing some text, but writing understandable documentation is hard. This is what i got so far: Feedback from colleagues suggests, that this whole business of sshd using the user's login shell might be a surprising decision on part of openssh, and borg itself should stay away from dealing with it (I don't necessarily agree). One also mentioned, that some users with non-default shells (the example Since i value the mentioned colleagues as non-beginner users, and having them consider the openssh behaviour surprising tells me, that a good documentation should address this. |
Hello!
Context
i currently use borg 1.x on a debian bookworm system, where i (also) want the server to not trust the clients that much and said clients connect to the server (and send data) over the network via ssh. This is as described in (one of) the configurations recommended by borg in its documentation.
Documentation reference:
borg/docs/usage/serve.rst
Line 47 in 6039349
I create this issue against the 2.x branch, but it both concerns the 1.x and 2.x documentation. I couldn't find a previous issue discussing (and possibly rejecting) my proposal through the github issue search, but i am not very confident that i didn't miss a related issue.
This issue proposes an improvement to the documentation, described just now. Further down, a longer rationale is given for the change.
Proposed Improvement
In the documentation, in the section
Usage > borg serve > Example
and also the following sectionSSH Configuration
,the text should also mention that setting a shell with smaller footprint for the user under which
borg serve
is started, will reduce attack surface.backup
userchsh -s /bin/sh backup
Rationale
I suppose that many users expect their backup-strategy to also hold (i.e. provide a means of disaster-recovery) with a reasonable certainty in the face of a "hacked" borg-client (e.g. a user's daily workstation); this is certainly a goal with my backup-strategy. When borg is chosen as a building block for this backup-strategy, and borg is setup on a separate backup-server according to the description presented in the documentation section "Usage > borg serve", then i think this setup is needlessly in risk of shell-bugs similar to shellshock (CVE-2014-6271 and others, see: https://en.wikipedia.org/wiki/Shellshock_(software_bug) ).
Note
It must be noted, that all this discussion is strictly speaking outside the scope of borg. However, since borg elects to giving ssh-related configuration directions in it's documentation, it takes on (some) responsibility of recommending a secure-by-default configuration.In the recommended setup, the forced command (specified in the authorized_keys file) is executed by sshd by using
$SHELL -c $COMMAND
, where $SHELL is the user's login shell, and $COMMAND is the forced command (ref: https://manpages.debian.org/bookworm/openssh-server/sshd_config.5.en.html#ForceCommand ).Now if the user's shell is configured to be
/bin/bash
(as is the default in the operating system i use, debian bookworm, and i suppose is easily the default shell in other linux operating systems), then a very large codebase is "pulled in" into the attack surface. For example a similar situation to the bug coined shellshock, in which a carefully crafted environment variable will lead to arbitrary code execution, might come around. After all, the borg-client connecting to borg-serve through ssh is in full control of the contents of the environment variable SSH_ORIGINAL_COMMAND.However, in order for the data transfer between the borg-client and borg-serve to work, actually all the bash-features and thus all the extra code are not needed. Thus, reducing the loaded code reduces the attack surface and finally reduces the chance of there being some (hidden) security bug.
sub-idea
When a dedicated user is used on the backup-server, then that user's shell could be set to a special borg-ssh-shell wrapper binary (to be implemented some day). This way, no traditional shell (/bin/sh, /bin/bash, etc) is started at the backup-server at all.
Then sshd would still execute
$SHELL -c $COMMAND
, but $SHELL is now the borg-serve wrapper. This wrapper would discard argv[1] (which is always-c
), split argv[2] in a shell-like manner (as ssh gives the command to $SHELL in one string), retain environment variable SSH_ORIGINAL_COMMAND and then execve (ref: https://manpages.debian.org/bookworm/manpages-dev/execve.2.en.html ) the actualborg-serve
process with the such calculated argv and envp.The text was updated successfully, but these errors were encountered: