Skip to content

feat: optional ChaCha encryption for auth.json keys - #4

Merged
cursor[bot] merged 3 commits into
mainfrom
cursor/desktop-secret-encrypt-17c0
Aug 29, 2026
Merged

feat: optional ChaCha encryption for auth.json keys#4
cursor[bot] merged 3 commits into
mainfrom
cursor/desktop-secret-encrypt-17c0

Conversation

@gaoyu06

@gaoyu06 gaoyu06 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

本次改动范围

  • auth.json 里的 API key / OAuth token 可选用 ChaCha20-Poly1305 加密(jcenc1: 信封)
  • 机器本地 secret.key(0600)
  • 默认关闭:CLI 尚不能读密文,默认加密会弄坏引擎登录
  • 明文仍可加载;打开开关后下次保存加密
  • 顺手修了 Linux/Windows 上 macos-private-api feature 导致的 cargo test 失败

是否可直接上线

否。默认关闭,但加了依赖与读写路径,需确认不会误伤 CLI。

上线前是否需要 review

需要(安全向)。

review 的前置条件

  1. docs/secrets.md:这是防随手翻文件,不是对抗本机恶意进程
  2. 确认默认 encrypt_secrets 为 false
  3. CLI 未实现同款信封前,不要改默认
Open in Web Open in Cursor 

cursoragent and others added 3 commits August 28, 2026 19:12
tauri.macos.conf.json holds macOSPrivateApi + transparent, but the cargo
feature was enabled unconditionally, so tauri-build rejected the mismatch
everywhere else and cargo test has been failing on main since v0.2.0.

Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
Provider API keys and the JuCode OAuth token pair are stored as
ChaCha20-Poly1305 envelopes ("jcenc1:<base64>") keyed by a 32-byte random
secret.key created 0600 in the app config dir. This is obfuscation against
casual reads — backups, synced home directories, support bundles — not
protection from anything running as the user; docs/secrets.md says so.

Off by default via config.json's encrypt_secrets, because ~/.jucode/auth.json
is shared with the jucode CLI engine: the desktop drives whatever CLI version
the user has installed, and that CLI would read the envelope as an API key.
Enabling it is for people who only reach the engine through Desktop.

Reads are format-agnostic in both directions, so plaintext files load
unchanged and the next save migrates them; an envelope that won't open is
left intact so a lost key surfaces as "not logged in" rather than a corrupt
save. Values stay JSON strings, and expiry timestamps stay in the clear so
the login/refresh checks work without a key. auth.json itself is now
chmod 0600 whether or not encryption is on.

Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
Bundle the credential file, the config holding encrypt_secrets, and the key
store into an AuthStore so the migration path can be exercised without
mutating $HOME for the whole test process: plaintext loads and the next save
encrypts it, flipping the switch off writes plaintext back, the default
leaves the CLI-shared file in the clear, and saves land at 0600.

Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
@cursor
cursor Bot merged commit 6c19488 into main Aug 29, 2026
2 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.

2 participants