Skip to content

fix(daemon): lock entitlement cache file permissions#78

Merged
hyperb1iss merged 1 commit into
mainfrom
codex/fix-plaintext-caching-of-entitlement-jwt
May 19, 2026
Merged

fix(daemon): lock entitlement cache file permissions#78
hyperb1iss merged 1 commit into
mainfrom
codex/fix-plaintext-caching-of-entitlement-jwt

Conversation

@hyperb1iss
Copy link
Copy Markdown
Owner

Motivation

  • The entitlement cache stored raw JWTs in entitlement.json using tokio::fs::write, which on Unix can produce world-readable files depending on the process umask and risk local token disclosure.
  • The change aims to protect the sensitive entitlement JWT on disk by enforcing owner-only permissions when persisting the cache.

Description

  • Replace direct tokio::fs::write with a dedicated helper write_entitlement_cache and call it from store_entitlement_response to centralize cache writes.
  • On Unix the helper opens the file with OpenOptionsExt::mode(0o600) (via spawn_blocking) to enforce owner-only read/write permissions.
  • On non-Unix platforms the helper falls back to tokio::fs::write to preserve existing behavior.
  • Extend the unit test cloud_entitlement_cache_round_trips_and_deletes_token to assert the cached file mode is 0600 on Unix.

Testing

  • Ran the targeted unit test cloud_entitlement_cache_round_trips_and_deletes_token in the hypercolor-daemon crate; the build/test run was started in the session but did not complete within the time window.
  • Added an automated assertion that checks file permissions (0o600) on Unix as part of the existing test to prevent regressions.

Codex Task

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@hyperb1iss has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 32 minutes and 28 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d085827-bf77-4d12-8916-d3ef5760d2d1

📥 Commits

Reviewing files that changed from the base of the PR and between cdffd2b and 30293e4.

📒 Files selected for processing (2)
  • crates/hypercolor-daemon/src/cloud_entitlements.rs
  • crates/hypercolor-daemon/tests/cloud_api_tests.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-plaintext-caching-of-entitlement-jwt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hyperb1iss hyperb1iss force-pushed the codex/fix-plaintext-caching-of-entitlement-jwt branch from b0c0992 to 30293e4 Compare May 19, 2026 09:01
@hyperb1iss hyperb1iss merged commit e8f4a72 into main May 19, 2026
@hyperb1iss hyperb1iss deleted the codex/fix-plaintext-caching-of-entitlement-jwt branch May 19, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant