-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add sshd options for alternative ~/.ssh/environment
and ~/.ssh/rc
files
#466
base: master
Are you sure you want to change the base?
Conversation
98a3f1d
to
eb99ce0
Compare
Great. Another thing everyone has to scan for. Not a fan. |
I don't see the problem. By default, none of these are overridden and work the same as they always have. If people are already scanning for alternate |
still not a fan. |
I will give you a reason. Now I have one cool place to set alias with no UID traceability. environment is an open book. And people who can't afford to buy commercial scanners have yet another setting they have to watch out for in ssh_conf. All this PR does is make CrowdStrike money. Not. A. Fan. |
I don't think i follow what are you trying to say here. Can you elaborate what exactly is bothering you and what CrowdStrike (whatever that is) has anything in common with the PR? |
@62832 i eyeballed your commit. Did you make sure that the environment file specified in the option is locked down to the root user as owner and locked down with |
OpenSSH doesn't even do this with the existing |
At least refuse to use the file if the underlying fs has no ro flag capability (and abort/ignore if it doesn't), and require ro be set on the file before sucking it up. |
If that is indeed the case, I'm happy to take another look and address this. I concede that I might have glossed over something important, but I would have better appreciated if this was clarified with less hostility.
Symlinks are not the answer. If I want to comply by specifications such as XDGBDS then I want there to be NO
As mentioned in the first point, that can be arranged. |
Thank you... updated out my typo above but you got what I meant. The ro check would give a lot of assurance that whatever option value is set, it's going to get some basket of controls that |
Thought about this some more... You have to resolve down the path and examine if the user setting keeps the file in the own user's home folder, because you're assuming this is just going to be set for XDG but user can set it anywhere. If it stays in the user's home folder but no longer on the 0700 .ssh folder, you have to perm check the file to make sure the user did not put on global write/execute on it. If it's outside the user home folder, then what I said above... file has to be owned by root and +i must be on the file because it's going to be global readable (then it's the user's problem if sensitive stuff is in it)... that would be ok. I think that gets you in a better position because right now ssh is not checking flags there and the 0700 on .ssh is what's protecting it. |
Sounds good. In that case, I'm thinking that the steps to take would be the following:
Is this what you had in mind? |
0700 anywhere in the +i check if it's OUTSIDE the
Yes if it resolves down to outside the That would keep the existing functionality the same when the option has been set, but then if an absolute path or path to somewhere else on the filesystem that makes the file shared needs good write protection. |
I'm guessing manpages update needed and/or printf because it's unexpected behavior to set an absolute path for the user folder and the client just ignores it with no information, so the user would need to be told (same way ssh client tells you that perms are wrong on the keys and |
@christoofar I've so far manage to implement the checks for user ownership and outside permissions within Unfortunately, I'm at a loss as to how to put together the immutability check considering that file flags work very differently between Linux and *BSD. Since I don't know of a particularly easy portable way to check for this, I'd be eager to hear any potential alternatives that might be worth considering instead. |
Further consideration: it probably doesn't make sense to enforce |
Well, ignoring the The But you take it |
I think it's way better to take the more user-annoying option and enforce to the file and not allow a They will ask around why it's like that and on a machine that's set up with lots of group ownerships it will stop some priv escalation attacks. |
a670a13
to
a57e10f
Compare
Continuing on from a previous attempt on the mailing list at proposing a mechanism for specifying alternative paths for the
environment
andrc
files used bysshd
, I figured it would be worth simply working on it there and then and submitting it as a PR.The rationale for this comes from the prior mailing list discussion near the start of the month regarding the possibility of built-in fallback paths which would follow the XDG Base Directory Specification, and my own attempt following it at implementing it myself. As it turns out, it was not very feasible to implement full compliance, as some of the files within the
~/.ssh
directory — namely,authorized_keys
,environment
andrc
— were not read by the client program, but the server daemon running as a different privileged user. In attempting to implement any solution that required the use of environment variables to define alternative locations, I was not able to find an easy way — if such even exists — of having thesshd
user read the authenticated user's existing environment.Therefore, it would instead make sense to leverage the existing configuration and program invocation options such as
ssh -F [config]
for a user to enforce compliance as they wish. However, while it is possible to specify alternative paths forsshd
to use for authorised key files,~/.ssh/environment
and~/.ssh/rc
remained hard-coded with no option to specify alternative paths. This PR implements this option for both of these files via theUserEnvironmentFile
andUserRCFile
options respectively forsshd_config
, completely eliminating the need for the~/.ssh
directory should the user choose to not use it.If there are any problems with the PR as it stands, please let me know and I'll be happy to address them.