Skip to content

security: remove embedded DeepSeek API keys; require user/local model setup - #85

Merged
XYAIStudio merged 4 commits into
mainfrom
cursor/security-remove-embedded-keys-0aae
Sep 20, 2026
Merged

XYAIStudio merged 4 commits into
mainfrom
cursor/security-remove-embedded-keys-0aae

Conversation

@XYAIStudio

@XYAIStudio XYAIStudio commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

摘要

桌面安装包不得再携带维护者的云厂商 API Key。本 PR 清除源码与打包路径中可能把真实密钥打进安装包的入口,首次运行不再预填云密钥,空密钥会阻断云调用,并增加 CI / 打包扫描防止回归。

必须立刻做(本 PR 不会代做)

  1. 下架安装包:GitHub Release v0.0.1–v0.0.4 的安装包须删除。(维护者已确认:已从 Release 全部删除。)
  2. 轮换 DeepSeek API Key:请在 DeepSeek 控制台作废并轮换可能已泄露的密钥。本仓库无法替你轮换线上配额;密钥一旦出现在安装包或用户 DB 里即应视为已泄露。

补充证据(不含真实密钥)

  • 用户本机最早备份(2026-09-15,0.0.1 首日)宿主 providers 已有一行:name=DeepSeek,base_url=https://api.deepseek.com/v1,api_key 为真实 sk-…,且 settings.active_model=DeepSeek/deepseek-v4-flash。这与设置向导 _apply_provider_draft 写入的 DeepSeek 预设完全一致,说明问题是首次安装即写入,不是用户后来手填。
  • GitHub Actions repo secrets 列表为空;.github/workflows/octop-desktop.yml 未引用 LLM_API_KEY / DEEPSEEK_API_KEY / LIVE_OPENAI_*。官方 CI 打包不会从 Actions secrets 注入云密钥。

调查结论(根因)

已提交源码与 v0.0.1–v0.0.4 标签中没有硬编码的 sk-+32hex 密钥。官方 CI 也不会注入 LLM secret。

更吻合证据的路径是:本地打安装包时把开发机密钥带进产物,首次运行再写进宿主 providers:

  1. bundle-org-sidecar.sh 的 rsync 会拷贝维护者 modules/openxyos/.env(含 LLM_API_KEY);sidecar seed.ts 曾把 process.env.LLM_API_KEY 写入配置。
  2. 若本地打包/试跑把 ~/.freeos、octop.db 或 dotenv 打进 zip,用户解包后第一次启动就会带着维护者的 DeepSeek 行(active_model=DeepSeek/deepseek-v4-flash)。
  3. 宿主向导在空密钥时若误读环境变量,也会写出同一行;当前源码已不再从 DEEPSEEK_API_KEY / OPENAI_API_KEY / LLM_API_KEY 填云厂商 api_key,并有测试锁定。

改动

  • 打包:sidecar 排除 .env / .freeos / octop.db;package.sh 打 zip 前扫描 staging;发现密钥文件或 DeepSeek 形态 sk- 则失败。
  • 首次运行:Ollama 优先;云厂商空密钥返回 PROVIDER_API_KEY_REQUIRED,不从环境变量预填;空密钥阻断云探测/拉模型。
  • sidecar:生产/air-gap 不回退 LLM_API_KEY;种子 llm_api_key 恒为空。
  • CI:扫描配置模板;断言 octop-desktop.yml 不注入 LLM secret;向导在 env 有假密钥时仍拒绝空 draft。

范围外

  • 不在 DeepSeek 控制台执行轮换。
  • 不改无关功能。

验证

  • uv run pytest tests/unit/desktop/test_packaged_secrets.py tests/integration/test_setup_wizard.py tests/integration/test_provider_fetch_models.py tests/unit/test_green_launch.py -q → 通过
  • 空密钥 fetch-models 断言已改为匹配本地化「API Key」/「密钥」文案
Open in Web Open in Cursor 

cursoragent and others added 4 commits September 20, 2026 13:32
… setup

Stop desktop packaging from copying maintainer .env into the org sidecar.
Never seed or prefill a real cloud API key; prefer local Ollama and block
empty-key cloud calls with a clear error. Add a CI scan for DeepSeek-like
secrets in packaged config templates.

Co-authored-by: XYAI Labs <haoboy8@gmail.com>
Co-authored-by: XYAI Labs <haoboy8@gmail.com>
Admin fetch-models now returns PROVIDER_API_KEY_REQUIRED copy
(API Key / 密钥), not a literal api_key substring.

Co-authored-by: XYAI Labs <haoboy8@gmail.com>
First-run must not persist DeepSeek from DEEPSEEK_API_KEY/OPENAI_API_KEY.
Refuse to zip staging trees that contain .env, octop.db, or .freeos.
Desktop CI workflow does not inject LLM secrets.

Co-authored-by: XYAI Labs <haoboy8@gmail.com>
@XYAIStudio
XYAIStudio marked this pull request as ready for review September 20, 2026 13:56
@XYAIStudio
XYAIStudio merged commit 7118932 into main Sep 20, 2026
12 checks passed
@XYAIStudio
XYAIStudio deleted the cursor/security-remove-embedded-keys-0aae branch September 20, 2026 15:29
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