Skip to content

Commit 5d24cb5

Browse files
committed
limit setup token validity
1 parent 40eb0eb commit 5d24cb5

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

crates/defguard_core/src/handlers/component_setup.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ use crate::{
6767

6868
const TOKEN_CLIENT_ID: &str = "Defguard Core";
6969
const CONNECTION_TIMEOUT: Duration = Duration::from_secs(10);
70+
/// Maximum lifetime of a one-time setup session token.
71+
/// The setup handshake must complete within this window; tokens that outlive
72+
/// it are useless and limiting the expiry reduces the damage window if the
73+
/// token is captured from the plaintext setup channel.
74+
const SETUP_TOKEN_EXPIRY_SECS: u64 = 300;
7075

7176
/// Guard that aborts a tokio task when dropped
7277
struct TaskGuard(tokio::task::JoinHandle<()>);
@@ -358,7 +363,7 @@ pub async fn setup_proxy_tls_stream(
358363
defguard_common::auth::claims::ClaimsType::Gateway,
359364
url.to_string(),
360365
TOKEN_CLIENT_ID.to_string(),
361-
u32::MAX.into(),
366+
SETUP_TOKEN_EXPIRY_SECS,
362367
)
363368
.to_jwt()
364369
{
@@ -802,7 +807,7 @@ pub async fn setup_gateway_tls_stream(
802807
defguard_common::auth::claims::ClaimsType::Gateway,
803808
url.to_string(),
804809
TOKEN_CLIENT_ID.to_string(),
805-
u32::MAX.into(),
810+
SETUP_TOKEN_EXPIRY_SECS,
806811
)
807812
.to_jwt()
808813
{

0 commit comments

Comments
 (0)