Skip to content
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

ssh: add trust checks before sourcing env vars #1395

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

slarew
Copy link
Contributor

@slarew slarew commented Jul 22, 2017

Proposed Changes

  • Add ownership test before attempting to source environment variables in SSH module. If the file is not owned by the current user, its contents should not be trusted. The default path is predictable and thus subject to abuse.

@@ -16,6 +16,19 @@ _ssh_dir="$HOME/.ssh"
# Set the path to the environment file if not set by another module.
_ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env.$UID}"

# Due to the predictability of the env file, check the env file exists and is
# owned by current EUID before trusting it.
if [ -f "$_ssh_agent_env" -a ! -O "$_ssh_agent_env" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use [[ rather than [

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Collaborator

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Note that #1394 should be resolved first, as this PR is based off of that PR.

* Remove persistent SSH auth socket.
* Make ps|grep more robust and POSIX compliant.
* On macOS, use `-A` switch to "add identities to the agent using any
passphrase stored in the user's keychain."
If the user defines identities in `:prezto:module:ssh:load`, always try
to load them, even on macOS.  On macOS, also try to load Keychain
managed identities. (Assume if a user adds an identity to Keychain then
the use would want those identities automatically loaded.)
@Shea690901
Copy link

Since commit ff91c8d unnecessary.
From this commit on, the env-file is stored within the XDG_CACHE_HOME directory (alternative in ${HOME}/.cache) and as such isn't be stored in a world writeable location (at least I hope nobody has that location writable for anybody except oneself).
The same goes for the gpg-agent.env which, depending of the configuration, might be used instead of the ssh one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants