Skip to content

Commit d88bfe5

Browse files
committed
fix: pass CHALLENGE_UUID env var for broker authentication
The JWT token for broker auth is generated with the challenge UUID, but CHALLENGE_ID was set to the human-readable name (e.g., 'term-challenge'). This caused a mismatch error when challenges tried to create containers. Now we pass both: - CHALLENGE_ID: Human-readable name (for logging, events) - CHALLENGE_UUID: UUID that matches JWT token (for broker auth) WsContainerClient.from_env() now prefers CHALLENGE_UUID over CHALLENGE_ID.
1 parent 58c8618 commit d88bfe5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

crates/challenge-orchestrator/src/docker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ impl DockerClient {
520520
let mut env: Vec<String> = Vec::new();
521521
// Use challenge NAME (not UUID) so validators can match events by name
522522
env.push(format!("CHALLENGE_ID={}", config.name));
523+
// Also pass the UUID for broker authentication (JWT token uses UUID)
524+
env.push(format!("CHALLENGE_UUID={}", config.challenge_id));
523525
env.push(format!("MECHANISM_ID={}", config.mechanism_id));
524526
// Pass through important environment variables from image defaults
525527
env.push("TASKS_DIR=/app/data/tasks".to_string());

crates/secure-container-runtime/src/ws_client.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ impl WsContainerClient {
3131

3232
/// Create client from environment variables
3333
/// Requires: CONTAINER_BROKER_WS_URL, CONTAINER_BROKER_JWT
34-
/// Optional: CHALLENGE_ID, VALIDATOR_HOTKEY (for owner_id)
34+
/// Optional: CHALLENGE_UUID (preferred), CHALLENGE_ID, VALIDATOR_HOTKEY (for owner_id)
3535
pub fn from_env() -> Option<Self> {
3636
let ws_url = std::env::var("CONTAINER_BROKER_WS_URL").ok()?;
3737
let jwt_token = std::env::var("CONTAINER_BROKER_JWT").ok()?;
38-
let challenge_id =
39-
std::env::var("CHALLENGE_ID").unwrap_or_else(|_| "unknown-challenge".to_string());
38+
// Prefer CHALLENGE_UUID (matches JWT token) over CHALLENGE_ID (human-readable name)
39+
let challenge_id = std::env::var("CHALLENGE_UUID")
40+
.or_else(|_| std::env::var("CHALLENGE_ID"))
41+
.unwrap_or_else(|_| "unknown-challenge".to_string());
4042
let owner_id =
4143
std::env::var("VALIDATOR_HOTKEY").unwrap_or_else(|_| "unknown-owner".to_string());
4244
Some(Self::new(&ws_url, &jwt_token, &challenge_id, &owner_id))

0 commit comments

Comments
 (0)