diff --git a/docker/.env.example b/docker/.env.example index d46247f696f..dfddb102949 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -270,15 +270,6 @@ DIFY_AGENT_STUB_API_BASE_URL=http://agent_backend:5050/agent-stub # Replace this development default in production. # Generate one with: python -c 'import secrets; print(secrets.token_urlsafe(32))' DIFY_AGENT_SERVER_SECRET_KEY=MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY -# Agent sandbox path isolation (Landlock), applied inside the local_sandbox container. -# Set SHELLCTL_ENABLE_PATH_ISOLATION=false to disable Landlock entirely (default: true). -SHELLCTL_ENABLE_PATH_ISOLATION=true -# The paths below override the built-in defaults when set (even to an empty value). -# Leave them commented out to keep the defaults; setting SHELLCTL_LANDLOCK_RO_PATHS or -# SHELLCTL_LANDLOCK_RW_DEV_PATHS to an empty string removes all default paths and can break exec. -# SHELLCTL_LANDLOCK_RW_PATHS= -# SHELLCTL_LANDLOCK_RO_PATHS= -# SHELLCTL_LANDLOCK_RW_DEV_PATHS= # Nginx and Docker Compose NGINX_SERVER_NAME=_ diff --git a/docker/docker-compose-template.yaml b/docker/docker-compose-template.yaml index 8404764f58d..559842ddcc4 100644 --- a/docker/docker-compose-template.yaml +++ b/docker/docker-compose-template.yaml @@ -526,15 +526,11 @@ services: local_sandbox: image: langgenius/dify-agent-local-sandbox:1.16.0-rc1 restart: always + env_file: + - path: ./envs/core-services/local-sandbox.env + required: false environment: - SHELLCTL_AUTH_TOKEN=${DIFY_AGENT_SHELLCTL_AUTH_TOKEN:-} - # Landlock path isolation. SHELLCTL_ENABLE_PATH_ISOLATION defaults to true in the runtime. - - SHELLCTL_ENABLE_PATH_ISOLATION=${SHELLCTL_ENABLE_PATH_ISOLATION:-true} - # Passed through only when set (uncommented) in .env; leaving them unset keeps - # the runtime's built-in defaults. Setting them to empty removes all default paths. - - SHELLCTL_LANDLOCK_RW_PATHS - - SHELLCTL_LANDLOCK_RO_PATHS - - SHELLCTL_LANDLOCK_RW_DEV_PATHS healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5004/healthz"] interval: 30s diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 69ea2c81103..1290b7707f6 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -532,15 +532,11 @@ services: local_sandbox: image: langgenius/dify-agent-local-sandbox:1.16.0-rc1 restart: always + env_file: + - path: ./envs/core-services/local-sandbox.env + required: false environment: - SHELLCTL_AUTH_TOKEN=${DIFY_AGENT_SHELLCTL_AUTH_TOKEN:-} - # Landlock path isolation. SHELLCTL_ENABLE_PATH_ISOLATION defaults to true in the runtime. - - SHELLCTL_ENABLE_PATH_ISOLATION=${SHELLCTL_ENABLE_PATH_ISOLATION:-true} - # Passed through only when set (uncommented) in .env; leaving them unset keeps - # the runtime's built-in defaults. Setting them to empty removes all default paths. - - SHELLCTL_LANDLOCK_RW_PATHS - - SHELLCTL_LANDLOCK_RO_PATHS - - SHELLCTL_LANDLOCK_RW_DEV_PATHS healthcheck: test: ["CMD", "curl", "-f", "http://localhost:5004/healthz"] interval: 30s diff --git a/docker/envs/core-services/dify-agent.env.example b/docker/envs/core-services/dify-agent.env.example index 7eeee49fdbe..be757e456bb 100644 --- a/docker/envs/core-services/dify-agent.env.example +++ b/docker/envs/core-services/dify-agent.env.example @@ -26,17 +26,3 @@ DIFY_AGENT_STUB_API_BASE_URL=http://agent_backend:5050/agent-stub # Replace this development default in production. # Generate one with: python -c 'import secrets; print(secrets.token_urlsafe(32))' DIFY_AGENT_SERVER_SECRET_KEY=MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY - -# --- Agent sandbox path isolation (Landlock) --- -# Applied by the runtime inside the local_sandbox container. -# Set SHELLCTL_ENABLE_PATH_ISOLATION=false to disable Landlock entirely (default: true). -SHELLCTL_ENABLE_PATH_ISOLATION=true -# The paths below override the built-in defaults when set (even to an empty value). -# Leave them commented out to keep the defaults; setting SHELLCTL_LANDLOCK_RO_PATHS or -# SHELLCTL_LANDLOCK_RW_DEV_PATHS to an empty string removes all default paths and can break exec. -# Comma-separated additional read-write directories (default: none beyond $HOME). -# SHELLCTL_LANDLOCK_RW_PATHS= -# Comma-separated read-only + execute directories (default: /usr,/bin,/sbin,/lib,/lib64,/etc,/proc,/opt/dify-agent-tools,/opt/homebrew,/snap). -# SHELLCTL_LANDLOCK_RO_PATHS= -# Comma-separated read-write device files (default: /dev/null,/dev/zero,/dev/urandom,/dev/random,/dev/tty). -# SHELLCTL_LANDLOCK_RW_DEV_PATHS= diff --git a/docker/envs/core-services/local-sandbox.env.example b/docker/envs/core-services/local-sandbox.env.example new file mode 100644 index 00000000000..97eed34d7d8 --- /dev/null +++ b/docker/envs/core-services/local-sandbox.env.example @@ -0,0 +1,16 @@ +# ------------------------------ +# Dify Agent Local Sandbox Configuration +# ------------------------------ + +# Set to false to disable Landlock path isolation (default: true). +SHELLCTL_ENABLE_PATH_ISOLATION=true + +# The paths below override the built-in defaults when set, even to an empty value. +# Leave them commented out to keep the defaults; empty read-only or device path +# lists can prevent commands from running. +# Comma-separated additional read-write directories (default: none beyond $HOME). +# SHELLCTL_LANDLOCK_RW_PATHS= +# Comma-separated read-only and executable directories (default: /usr,/bin,/sbin,/lib,/lib64,/etc,/proc,/opt/dify-agent-tools,/opt/homebrew,/snap). +# SHELLCTL_LANDLOCK_RO_PATHS= +# Comma-separated read-write device files (default: /dev/null,/dev/zero,/dev/urandom,/dev/random,/dev/tty). +# SHELLCTL_LANDLOCK_RW_DEV_PATHS=