Skip to content

Commit

Permalink
fix: validate challenge to sign (#127)
Browse files Browse the repository at this point in the history
validate challenge to sign
  • Loading branch information
leanmendoza authored Oct 14, 2024
1 parent 0d9e648 commit 6e2b0cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/comms/src/archipelago.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ async fn archipelago_handler_inner(
// send challenge response
debug!("<< challenge received; {challenge_to_sign}");

if !challenge_to_sign.starts_with("dcl-") {
error!("invalid challenge to sign");
return Err(anyhow!("invalid challenge to sign"));
}

// sign challenge
let chain = wallet.sign_message(challenge_to_sign).await?;
let auth_chain_json = serde_json::to_string(&chain)?;
Expand Down
5 changes: 5 additions & 0 deletions crates/comms/src/websocket_room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ async fn websocket_room_handler_inner(
// send challenge response
debug!("<< challenge received; {challenge_to_sign}");

if !challenge_to_sign.starts_with("dcl-") {
error!("invalid challenge to sign");
return Err(anyhow!("invalid challenge to sign"));
}

// sign challenge
let chain = wallet.sign_message(challenge_to_sign).await?;
let auth_chain_json = serde_json::to_string(&chain)?;
Expand Down

0 comments on commit 6e2b0cb

Please sign in to comment.