Skip to content

Conversation

samtoxie
Copy link
Contributor

This PR fixes #1272 for both public key and password targets.

When a keyboard-interactive prompt is offered it will respond with empty responses to given prompts. For targets with enforced 2FA via TOTP for example, this will fail as the code is not correct and the session will terminate. For targets that have 2FA enabled, but don't enforce it this will ensure the connection will be setup as sshd expects those empty responses.

…ional 2fa

Signed-off-by: Sam Toxopeus <sam@toxopeus.it>
@samtoxie
Copy link
Contributor Author

samtoxie commented Feb 27, 2025

The test failure seems to be because the test ssh server ratelimits after wg attempts kb-interactive which then leads to a timeout. Given the current flow it will always attempt it once per connection if mentioned as possible method and key or password fails.

Ideally you'd pick up on the partial success result, so it only attempts is if pw or key already succeeded individually. However AuthResult does not seem to provide this feedback, any idea for a workaround to still pick that up? @Eugeny

@Eugeny
Copy link
Member

Eugeny commented Feb 27, 2025

russh indeed doesn't expose the partial_success flag yet. But I think I've fixed your issue in #1274 - can you please merge or rebase?

Previously Warpgate would try the same RSA key three times with different hash algs, exhausting OpenSSH's auth attempt budget.

@samtoxie
Copy link
Contributor Author

Ah I made a mistake in merging indeed, you caught it quicker than me xD

I wonder if it actually works like this, as at the end we will still worst case attempt n*2 attempts when we also attempt keyboard-interactive for every failed connection. Oh well lets see what the test does.

@Eugeny
Copy link
Member

Eugeny commented Feb 27, 2025

It should work in reality except the cases where the auth limit is <=4 or (very artificial) rsa-sha2-x signature algos are disabled like in that one test - because right now it ends up with:

  • Ed25519 attempt
  • K-I attempt
  • RSA + (best hash) attempt
  • K-I attempt
  • ssh-rsa fallback
  • (OpenSSH default limit of 5 is here)
  • K-I attempt

I'll try to add support for partial_success to russh soon 😅

@Eugeny Eugeny merged commit 95dce41 into warp-tech:main Feb 27, 2025
5 of 8 checks passed
@samtoxie
Copy link
Contributor Author

It should work in reality except the cases where the auth limit is <=4 or (very artificial) rsa-sha2-x signature algos are disabled like in that one test - because right now it ends up with:

* Ed25519 attempt

* K-I attempt

* RSA + (best hash) attempt

* K-I attempt

* ssh-rsa fallback

* (OpenSSH default limit of 5 is here)

* K-I attempt

I'll try to add support for partial_success to russh soon 😅

Indeed, succeeds now. Thanks for your help! Support for partial_success would be awesome indeed, as it would simplify this too. However no rush (no pun intended), I think this is one of the very few cases where it is actually nice to have and for now this workaround is good enough.

Also overall Warpgate really is an awesome project, thanks for all your time and dedication in it 😄. And its been a nice way so far for me to dig some more into rust, as I usually work with different toolchains.

@Eugeny
Copy link
Member

Eugeny commented Feb 27, 2025

Thanks! And thanks for contributing as always

If the stars align I'll have time to try adding partial_success tonight

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.

SSH targets with optional 2fa challenge dont work
2 participants