Skip to content

Security: protect Traefik dashboard with Authentik and remove root Docker socket access from Authentik worker#600

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/secure-traefik-dashboard-isolate-authentik-worker
Draft

Security: protect Traefik dashboard with Authentik and remove root Docker socket access from Authentik worker#600
Copilot wants to merge 2 commits intomainfrom
copilot/secure-traefik-dashboard-isolate-authentik-worker

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 16, 2026

Traefik dashboard was publicly accessible (middleware line commented out), and the Authentik worker had unrestricted root access to the Docker socket — equivalent to host root on the VPS.

Changes

Traefik dashboard (vps/traefik.yml, media/traefik.yml)

  • Uncommented traefik.http.routers.api.middlewares=authentik@docker on both stacks to enforce Authentik SSO on the dashboard

Authentik worker hardening (vps/auth.yml)

  • Removed user: root
  • Removed direct /var/run/docker.sock volume mount
  • Added socket_docker to the worker's networks — routes Docker API calls through the existing tecnativa/docker-socket-proxy instead
  • Declared socket_docker as external: true in the file's networks: block
# Before
worker:
  networks:
    - authentik
  user: root
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - authentik-media:/media
    ...

# After
worker:
  networks:
    - authentik
    - socket_docker
  volumes:
    - authentik-media:/media
    ...

Post-deploy: Update the Authentik Docker integration URL (Admin → Outposts → Docker Integration) from unix:///var/run/docker.sock to tcp://dockerproxy:2375.

Original prompt

Please secure the Traefik dashboard and remove the root/Docker socket privileges from the Authentik worker in the TheToto/selfhosted repository.

Here are the specific changes to make:

1. Secure Traefik API/Dashboard in vps/traefik.yml
Find the commented out middleware line for the Traefik API and uncomment it.
Change:

      #- 'traefik.http.routers.api.middlewares=authentik@docker'

To:

      - 'traefik.http.routers.api.middlewares=authentik@docker'

2. Secure Traefik API/Dashboard in media/traefik.yml
Find the commented out middleware line for the Traefik API and uncomment it.
Change:

      #- 'traefik.http.routers.api.middlewares=authentik@docker'

To:

      - 'traefik.http.routers.api.middlewares=authentik@docker'

3. Isolate Authentik Worker in vps/auth.yml
In the worker service block:

  • Remove user: root
  • Remove - /var/run/docker.sock:/var/run/docker.sock from the volumes list.
  • Add socket_docker to the networks list for the worker service.
  • At the bottom of the file, ensure socket_docker is declared in the networks: block with external: true (alongside global_net and authentik if applicable).

Example of expected worker configuration:

  worker:
    image: ghcr.io/goauthentik/server:2026.2.1
    restart: unless-stopped
    command: worker
    networks:
      - authentik
      - socket_docker
# ... (rest of environment, without user: root)
    volumes:
      - authentik-media:/media
      - authentik-certs:/certs
      - authentik-templates:/templates

And in the networks: block at the end of the file:

networks:
  authentik:
  global_net:
    external: true
  socket_docker:
    external: true

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: fait une recherche approfondie de vulnerabilités dans mon repo selfhosted

Assistant: J'ai effectué une analyse approfondie de votre dépôt TheToto/selfhosted en examinant les fichiers de configuration Docker Compose (via la recherche de code).

Dans l'ensemble, votre configuration démontre d'excellentes pratiques de sécurité. Vous avez mis en place de très bonnes défenses, mais voici quelques points d'attention et vulnérabilités potentielles que j'ai pu identifier :

🟢 Les excellents points de sécurité (à conserver) :

  1. Gestion des secrets : Aucun mot de passe, clé d'API ou token n'est écrit "en dur" (hardcodé) dans vos fichiers (ex: ${CF_API_KEY}, ${PG_PASS}, ${REDIS_PASSWORD}). Ils sont correctement gérés par des variables d'environnement. (Assurez-vous juste que vos fichiers .env sont bien dans votre .gitignore).
  2. Docker Socket Proxy : Dans vps/traefik.yml, Traefik ne monte pas directement le socket Docker root (/var/run/docker.sock) mais passe par tecnativa/docker-socket-proxy. C'est une excellente pratique pour limiter la surface d'attaque si Traefik venait à être compromis.
  3. Authentification centralisée (OIDC) : Vous utilisez Authentik de manière intensive (Mealie, Watchstate, Torrent, etc.) avec ALLOW_PASSWORD_LOGIN: False (ex: Mealie), ce qui empêche le contournement du SSO.
  4. Headers de sécurité : Dans media/jellyfin.yml et media/plex.yml, les middlewares Traefik intègrent d'excellents en-têtes de sécurité (SSLRedirect, browserXSSFilter, frameDeny, STSPreload, etc.) pour vous protéger contre le XSS et le clickjacking.

⚠️ Risques et Vulnérabilités potentielles à corriger :

1. Traefik Dashboard potentiellement exposé sans authentification

Dans vos fichiers vps/traefik.yml et media/traefik.yml, l'accès à l'API/Dashboard Traefik n'est pas protégé :

      - 'traefik.http.routers.api.entrypoints=https'
      - 'traefik.http.routers.api.service=api@internal'
      #- 'traefik.http.routers.api.middlewares=authentik@docker'

Le problème : L'authentification par authentik@docker est commentée. Comme vous avez défini une defaultRule sur Host(traefik.${APP_DOMAIN}), cela signifie que n'importe qui accédant à l'URL de votre dashboard Traefik aura potentiellement un accès complet sans aucun mot de passe.
Correction : Décommentez la ligne du middleware ou configurez une authentification basicAuth minimale.

2. Socket Docker exposé au Worker Authentik (Privilege Escalation)

Dans vps/auth.yml, le service worker a accès au socket Docker en tant que compte root :

    user: root
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Le problème : Monter le socket Docker directement dans un conteneur en tant que root équivaut à lui donner les droits root sur la machine hôte complète (votre ...

This pull request was created from Copilot chat.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…rker

Co-authored-by: TheToto <12860648+TheToto@users.noreply.github.com>
Copilot AI changed the title [WIP] Secure Traefik dashboard and remove Docker socket privileges Security: protect Traefik dashboard with Authentik and remove root Docker socket access from Authentik worker Mar 16, 2026
Copilot AI requested a review from TheToto March 16, 2026 18:08
@TheToto
Copy link
Copy Markdown
Owner

TheToto commented Mar 16, 2026

pour le socket docker je prefere que tu fqsse son propre proxy avec les permissions necessaires

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants