Skip to content

security: stop writing API key into local_client.py#18

Merged
Bradymck merged 2 commits into
mainfrom
security/no-plaintext-key
Jun 10, 2026
Merged

security: stop writing API key into local_client.py#18
Bradymck merged 2 commits into
mainfrom
security/no-plaintext-key

Conversation

@Bradymck

@Bradymck Bradymck commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Older versions of openhome local start regex-patched the user's live OpenHome API key into ~/.openhome/local/local_client.py as a Python string literal. This left the key persisting on disk in plaintext, swept into backups (Time Machine / Dropbox / iCloud), and readable by any process running as the user.
  • Pass the API key via OPENHOME_API_KEY env var to the spawned Python process instead — never written to disk.
  • Added a one-shot scrub on local start: if an existing local_client.py still has a patched literal from an older CLI, replace it with os.environ.get("OPENHOME_API_KEY", "").

User action required

  • Rotate your OpenHome API key in the dashboard. Anyone with a copy of your ~/.openhome/local/local_client.py (backups, sync folders, shared dev machines) has the previous value.
  • Update local_client.py to read os.environ["OPENHOME_API_KEY"] if it currently hardcodes one.

Test plan

  • npm run build passes (pre-existing TS errors in assign.ts/client.ts are unrelated and unchanged in count)
  • openhome local start with no prior local_client.py prints the manual download instructions (unchanged)
  • With a stale local_client.py containing OPENHOME_API_KEY = "sk-...", openhome local start scrubs it back to os.environ.get(...) and prints the scrub notice
  • Spawned Python process sees OPENHOME_API_KEY in its environment

🤖 Generated with Claude Code

Bradymck and others added 2 commits June 9, 2026 16:35
Older versions regex-patched the live OpenHome API key directly into
~/.openhome/local/local_client.py as a Python string literal. The key
then persisted on disk in plaintext, would be swept into Time Machine
or any user-level backup, and could leak via casual `cat` or
file-sync tools (Dropbox/iCloud).

Fix:
- Pass OPENHOME_API_KEY to the spawned Python via env on the child
  process only. Never write the key to disk.
- On `local start`, if an existing local_client.py still contains a
  patched literal from a prior CLI version, scrub it back to
  os.environ.get("OPENHOME_API_KEY", "") so the leaked-on-disk copy
  is removed in-place.
- Users with an existing install should rotate their API key in the
  OpenHome dashboard since the previous value lived in a plaintext
  file. local_client.py must read the key from
  os.environ["OPENHOME_API_KEY"].

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Security patch — stop writing API key into local_client.py on disk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Bradymck Bradymck merged commit bcfaf4b into main Jun 10, 2026
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