Compare commits
2 Commits
security/f
...
security/f
| Author | SHA1 | Date | |
|---|---|---|---|
| ed32487cbe | |||
| 37c5e672b5 |
@@ -253,6 +253,26 @@ class DockerEnvironment(BaseEnvironment):
|
|||||||
# mode uses tmpfs (ephemeral, fast, gone on cleanup).
|
# mode uses tmpfs (ephemeral, fast, gone on cleanup).
|
||||||
from tools.environments.base import get_sandbox_dir
|
from tools.environments.base import get_sandbox_dir
|
||||||
|
|
||||||
|
# SECURITY FIX (V-012): Block dangerous volume mounts
|
||||||
|
# Prevent privilege escalation via Docker socket or sensitive paths
|
||||||
|
_BLOCKED_VOLUME_PATTERNS = [
|
||||||
|
"/var/run/docker.sock",
|
||||||
|
"/run/docker.sock",
|
||||||
|
"/var/run/docker.pid",
|
||||||
|
"/proc", "/sys", "/dev",
|
||||||
|
":/", # Root filesystem mount
|
||||||
|
]
|
||||||
|
|
||||||
|
def _is_dangerous_volume(vol_spec: str) -> bool:
|
||||||
|
"""Check if volume spec is dangerous (docker socket, root fs, etc)."""
|
||||||
|
for pattern in _BLOCKED_VOLUME_PATTERNS:
|
||||||
|
if pattern in vol_spec:
|
||||||
|
return True
|
||||||
|
# Check for docker socket variations
|
||||||
|
if "docker.sock" in vol_spec.lower():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
# User-configured volume mounts (from config.yaml docker_volumes)
|
# User-configured volume mounts (from config.yaml docker_volumes)
|
||||||
volume_args = []
|
volume_args = []
|
||||||
workspace_explicitly_mounted = False
|
workspace_explicitly_mounted = False
|
||||||
@@ -263,6 +283,15 @@ class DockerEnvironment(BaseEnvironment):
|
|||||||
vol = vol.strip()
|
vol = vol.strip()
|
||||||
if not vol:
|
if not vol:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# SECURITY FIX (V-012): Block dangerous volumes
|
||||||
|
if _is_dangerous_volume(vol):
|
||||||
|
logger.error(
|
||||||
|
f"SECURITY: Refusing to mount dangerous volume '{vol}'. "
|
||||||
|
f"Docker socket and system paths are blocked to prevent container escape."
|
||||||
|
)
|
||||||
|
continue # Skip this dangerous volume
|
||||||
|
|
||||||
if ":" in vol:
|
if ":" in vol:
|
||||||
volume_args.extend(["-v", vol])
|
volume_args.extend(["-v", vol])
|
||||||
if ":/workspace" in vol:
|
if ":/workspace" in vol:
|
||||||
|
|||||||
Reference in New Issue
Block a user