Skip to content

Commit 0d30bfa

Browse files
committed
feat: remove image whitelist by default, allow all public images
- Default SecurityPolicy now has empty allowed_image_prefixes (allow all) - validate_image() skips check if whitelist is empty - Added strict() for production with ghcr.io/platformnetwork/ only - Added allow_all_images() and with_image_prefix() builder methods This allows challenges to use any Docker Hub or other public images like alexgshaw/* used by terminal-bench tasks.
1 parent d7be22b commit 0d30bfa

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ impl Default for SecurityPolicy {
5656
forbidden.insert("/dev".to_string());
5757

5858
Self {
59-
allowed_image_prefixes: vec!["ghcr.io/platformnetwork/".to_string()],
59+
// Empty = allow all images (challenges can use any public image)
60+
// For strict mode, populate this with allowed prefixes
61+
allowed_image_prefixes: vec![],
6062
max_memory_bytes: 8 * 1024 * 1024 * 1024, // 8GB
6163
max_cpu_cores: 4.0,
6264
max_pids: 512,
@@ -72,23 +74,35 @@ impl Default for SecurityPolicy {
7274
}
7375

7476
impl SecurityPolicy {
75-
/// Create a strict policy for production
77+
/// Create a strict policy for production with image whitelist
7678
pub fn strict() -> Self {
77-
Self::default()
79+
let mut policy = Self::default();
80+
// Only allow platform images in strict mode
81+
policy.allowed_image_prefixes = vec!["ghcr.io/platformnetwork/".to_string()];
82+
policy
7883
}
7984

8085
/// Create a more permissive policy for development
8186
pub fn development() -> Self {
8287
let mut policy = Self::default();
83-
policy
84-
.allowed_image_prefixes
85-
.push("localhost:5000/".to_string());
8688
policy
8789
.allowed_mount_prefixes
8890
.push("/workspace/".to_string());
8991
policy
9092
}
9193

94+
/// Allow all images (no whitelist check)
95+
pub fn allow_all_images(mut self) -> Self {
96+
self.allowed_image_prefixes.clear();
97+
self
98+
}
99+
100+
/// Add allowed image prefix
101+
pub fn with_image_prefix(mut self, prefix: &str) -> Self {
102+
self.allowed_image_prefixes.push(prefix.to_string());
103+
self
104+
}
105+
92106
/// Validate a container configuration against policy
93107
pub fn validate(&self, config: &ContainerConfig) -> Result<(), ContainerError> {
94108
// Check image is whitelisted
@@ -120,7 +134,13 @@ impl SecurityPolicy {
120134
}
121135

122136
/// Validate image is from allowed registry
137+
/// If allowed_image_prefixes is empty, all images are allowed
123138
pub fn validate_image(&self, image: &str) -> Result<(), ContainerError> {
139+
// Empty whitelist = allow all images
140+
if self.allowed_image_prefixes.is_empty() {
141+
return Ok(());
142+
}
143+
124144
let image_lower = image.to_lowercase();
125145

126146
for prefix in &self.allowed_image_prefixes {

0 commit comments

Comments
 (0)