Skip to content

Commit f0e85db

Browse files
committed
fix critical vulnerability in ismp-grandpa
1 parent 5613582 commit f0e85db

File tree

9 files changed

+35
-39
lines changed

9 files changed

+35
-39
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ geth-primitives = { path = "./modules/consensus/geth-primitives", default-featur
283283
sync-committee-primitives = { path = "./modules/consensus/sync-committee/primitives", default-features = false }
284284
sync-committee-prover = { path = "./modules/consensus/sync-committee/prover" }
285285
sync-committee-verifier = { path = "./modules/consensus/sync-committee/verifier", default-features = false }
286-
grandpa-verifier-primitives = { version = "0.1.1", path = "./modules/consensus/grandpa/primitives", default-features = false }
287-
grandpa-verifier = { version = "0.1.1", path = "./modules/consensus/grandpa/verifier", default-features = false }
286+
grandpa-verifier-primitives = { version = "0.1.2", path = "./modules/consensus/grandpa/primitives", default-features = false }
287+
grandpa-verifier = { version = "0.1.2", path = "./modules/consensus/grandpa/verifier", default-features = false }
288288
grandpa-prover = { path = "./modules/consensus/grandpa/prover" }
289289

290290
# consensus clients
291291
ismp-bsc = { path = "./modules/ismp/clients/bsc", default-features = false }
292-
ismp-grandpa = { version = "15.0.0", path = "./modules/ismp/clients/grandpa", default-features = false }
292+
ismp-grandpa = { version = "15.0.1", path = "./modules/ismp/clients/grandpa", default-features = false }
293293
ismp-parachain = { version = "15.0.1", path = "./modules/ismp/clients/parachain/client", default-features = false }
294294
ismp-parachain-inherent = { version = "15.0.0", path = "./modules/ismp/clients/parachain/inherent" }
295295
ismp-parachain-runtime-api = { version = "15.0.0", path = "./modules/ismp/clients/parachain/runtime-api", default-features = false }

modules/consensus/grandpa/primitives/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "grandpa-verifier-primitives"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["Polytope Labs <[email protected]>"]
66
license = "Apache-2.0"

modules/consensus/grandpa/primitives/src/justification.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use sp_consensus_grandpa::{
2626
ScheduledChange, SetId, GRANDPA_ENGINE_ID,
2727
};
2828
use sp_core::ed25519;
29-
use sp_runtime::{generic::OpaqueDigestItemId, traits::Header as HeaderT};
29+
use sp_runtime::{generic::OpaqueDigestItemId, traits::Header as HeaderT, RuntimeAppPublic};
3030
use sp_std::prelude::*;
3131

3232
/// A GRANDPA justification for block finality, it includes a commit message and
@@ -243,20 +243,9 @@ where
243243
H: Encode,
244244
N: Encode,
245245
{
246-
log::trace!(target: "pallet_grandpa", "Justification Message {:?}", (round, set_id));
247246
let buf = (message, round, set_id).encode();
248247

249-
let signature_bytes: &[u8] = signature.as_ref();
250-
let sp_finality_signature: ed25519::Signature = signature_bytes
251-
.try_into()
252-
.map_err(|err| anyhow!("Failed to convert ed25519 signature: {err:#?}"))?;
253-
254-
let id_bytes: &[u8] = id.as_ref();
255-
let pub_key: ed25519::Public = id_bytes
256-
.try_into()
257-
.map_err(|err| anyhow!("Failed to convert public key: {err:#?}"))?;
258-
259-
if !sp_io::crypto::ed25519_verify(&sp_finality_signature, &buf, &pub_key) {
248+
if !id.verify(&buf, signature) {
260249
Err(anyhow!("invalid signature for precommit in grandpa justification"))?
261250
}
262251

modules/consensus/grandpa/prover/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ where
158158

159159
Ok(ConsensusState {
160160
current_authorities,
161-
current_set_id: current_set_id + 1,
161+
current_set_id,
162162
latest_height,
163163
latest_hash: hash.into(),
164164
slot_duration,

modules/consensus/grandpa/verifier/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "grandpa-verifier"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["Polytope Labs <[email protected]>"]
66
license = "Apache-2.0"
@@ -14,7 +14,7 @@ keywords = ["substrate", "polkadot-sdk", "ISMP", "interoperability", "GRANDPA"]
1414
targets = ["x86_64-unknown-linux-gnu"]
1515

1616
[dependencies]
17-
codec = { workspace = true, features = ["derive"]}
17+
codec = { workspace = true, features = ["derive"] }
1818
anyhow = { workspace = true, default-features = false }
1919
finality-grandpa = { version = "0.16.0", features = ["derive-codec"], default-features = false }
2020
serde = { workspace = true, features = ["derive"] }

modules/consensus/grandpa/verifier/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async fn follow_grandpa_justifications() {
4444
let relay_ws_url = std::env::var("RELAY_HOST")
4545
.unwrap_or_else(|_| "wss://hyperbridge-paseo-relay.blockops.network:443".to_string());
4646

47-
let para_ids = vec![2000];
47+
let para_ids = vec![1000];
4848

4949
println!("Connecting to relay chain {relay_ws_url}");
5050
let prover = GrandpaProver::<subxt_utils::BlakeSubstrateChain>::new(ProverOptions {
@@ -85,7 +85,7 @@ async fn follow_grandpa_justifications() {
8585

8686
// slot duration in milliseconds for parachains
8787
let slot_duration = 6000;
88-
let hash = prover.client.rpc().block_hash(Some(10u64.into())).await.unwrap().unwrap();
88+
let hash = prover.client.rpc().finalized_head().await.unwrap();
8989
let mut consensus_state = prover.initialize_consensus_state(slot_duration, hash).await.unwrap();
9090
println!("Grandpa proofs are now available");
9191
while let Some(Ok(_)) = subscription.next().await {

modules/ismp/clients/grandpa/Cargo.toml

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ismp-grandpa"
3-
version = "15.0.0"
3+
version = "15.0.1"
44
edition = "2021"
55
authors = ["Polytope Labs <[email protected]>"]
66
license = "Apache-2.0"
@@ -15,9 +15,7 @@ readme = "./README.md"
1515
anyhow = { workspace = true }
1616
codec = { workspace = true, features = ["derive"] }
1717
primitive-types = { workspace = true }
18-
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
1918
merkle-mountain-range = { workspace = true }
20-
finality-grandpa = { version = "0.16.0", features = ["derive-codec"], default-features = false }
2119
frame-benchmarking = { workspace = true, optional = true }
2220
sp-std = { workspace = true }
2321

@@ -39,6 +37,16 @@ sp-core = { workspace = true }
3937
# cumulus
4038
substrate-state-machine = { workspace = true }
4139

40+
[dependencies.scale-info]
41+
version = "2.1.1"
42+
default-features = false
43+
features = ["derive"]
44+
45+
[dependencies.finality-grandpa]
46+
version = "0.16.0"
47+
features = ["derive-codec"]
48+
default-features = false
49+
4250
[features]
4351
default = ["std"]
4452
std = [

parachain/runtimes/nexus/src/lib.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ impl Contains<RuntimeCall> for IsTreasurySpend {
335335
fn contains(c: &RuntimeCall) -> bool {
336336
matches!(
337337
c,
338-
RuntimeCall::Treasury(pallet_treasury::Call::spend { .. })
339-
| RuntimeCall::Treasury(pallet_treasury::Call::spend_local { .. })
338+
RuntimeCall::Treasury(pallet_treasury::Call::spend { .. }) |
339+
RuntimeCall::Treasury(pallet_treasury::Call::spend_local { .. })
340340
)
341341
}
342342
}
@@ -764,20 +764,19 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
764764
fn filter(&self, c: &RuntimeCall) -> bool {
765765
match self {
766766
ProxyType::Any => true,
767-
ProxyType::NonTransfer => {
768-
!matches!(c, RuntimeCall::Balances { .. } | RuntimeCall::Assets { .. })
769-
},
767+
ProxyType::NonTransfer =>
768+
!matches!(c, RuntimeCall::Balances { .. } | RuntimeCall::Assets { .. }),
770769
ProxyType::CancelProxy => matches!(
771770
c,
772-
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })
773-
| RuntimeCall::Utility { .. }
774-
| RuntimeCall::Multisig { .. }
771+
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
772+
RuntimeCall::Utility { .. } |
773+
RuntimeCall::Multisig { .. }
775774
),
776775
ProxyType::Collator => matches!(
777776
c,
778-
RuntimeCall::CollatorSelection { .. }
779-
| RuntimeCall::Utility { .. }
780-
| RuntimeCall::Multisig { .. }
777+
RuntimeCall::CollatorSelection { .. } |
778+
RuntimeCall::Utility { .. } |
779+
RuntimeCall::Multisig { .. }
781780
),
782781
}
783782
}

0 commit comments

Comments
 (0)