Skip to content

Restic tools never pass the repository password, so they fail under sudo #112

Closed

Description

@TMHSDigital

Summary

backupStatus, backupList, backupDiff, backupRestore and volumeBackup run sudo restic -r <repo> ... without any way to supply the repository password. sudo strips RESTIC_PASSWORD/RESTIC_PASSWORD_FILE from the SSH session and there is no terminal to prompt on, so on the setup the skills describe (password kept in /etc/restic-env for the backup script) these tools fail.

Related: #87

Where

  • mcp-server/src/tools/backupStatus.ts:30
  • mcp-server/src/tools/backupList.ts:30
  • mcp-server/src/tools/backupDiff.ts:22
  • mcp-server/src/tools/backupRestore.ts:40
  • mcp-server/src/tools/volumeBackup.ts:29
  • mcp-server/README.md:80 (only HOMELAB_BACKUP_REPO is configurable)
  • skills/backup-recovery/SKILL.md:32 ("Restic repository password (stored in MCP config or environment variable)"), :102 (/etc/restic-env)

Details

homelab_backupRun works because it calls /opt/backup/backup.sh, which loads its own env file. The other restic tools call restic directly with only -r. The skill says the password can be "stored in MCP config", but no such setting exists.

Impact

Five backup tools, and the morning-health-check / pre-reboot-checklist prompts that call homelab_backupStatus, return restic password errors on a standard install instead of snapshot data.

Steps to reproduce

  1. Repository at /mnt/backup/restic whose password is only in /etc/restic-env (as the skill describes).
  2. Call homelab_backupStatus.
  3. restic exits with a password error.

Suggested fix

  • Add HOMELAB_RESTIC_PASSWORD_FILE (path on the node, per-node overridable through HOMELAB_NODES env) and pass --password-file <path> on every restic call through one helper in mcp-server/src/utils/restic.ts. Optionally also support an env file to source (HOMELAB_RESTIC_ENV_FILE, for example /etc/restic-env) so RESTIC_REPOSITORY and remote-backend credentials work too.
  • Document it in mcp-server/README.md, .env.example and the backup-recovery skill, and remove the "stored in MCP config" wording until it is true.

Acceptance criteria

  • All restic-invoking tools pass the configured password file.
  • A clear error names the setting when restic reports a missing password.
  • Command tests assert the flag for each restic tool.

Getting started

  • Relevant files: mcp-server/src/utils/restic.ts, the five tool files above
  • How to run tests: cd mcp-server && npm install && npm test

Filed by repo-audit/full-audit at a59395f. Severity: high. Effort: S. audit-key: bug|mcp-server/src/utils/restic.ts|resticPassword

Activity

  1. added
    bug
    good first issue
    severity: high
    on Nov 18, 2026
  2. TMHSDigital commented on Nov 18, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in c8605e0. All five restic tools now go through resticCommand(), which sources HOMELAB_RESTIC_ENV_FILE (default /etc/restic-env) as root when present and passes HOMELAB_RESTIC_PASSWORD_FILE as --password-file; password failures name both settings. Verified with per-tool command tests, helper tests (363 passing), and by running the generated sh -c wrapper against a stub restic.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuemcp-serverseverity: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions