Skip to content

bug: ~/.openwiki permissions are a no-op on Windows — chmod 0o700/0o600 leaves the credential store on inherited ACLs #366

Description

What happens

OpenWiki carefully sets POSIX permissions on its home directory everywhere it is ensured — mkdir(..., { mode: 0o700 }) + chmod(0o700) in ensureOpenWikiHome (src/openwiki-home.ts) and saveOpenWikiEnv (src/env.ts), and 0o600 on .env and the sqlite checkpoint. On Windows, however, Node's fs.chmod only toggles the read-only attribute (documented Node caveat) and the mode option on mkdir/writeFile is ignored — so none of these calls restrict anything. ~/.openwiki just inherits whatever ACL its parent directory grants.

Why it matters

~/.openwiki is the highest-value directory OpenWiki manages:

  • .env holds every provider API key and OAuth token in plaintext — including the ChatGPT refresh token the docs say to treat like a password,
  • openwiki.sqlite holds full chat checkpoint state,
  • connectors/<id>/raw/ holds raw Gmail/Slack/Notion content.

On a default %USERPROFILE% the inherited ACL is usually owner+SYSTEM+Administrators, but nothing guarantees that: any broader ACE on the profile (or a relocated home) flows straight down to the credential store. Verified on a real Windows 11 machine — a directory created under %TEMP% inherited a dozen modify-rights ACEs from its parent, and the existing chmod(0o700) left all of them in place.

Expected

On Windows, the existing 0o700 owner-only intent should be mirrored with an ACL: full control for the current user and SYSTEM only, inheritance removed — best-effort, exactly like the surrounding chmod calls (never failing a run because ACL tooling is unavailable).

I have a tightly-scoped, dependency-free fix (two icacls invocations, grant-before-inheritance-reset so a failed grant can never lock the user out) with tests ready — PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions