From 352f99c5b7628bb518353f95d51dc46eef164fba Mon Sep 17 00:00:00 2001 From: Borja Castellano Date: Mon, 9 Nov 2026 12:18:36 -0800 Subject: [PATCH 1/2] fix(dashcore): reject high-S signatures in `verify_data_signature` Since the Base SDK bump in #1214, `EcdsaPublicKey::verify` normalizes S before verifying, so `verify_data_signature` accepted high-S signatures it refused before. A high-S signature is a malleable twin of the low-S one. `verify_data_signature` now checks `is_low_s` before verifying and returns an error for a high-S signature, as it did before the bump. --- dash/src/signer.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dash/src/signer.rs b/dash/src/signer.rs index 6a0bbd458..d491bb122 100644 --- a/dash/src/signer.rs +++ b/dash/src/signer.rs @@ -12,6 +12,7 @@ use crate::sign_message; /// verifies the ECDSA signature /// The provided signature must be recoverable. Which means: it must contain the recovery byte as a prefix +/// A signature with a high S value is rejected because it is a malleable twin of the low-S one. pub fn verify_data_signature( data: &[u8], signature: &[u8], @@ -23,7 +24,10 @@ pub fn verify_data_signature( let pub_key = ECDSAPublicKey::from_slice(public_key).map_err(anyhow::Error::msg)?; - pub_key.inner.verify(&data_hash, sig.signature()?).map_err(anyhow::Error::msg) + let sig = sig.signature()?; + ensure!(sig.is_low_s(), "the signature has a high S value"); + + pub_key.inner.verify(&data_hash, sig).map_err(anyhow::Error::msg) } /// verifies the the hash signature. From provided signature and hash recovers the public key From 9b1df994384469db41843bd8f4859ba35be6e5ee Mon Sep 17 00:00:00 2001 From: Borja Castellano Date: Thu, 12 Nov 2026 03:51:24 -0800 Subject: [PATCH 2/2] test(dashcore): cover high-S rejection in `verify_data_signature` --- dash/src/signer.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dash/src/signer.rs b/dash/src/signer.rs index d491bb122..4ff333f78 100644 --- a/dash/src/signer.rs +++ b/dash/src/signer.rs @@ -125,6 +125,20 @@ mod test { .expect("verification shouldn't fail") } + /// Uses the high-S twin of the signature pinned in `sign_hash_output_is_unchanged`. + #[test] + fn verify_data_signature_rejects_high_s() { + let k = get_keys(); + let data = hex!("fafafa"); + let signature = hex!( + "218f7395d4f8d36f8b53c3b8b34edfda5b618f3ec53e8b9f1f508e75dc8fc85693d66f642b8432e842e615493ffd809922ff3365ef0390b1ece732c76ba5280972" + ); + + let result = verify_data_signature(&data, &signature, &k.public_key_compressed); + + assert_error_contains!(result, "the signature has a high S value"); + } + /// Pins the deterministic (RFC 6979) signature so the key handling in /// `sign_hash` can change without changing its output. #[test]