Skip to content

Commit fc18358

Browse files
authored
feat(cli): JWT Validation Using L2 Args (#454)
* feat(cli): l2 jwt validation * fix deny issues
1 parent 7854014 commit fc18358

File tree

4 files changed

+105
-6
lines changed

4 files changed

+105
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/client/cli/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ workspace = true
1515
# General
1616
url.workspace = true
1717
clap.workspace = true
18-
alloy-rpc-types-engine.workspace = true
18+
eyre.workspace = true
19+
20+
# Base
21+
base-jwt = { workspace = true, features = ["engine-validation"] }

crates/client/cli/src/l2.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::path::PathBuf;
44

5-
use alloy_rpc_types_engine::JwtSecret;
5+
use base_jwt::{JwtError, JwtSecret, JwtValidator, resolve_jwt_secret};
66
use url::Url;
77

88
const DEFAULT_L2_ENGINE_TIMEOUT: u64 = 30_000;
@@ -51,3 +51,28 @@ impl Default for L2ClientArgs {
5151
}
5252
}
5353
}
54+
55+
impl L2ClientArgs {
56+
/// Returns the L2 JWT secret for the engine API.
57+
///
58+
/// Resolution order:
59+
/// 1. Read from file path if `l2_engine_jwt_secret` is set
60+
/// 2. Use encoded secret if `l2_engine_jwt_encoded` is set
61+
/// 3. Fall back to default JWT file `l2_jwt.hex`
62+
pub fn jwt_secret(&self) -> Result<JwtSecret, JwtError> {
63+
resolve_jwt_secret(
64+
self.l2_engine_jwt_secret.as_deref(),
65+
self.l2_engine_jwt_encoded,
66+
"l2_jwt.hex",
67+
)
68+
}
69+
70+
/// Validate the jwt secret if specified by exchanging capabilities with the engine.
71+
/// Since the engine client will fail if the jwt token is invalid, this allows to ensure
72+
/// that the jwt token passed as a cli arg is correct.
73+
pub async fn validate_jwt(&self) -> eyre::Result<JwtSecret> {
74+
let jwt_secret = self.jwt_secret().map_err(|e| eyre::eyre!(e))?;
75+
let validator = JwtValidator::new(jwt_secret);
76+
validator.validate_with_engine(self.l2_engine_rpc.clone()).await.map_err(|e| eyre::eyre!(e))
77+
}
78+
}

deny.toml

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
[advisories]
2+
# Ignore unmaintained/vulnerable crates that come from upstream dependencies we cannot control
3+
ignore = [
4+
# rustls-pemfile is unmaintained but comes from bollard -> testcontainers (dev dependency)
5+
# No safe upgrade available, waiting for upstream to migrate to rustls-pki-types
6+
"RUSTSEC-2025-0134",
7+
8+
# tokio-tar has a PAX header vulnerability but comes from testcontainers (dev dependency)
9+
# No safe upgrade available, tokio-tar is archived
10+
"RUSTSEC-2025-0111",
11+
12+
# backoff is unmaintained but comes from rollup-boost -> kona-engine (upstream dependency)
13+
# No safe upgrade available
14+
"RUSTSEC-2025-0012",
15+
16+
# bincode is unmaintained but comes from reth-nippy-jar (upstream reth dependency)
17+
# No safe upgrade available
18+
"RUSTSEC-2025-0141",
19+
20+
# instant is unmaintained but comes from backoff -> rollup-boost (upstream dependency)
21+
# No safe upgrade available
22+
"RUSTSEC-2024-0384",
23+
24+
# paste is unmaintained but widely used in ecosystem (alloy, reth, etc.)
25+
# No safe upgrade available
26+
"RUSTSEC-2024-0436",
27+
]
28+
29+
[licenses]
30+
allow = [
31+
"MIT",
32+
"Apache-2.0",
33+
"Apache-2.0 WITH LLVM-exception",
34+
"BSD-2-Clause",
35+
"BSD-3-Clause",
36+
"ISC",
37+
"Unicode-3.0",
38+
"Unlicense",
39+
"Zlib",
40+
"CC0-1.0",
41+
"MPL-2.0",
42+
"0BSD",
43+
"BSL-1.0",
44+
"OpenSSL",
45+
"CDLA-Permissive-2.0",
46+
]
47+
confidence-threshold = 0.8
48+
149
[bans]
250
deny = ["reth"]
351
multiple-versions = "deny"
@@ -61,7 +109,6 @@ skip = [
61109
"redox_users",
62110

63111
# Network crates
64-
"yamux",
65112
"tungstenite",
66113
"tokio-tungstenite",
67114

@@ -75,7 +122,20 @@ skip = [
75122
"cargo_metadata",
76123
"core-foundation",
77124
"crossterm",
78-
"if-addrs",
125+
"gloo-timers",
126+
"indexmap",
127+
"kona-genesis",
128+
"opentelemetry",
129+
"opentelemetry-http",
130+
"opentelemetry-otlp",
131+
"opentelemetry-proto",
132+
"opentelemetry_sdk",
133+
"prost",
134+
"prost-derive",
135+
"rustc-hash",
136+
"tonic",
137+
"tower",
138+
"tracing-opentelemetry",
79139
"openssl-probe",
80140
"procfs",
81141
"procfs-core",
@@ -84,6 +144,16 @@ skip = [
84144
"toml_datetime",
85145
"toml_edit",
86146
"unicode-width",
87-
"unsigned-varint",
88147
"webpki-roots",
89148
]
149+
150+
[sources]
151+
unknown-registry = "deny"
152+
unknown-git = "deny"
153+
154+
# Allow git sources from known upstream repositories
155+
allow-git = [
156+
"https://github.com/paradigmxyz/reth",
157+
"https://github.com/op-rs/kona",
158+
"https://github.com/flashbots/rollup-boost.git",
159+
]

0 commit comments

Comments
 (0)