Skip to content

Commit a0cdc2d

Browse files
committed
fix potential infinite loop in parse_x509_der_multi()
Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
1 parent 750d092 commit a0cdc2d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

crates/types/src/utils.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use anyhow::anyhow;
12
use x509_parser::oid_registry::asn1_rs::FromDer;
23
use x509_parser::prelude::*;
34

@@ -33,7 +34,14 @@ pub fn parse_x509_der_multi(raw_bytes: &[u8]) -> crate::Result<Vec<X509Certifica
3334
let mut certs = Vec::new();
3435
let mut i = raw_bytes;
3536
while !i.is_empty() {
37+
let original_len = i.len();
3638
let (j, cert) = X509Certificate::from_der(i)?;
39+
// Check that parser is making progress to avoid infinite loop
40+
if j.len() >= original_len {
41+
return Err(anyhow!(
42+
"X.509 parser not making progress, possible infinite loop"
43+
));
44+
}
3745
certs.push(cert);
3846
i = j;
3947
}
156 Bytes
Binary file not shown.

zkvm/risc0/src/methods.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
pub const DCAP_QUOTE_VERIFIER_ID: [u32; 8] = [670652583, 3052685693, 4223741116, 373457406, 3379441760, 859408996, 511595924, 2088624085];
3-
pub const DCAP_QUOTE_VERIFIER_ID_STR: &str = "a758f9277d49f4b5bc2cc1fbfe81421660306ec9648a393394557e1ed5df7d7c";
2+
pub const DCAP_QUOTE_VERIFIER_ID: [u32; 8] = [1469344566, 2571982276, 2356695967, 1474046247, 981647680, 2103389531, 2739361402, 3432988093];
3+
pub const DCAP_QUOTE_VERIFIER_ID_STR: &str = "366b9457c4554d999f53788c2729dc5740c1823a5b2d5f7d7a5647a3bd3d9fcc";
44
pub const DCAP_QUOTE_VERIFIER_ELF: &[u8] = include_bytes!("../artifacts/dcap-quote-verifier");

0 commit comments

Comments
 (0)