Skip to content

🔒 [security] encrypt token cache and configuration at rest#105

Open
cmuench wants to merge 1 commit into
mainfrom
security-encrypt-config-at-rest-7106440122432922954
Open

🔒 [security] encrypt token cache and configuration at rest#105
cmuench wants to merge 1 commit into
mainfrom
security-encrypt-config-at-rest-7106440122432922954

Conversation

@cmuench
Copy link
Copy Markdown
Contributor

@cmuench cmuench commented May 8, 2026

This PR addresses a security vulnerability where authentication tokens and secrets were stored in plaintext JSON files.

🎯 What: Introduced encryption at rest for config.json and token-cache.json.
⚠️ Risk: Storing secrets in plaintext on disk exposes them to any local user or process with read access, which is especially risky on multi-tenant developer workstations.
🛡️ Solution:

  • Implemented encryption using Node.js native crypto module with aes-256-ctr.
  • Derived a semi-stable encryption key from os.hostname() and os.userInfo().username.
  • Updated saveConfig, loadConfig, saveTokenCache, and loadTokenCache in lib/config.js to handle encrypted data.
  • Added a fallback mechanism to support existing plaintext configuration files.
  • Updated tests/config.test.js to account for the new encryption layer.
  • Added tests/token_encryption_repro.test.js to verify encryption works as expected.

PR created automatically by Jules for task 7106440122432922954 started by @cmuench

Implemented encryption for `config.json` and `token-cache.json` using `aes-256-ctr` with a key derived from system information. This provides defense in depth for sensitive credentials like authentication tokens and client secrets. Added backward compatibility to read existing plaintext files and updated tests to handle the new encrypted format.

Co-authored-by: cmuench <211294+cmuench@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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