Skip to content

Create rclone credential directories and files with owner-only permissions #1914

Closed

Description

@phernandez

Problem

Follow-up from the reviewed CodeRabbit deep scan (K43). This ticket tracks one distinct fix; duplicate scan rows are consolidated here.

Reviewed evidence and scope

  • K43 (scan ID 379d479d-4b94-4a6a-b616-2604452d5ec9, review A, Low): rclone credentials written with ordinary permissions, no tightening. Owner-only directory/file creation; legacy/local CLI scope.
    Source at current baseline: src/basic_memory/cli/commands/cloud/rclone_config.py:62.

Fix and validation

  • Create rclone credential directories and files with owner-only permissions.
  • Recheck current callers and supported behavior before choosing the smallest complete fix.
  • Add a bounded regression at the affected public or service boundary; demonstrate it fails without the fix.
  • Preserve legitimate inputs and tenant/project boundaries. Run focused tests plus repository static/type checks.

The scan/review establishes the code-level concern described above; it does not establish production exploitation. Conditional branches and local/tooling-only exposure must retain that scope.

Activity

  1. added
    security
    on Oct 28, 2026
  2. claude commented on Oct 28, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 17s —— View job


    Triage

    • Type: Bug (security hardening). Labeled bug; the existing security label stays.
    • Component: CLI (legacy rclone cloud sync). It's local CLI scope, so I didn't apply the cloud label.
    • Priority: Low, matching the scan review. This is local-only exposure and not a demonstrated exploit.
    • Complexity: Simple.
    • Duplicates: A search for related issues found none.

    Findings

    In src/basic_memory/cli/commands/cloud/rclone_config.py:

    • Line 31 creates the config directory with config_dir.mkdir(parents=True, exist_ok=True), which uses default permissions.
    • Lines 62-63 write the rclone config, which holds credentials, with a plain open(config_path, "w"), so the file gets umask-default permissions (often 0644).

    Suggested approach (for whoever picks this up)

    • Create the directory with mode=0o700. Because mkdir's mode doesn't change a directory that already exists, also chmod an existing directory.
    • Write the file with os.open(..., O_WRONLY|O_CREAT|O_TRUNC, 0o600), then os.fchmod or chmod so an existing file is tightened too.
    • Add a regression test that asserts mode 0o700 on the directory and 0o600 on the file. Check it with a permissive umask and with a pre-existing loose file, and confirm it fails without the fix.
    • Skip the permission assertions on Windows.

    I did not implement anything, per triage scope.

  3. added
    bug
    on Oct 28, 2026
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

    bugsecurity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions