Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(docker): document security model, harden cookiecutter, add CI cap test (#2384)

LearningCircuit2b707314a8c4
diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml
index 1e76eab635..355dfc7e26 100644
--- a/.github/workflows/docker-tests.yml
+++ b/.github/workflows/docker-tests.yml
@@ -835,10 +835,20 @@ jobs:
- name: Start production container
run: |
mkdir -p "$PWD/ci-data-prod"
+ # Run with the same security settings as docker-compose.yml so CI
+ # catches capability regressions (e.g., missing cap_add that breaks
+ # the entrypoint's chown/gosu in restricted environments).
docker run -d \
--name ldr-prod-test \
-p 5001:5000 \
-v "$PWD/ci-data-prod":/data \
+ --security-opt no-new-privileges:true \
+ --cap-drop ALL \
+ --cap-add CHOWN \
+ --cap-add FOWNER \
+ --cap-add DAC_OVERRIDE \
+ --cap-add SETUID \
+ --cap-add SETGID \
-e LDR_DATA_DIR=/data \
-e LDR_USE_FALLBACK_LLM=true \
-e DISABLE_RATE_LIMITING=true \
diff --git a/cookiecutter-docker/{{cookiecutter.config_name}}/docker-compose.{{cookiecutter.config_name}}.yml b/cookiecutter-docker/{{cookiecutter.config_name}}/docker-compose.{{cookiecutter.config_name}}.yml
index bb71b21321..01fb1ac52a 100644
--- a/cookiecutter-docker/{{cookiecutter.config_name}}/docker-compose.{{cookiecutter.config_name}}.yml
+++ b/cookiecutter-docker/{{cookiecutter.config_name}}/docker-compose.{{cookiecutter.config_name}}.yml
@@ -32,9 +32,20 @@ services:
volumes:
- ldr_data:/data
- ldr_scripts:/scripts
- - ./local_collections/personal_notes:/local_collections/personal_notes/
- - ./local_collections/project_docs:/local_collections/project_docs/
- - ./local_collections/research_papers:/local_collections/research_papers/
+ - ./local_collections/personal_notes:/local_collections/personal_notes/:ro
+ - ./local_collections/project_docs:/local_collections/project_docs/:ro
+ - ./local_collections/research_papers:/local_collections/research_papers/:ro
+ # Security: drop all capabilities, add back only what the entrypoint needs
+ security_opt:
+ - "no-new-privileges:true"
+ cap_drop:
+ - ALL
+ cap_add:
+ - CHOWN # chown -R ldruser:ldruser /data
+ - FOWNER # chmod on files not owned by root
+ - DAC_OVERRIDE # mkdir in /home/ldruser (.config dir)
+ - SETUID # gosu setuid() to switch to ldruser
+ - SETGID # gosu setgid() to switch group
restart: unless-stopped
{%- if cookiecutter._enable_ollama or cookiecutter.enable_searxng %}
depends_on:
@@ -87,6 +98,8 @@ services:
- "/dev/dri:/dev/dri"
{% endif %}
{% endif %}
+ security_opt:
+ - "no-new-privileges:true"
restart: unless-stopped
{% endif %}
diff --git a/docker-compose.yml b/docker-compose.yml
index c25c00a463..19e7b29e7f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -134,16 +134,34 @@ services:
- ./local_collections/personal_notes:/local_collections/personal_notes/:ro
- ./local_collections/project_docs:/local_collections/project_docs/:ro
- ./local_collections/research_papers:/local_collections/research_papers/:ro
+ # ============================================================================
+ # CONTAINER SECURITY — Principle of Least Privilege
+ # ============================================================================
+ # The entrypoint (scripts/ldr_entrypoint.sh) runs as root to fix Docker
+ # volume ownership, then drops to ldruser (UID 1000) via gosu before
+ # starting the application. The privilege timeline is:
+ #
+ # 1. Root phase (brief): mkdir, chmod, chown on /data and /home/ldruser
+ # 2. gosu execve(): irreversible switch to ldruser (empty capability set)
+ # 3. App phase: runs as ldruser with zero capabilities
+ #
+ # We drop ALL capabilities, then add back only what the root phase needs.
+ # no-new-privileges prevents re-escalation after gosu drops privileges.
+ #
+ # WARNING: Removing cap_add entries will break container startup — the
+ # entrypoint will fail with "Operation not permitted" on chown/chmod.
+ # This is especially visible in restricted environments (Proxmox LXC).
+ # ============================================================================
security_opt:
- "no-new-privileges:true"
cap_drop:
- ALL
cap_add:
- - CHOWN # Required for entrypoint to chown /data to ldruser
- - FOWNER # Required for entrypoint to set ownership regardless of file owner
- - DAC_OVERRIDE # Required for entrypoint to access files during permission setup
- - SETUID # Required for gosu to switch from root to ldruser (setuid syscall)
- - SETGID # Required for gosu to switch group to ldruser (setgid syscall)
+ - CHOWN # chown -R ldruser:ldruser /data
+ - FOWNER # chmod on files not owned by root (after chown to ldruser)
+ - DAC_OVERRIDE # mkdir in /home/ldruser (.config dir, mode 755 = no write for others)
+ - SETUID # gosu setuid() syscall to switch to ldruser
+ - SETGID # gosu setgid() syscall to switch group
restart: unless-stopped
depends_on:
ollama: