mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3884] ssh profile blocks access to ssh-agent with non-default socket location #2440
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#2440
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @scruloose on GitHub (Jan 12, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3884
Bug and expected behavior
I have just installed firejail and run the auto-configurator with
sudo firecfg. I have ssh-agent running (with a nonstandard socket location — which I believe is relevant). When I runssh <host>, I'm prompted for the passphrase for my key every time, even thoughssh-add -lshows the key is loaded,envshows theSSH-AUTH_SOCKvariable is correctly set, and I have verified that the socket "file" exists. If I provide the passphrase, ssh connects as expected.No profile and disabling firejail
firejail --noprofile /path/to/programin a terminal?firejail --noprofile /usr/bin/ssh <host>, it uses the key from ssh-agent with no passphrase prompt and immediately presents the remote system's shell prompt, as expected./usr/bin/ssh <host>, it uses the key from ssh-agent with no passphrase prompt and immediately presents the remote system's shell prompt, as expected.Reproduce
Steps to reproduce the behavior:
sudo firecfgssh-addyour key if it's not already loadedEnvironment
Debian Bullseye, kernel 5.10.4
0.9.64
Additional context
ssh -vvv, the output includes the following line:debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directoryssh.profileincludes an exception hardcoded to the default socket location:noblacklist /tmp/ssh-*But I don't see anything that takes the
SSH_AUTH_SOCKenvironment variable and adds an exception for it.ssh-agentcurrently is not sandboxed. My existing configuration calls it by full path and I haven't yet updated that to point to the firejail symlink.Checklist
I don't actually know how to check this. I can tell you I haven't made any local changes to the profile.
Sorry, duplicates of what? Duplicate profiles for ssh? This is a perfectly stock install, with nothing customized yet.
--profile=PROFILENAMEis used to set the right profile.It's the official Debian repo
sshpackage, not an AppImage.LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 PROGRAMto get english error-messages.English UTF-8 is my system default language.
browser-allow-drm yes/browser-disable-u2f noinfirejail.configto allow DRM/U2F in browsers.Never heard of it. However, I think DRM is a cancer, I already have it disabled in my browser, and my problem is not browser related. So I think we can safely rule this out.
debug output
I'll happily provide this if it's needed, but I'm reasonably sure the relevant details are already in "Additional Context" above.
@kmk3 commented on GitHub (Jan 12, 2021):
Indeed, ssh.profile only has an exception for the default path. If you use a
custom path, the usual way to allow it is to add an exception for it on
/etc/firejail/ssh.local or ~/.config/firejail/ssh.local. Example:
I don't think that there is any functionality implemented to create exceptions
based on the contents of a given environment variable (other than the ones that
are explicitly supported, such as
${HOME}. Though I must say that this wouldbe nice to have for things like
$XDG_CONFIG_HOME.I think it means to check on the master branch if it has already been fixed:
https://github.com/netblue30/firejail/blob/master/etc/profile-m-z/ssh.profile
It means to check for existing issues before potentially opening a duplicate.
@scruloose commented on GitHub (Jan 13, 2021):
Thanks for your quick response!
I don't know if it's obvious to everyone but me, or if it might be good to update the template to specify "duplicate issues"…?
Adding that line to
~/.config/firejail/ssh.localhad no effect on its own. After also adding a whitelist rule (similar to the ones that get included viawhitelist-runuser-common.inc) now ssh seems to be working as expected.When I saw
${USER}and${HOME}in that profile file, I kind of assumed that reading from arbitrary environment variables was supported. I can already see that it would be helpful to have that capability.@kmk3 commented on GitHub (Jan 14, 2021):
No problem.
Will do that.
Nice, I'm glad it worked.
Yeah, I was bit by this before as well. Not sure what is the best place for
documenting that though, so if anyone has any suggestions...
Agreed, though I'm not sure about the security/code complexity implications of
that. I'd suggest opening a feature request.
On a related note: Not sure if this helps the case, but the profiles are
currently able to set environment variables:
@Lesstat commented on GitHub (Jan 14, 2021):
I just encountered the same bug and the whitelist rule explained above did fix it 👍 so kudos to you. Unfortunately, If the connection includes a Proxyjump I still get asked for my ssh passphrase. Any ideas how to fix this?
@kmk3 commented on GitHub (Jan 14, 2021):
@scruloose Could you change the title to something more specific? Example:
@Lesstat commented 10 hours ago:
Since custom auth socket paths seem to be a thing, I'll add a comment about
them on ssh.profille (and possibly on allow-ssh.inc; see #3885). Would you
mind giving an example path and/or saying what is your use case for it?
Related to that, we are discussing1 2 further hardening ssh (TBD), so I'm
very interested in custom setups and whether that would break them. I'll
mention you both when the relevant PR is created.
This is a different problem, so please open a new issue.
@scruloose commented on GitHub (Jan 17, 2021):
For my part, I'm using a systemd user service to manage my ssh-agent, mostly so it's available independent of my desktop environment and I don't have to worry about duplicate agent processes. As long as I continue to have at least one logged-in session — be it X11, Wayland, VT1, ssh in from remote, whatever — the same ssh-agent process stays available, even if the initial login session that triggered it has since logged out.
AFAIK, the expected location for ephemeral runtime files and sockets associated with systemd user services is
$XDG_RUNTIME_DIR, which on my Debian systems is/run/user/$UID/, so that's where I put my ssh-agent's socket.@kmk3 commented on GitHub (Jan 20, 2021):
Thanks.
Nice, I never thought about making user daemons survive session termination.
That makes sense; I would also rather put sockets in there. Better user
isolation and less /tmp pollution. I wish that more tools would use
$XDG_RUNTIME_DIRfor these things by default on Linux...@scruloose commented on GitHub (Jan 25, 2021):
It does make some things much simpler. The behaviour I described, where user services persist as long as the user continues to have at least one active login session, is the systemd default. There's also a setting you can apply to users via the system systemctl instance, which IIRC is called "enable-linger", that allows that user's user systemd services to start at boot and survive until shutdown just like system services. I'm not sure whether it's possible for the user to then turn the lingering behaviour on and off for individual units, though, and generally I use system services that drop privileges via the
User=andGroup=directives for that kind of use-case.Yeah, me too. How does that old joke go? "The great thing about standards is there are so many to choose from, you can do whatever you want"…