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

Tokens issued via vault-ssh-helper OTP are not being revoked properly #40

Closed
jrdemasi opened this issue Apr 17, 2019 · 4 comments · Fixed by hashicorp/vault#7777
Closed

Comments

@jrdemasi
Copy link

jrdemasi commented Apr 17, 2019

Currently, I am using SSH OTP to login to some CentOS 7 systems and everything is working as intended (or, at least, as I want them to :-)). However, when I logout, I get output like the following, and tokens are not actually being revoked:

[<sshuser>@hostname ~]$ exit
logout
Connection to xxx.xxx.xx.xx closed.
failed to revoke key: Error making API request.

URL: PUT https://mydomain.tld/v1/sys/leases/revoke/ssh/creds/<sshuser>/ArYTGUV78708q14rXXmNNrZg
Code: 403. Errors:

* 1 error occurred:
	* permission denied

If I manually add a policy to grant access to sys/leases/revoke/ssh/creds/* and apply it to my users, it works fine, but of course they can also revoke any tokens in the path then. Shouldn't this be using auth/token/revoke-self? Is there something I'm missing about the appropriate way to be using this?

Thanks in advance!

@aram535
Copy link

aram535 commented Oct 28, 2019

I also just ran across this. I rather not add revoke to all users.

@jrdemasi
Copy link
Author

jrdemasi commented Oct 30, 2019 via email

@ncabatoff
Copy link

The code that does the revoke actually lives in the vault ssh command, not the helper.

revoke-self isn't the right solution, because that would revoke the token the user used to authenticate to vault, but we just want to revoke the lease that was created for the SSH credentials.

I'm not very familiar with the SSH OTP functionality, but I had a look at when the code in question was introduced, and I saw in an earlier version that it had this comment above it:

	// If the session established was longer than the lease expiry, the secret
	// might have been revoked already. If not, then revoke it. Since the key
	// file is deleted and since user doesn't know the credential anymore, there
	// is not point in Vault maintaining this secret anymore. Every time the command
	// is run, a fresh credential is generated anyways.

This suggests to me that the error message is annoying but could be ignored without risk.

@jefferai
Copy link
Member

jefferai commented Nov 1, 2019

I don't think that's quite the same situation but @ncabatoff is right in that you probably don't want to revoke the token that generated the lease as then every time you SSHed somewhere you'd have to reauthenticate to Vault.

Given that lease IDs are not public and you'd have to know the exact lease ID to revoke it, most people simply grant access to sys/leases/revoke. Although it does look like we should update the bit in the SSH secrets engine to use the body form of the revoke call instead of the path form.

jefferai added a commit to hashicorp/vault that referenced this issue Nov 1, 2019
We didn't make this change earlier because not everyone would have had
an updated version of Vault with this API change but it's definitely
time.

Fixes hashicorp/vault-ssh-helper#40
jefferai added a commit to hashicorp/vault that referenced this issue Nov 5, 2019
We didn't make this change earlier because not everyone would have had
an updated version of Vault with this API change but it's definitely
time.

Fixes hashicorp/vault-ssh-helper#40
jefferai added a commit to hashicorp/vault that referenced this issue Nov 5, 2019
We didn't make this change earlier because not everyone would have had
an updated version of Vault with this API change but it's definitely
time.

Fixes hashicorp/vault-ssh-helper#40
jefferai added a commit to hashicorp/vault that referenced this issue Nov 5, 2019
…7800)

We didn't make this change earlier because not everyone would have had
an updated version of Vault with this API change but it's definitely
time.

Fixes hashicorp/vault-ssh-helper#40
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 a pull request may close this issue.

4 participants