Secure, Fast, and Extensible Sandbox runtime for AI agents.
fix(server): read a backslash as "/" in the Docker root mount check
Jackmeson10391cc2f9d2a
diff --git a/server/opensandbox_server/services/docker/volumes.py b/server/opensandbox_server/services/docker/volumes.pyindex 45e615623..616639489 100644--- a/server/opensandbox_server/services/docker/volumes.py+++ b/server/opensandbox_server/services/docker/volumes.py@@ -61,7 +61,9 @@ class DockerVolumesMixin:for volume in request.volumes:# Docker cleans container paths, including repeated leading slashes.mount_path = posixpath.normpath("/" + volume.mount_path.lstrip("/"))- if mount_path == "/":+ # Docker's root check also reads a backslash as "/"; its duplicate check does not.+ root_path = posixpath.normpath("/" + volume.mount_path.replace("\\", "/").lstrip("/"))+ if root_path == "/":raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST,detail={diff --git a/server/tests/test_docker_service.py b/server/tests/test_docker_service.pyindex 37423aab9..b9c3a0b29 100644--- a/server/tests/test_docker_service.py+++ b/server/tests/test_docker_service.py@@ -4060,6 +4060,8 @@ class TestDockerVolumeValidation:("other", "//", SandboxErrorCodes.INVALID_MOUNT_PATH),("other", "/.", SandboxErrorCodes.INVALID_MOUNT_PATH),("other", "/mnt/..", SandboxErrorCodes.INVALID_MOUNT_PATH),+ ("other", "/\\", SandboxErrorCodes.INVALID_MOUNT_PATH),+ ("other", "/mnt/..\\", SandboxErrorCodes.INVALID_MOUNT_PATH),],)@pytest.mark.asyncio@@ -4113,7 +4115,8 @@ class TestDockerVolumeValidation:assert mock_client.mock_calls == []@pytest.mark.parametrize(- "mount_path", ["/mnt/data/cache", "/mnt/other", "/tmp/opensandbox-execd"]+ "mount_path",+ ["/mnt/data/cache", "/mnt/other", "/tmp/opensandbox-execd", "/mnt\\data", "/mnt/data\\"],)@pytest.mark.asyncioasync def test_nested_and_repeated_source_mounts_allowed(self, mock_docker, mount_path):