Skip to content

Commit

Permalink
Client checks pubkey in challenge before signing
Browse files Browse the repository at this point in the history
  • Loading branch information
timweri committed Nov 9, 2023
1 parent 2f860c1 commit 020c7b9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rustica-agent/src/rustica/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ pub async fn complete_rustica_challenge(
SSHCertificate::from_string(&response.challenge).map_err(|_| RefreshError::SigningError)?;
challenge_certificate.signature_key = challenge_certificate.key.clone();

// We assert that the pubkey in the challenge belongs to the client
// This prevents a malicious Rustica server from tricking the client into signing a
// malicious SSH certificate for some unknown key.
if challenge_certificate.key.fingerprint().hash != ssh_pubkey.fingerprint().hash {
debug!("The public key in the challenge doesn't match the client's publickey");
return Err(RefreshError::SigningError);
}

let resigned_certificate = match signatory {
Signatory::Yubikey(signer) => {
let signature = signer
Expand Down

0 comments on commit 020c7b9

Please sign in to comment.