Skip to content

security: owner-only store, race-free credential files, safer defaults - #161

Merged
vsn411 merged 2 commits into
mainfrom
fix/go-live-hardening
Nov 20, 2026
Merged

vsn411 merged 2 commits into
mainfrom
fix/go-live-hardening

Conversation

@vsn411

@vsn411 vsn411 commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Found during end-to-end testing before go-live (fresh wheel install in a clean home, the real install.sh, a real Claude run, the release workflow).

Security

Problem Before After
Store permissions ~/.secfoo 0755, files 0644: any local user on a shared machine or CI runner could read every prompt (the scanned source), report and finding Store root 0700; an older store is tightened on first use (a store the user doesn't own is left alone)
Credential files cloud.toml, memory.toml, claude-mcp-config.json written with the default umask, then chmod 0600: the secret was briefly world-readable, and a pre-existing 0644 file kept that mode until the chmod New config.write_private_text creates them 0600 (os.open + fchmod)
Default config secfoo config init wrote an active Atlassian [[mcp_servers]] entry, so every claude run executed npx -y mcp-remote@latest (an unpinned download) and started an OAuth flow, Atlassian user or not A commented-out example like the others, with a note to pin a reviewed version
release.yml ${{ inputs.tag }} interpolated into a shell script Passed in as a variable

Release and install

  • Docker. The image ran pip install secfoo (unpinned) after a fixed sleep 60, so the image tagged X.Y.Z could contain the previous release while PyPI's index caught up. release.yml now passes SECFOO_VERSION as a build arg. The Dockerfile installs exactly that version, retries up to 6 times, and ends with secfoo --version. Without the arg it installs the latest release, as before.
  • install.sh. A writable PREFIX without bin/ yet was silently ignored and the binary went to ~/.local/bin. It now creates $PREFIX/bin.

Verification

  • tests/test_store_privacy.py:
    • new and pre-existing stores end up 0700
    • write_private_text creates 0600 files and tightens existing ones
    • the three credential writers produce 0600 files
    • the template parses with no mcp_servers
    • 4 of 5 fail on main
  • The Dockerfile RUN loop, run in /bin/sh with a stub pip: succeeds first time, succeeds after 2 failures, exits 1 after 6 failures, and installs unpinned when no version is given.
  • install.sh run for real with PREFIX=<new dir>: installs v0.3.1 into $PREFIX/bin after the checksum check. Before this change it went to ~/.local/bin.
  • Full suite: 1839 passed. No new lint findings in the touched files.

Not in this PR (needs an account owner):

  • NPM_TOKEN is unset, so @rakfortltd/secfoo was never published, although the README tells users to npm install -g it.
  • The GHCR image is not publicly pullable yet.

🤖 Generated with Claude Code

Satyanarayana Vuppala and others added 2 commits November 20, 2026 13:54
Found in end-to-end testing before go-live:

- ~/.secfoo was 0755 with 0644 files: on a shared machine or CI runner any
  local user could read every prompt (the scanned source), report and
  finding. The store root is now 0700, and an older store is tightened.
- cloud.toml, memory.toml and claude-mcp-config.json were written with the
  default umask and chmod-ed afterwards, so a secret was briefly readable
  (and stayed readable until the chmod if the file pre-existed). They are
  now created 0600 via os.open.
- 'secfoo config init' wrote an active Atlassian MCP entry, so every claude
  run executed 'npx -y mcp-remote@latest' (an unpinned download) and started
  an OAuth flow even for users who never use Atlassian. It is now a
  commented-out example, like the others.
- Docker: the image installed an unpinned 'secfoo' after a fixed 60s sleep,
  so a release image could contain the previous version. release.yml now
  passes the version as a build arg and the Dockerfile retries until PyPI
  serves it.
- release.yml no longer interpolates inputs.tag into a shell script; the
  value reaches the script as a variable.
- install.sh ignored a writable PREFIX whose bin/ did not exist yet and
  silently installed to ~/.local/bin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vsn411
vsn411 merged commit 2b4628d into main Nov 20, 2026
7 checks passed
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.

1 participant