[Feature] 远程连接的秘密生命周期:Go 侧答案按 S14 清零,删除连接时处理保留会话的令牌
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 24/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go, typescript
- Domain
- authentication, desktop-dev, security
Research direction
Start at desktop/internal/workbench/git_auth.go (answerGitAuth) and follow the secret into desktop/internal/core/gitauth.go, core/remote.go, credentials/credentials.go (Store.Get/Set) and remoteconn/answers.go, noting every copy, since encoding/json and cgo/syscall boundaries may duplicate it. For part 2 read remoteconn/kept.go (keptAccount) and the @host/remote-sessions entries, and decide how kept sessions group per saved connection plus the migration from the old keys. Done means no string copies of secrets remain, buffers are zeroed, and deleting a connection clears or prompts for its kept sessions.
Written by the indexing model from the issue text.
Description
Problem to solve / 要解决的问题
#2231 的 S14 要求秘密用完立即从内存清零:Go 侧用 []byte 持有,用完清零,不转成 string。设置表“连接”一行要求删除连接、清除已记住的秘密后,钥匙串里不留这台机器的秘密。桌面端现在有两处没做到。
1. Go 侧以 string 持有密码和口令,无法清零
desktop/internal/workbench/git_auth.go的answerGitAuth用g.field.Text()从 Viva 的ui.Field取出string。Viva 输入框内部也用字符串保存内容。desktop/internal/core/gitauth.go的Client.GitAuthRespond和desktop/internal/core/remote.go的Client.RemoteAuthRespond参数是*string,再编码成 JSON 交给 Core。desktop/internal/credentials/credentials.go的Store.Get/Store.Set以string读写秘密。“记住密码”(desktop/internal/remoteconn/answers.go)保存的答案以 JSON 的string字段编解码。
Go 的 string 不可改写,在垃圾回收之前,这些副本会一直留在堆上。影响:进程内存转储或交换文件里可能残留密码和私钥口令。
2. 删除已保存的连接后,保留会话的令牌还在钥匙串里
- 保留会话的令牌存在
@host/remote-sessions,键是desktop/internal/remoteconn/kept.go的keptAccount(connectionID)。删除连接时没有清理这些令牌,也没有停止或提示远端仍在运行的保留进程。 - 同一台主机上的容器以
<已保存连接 id>/<容器身份>作为连接 id,钥匙串接口不能按前缀列出条目,删除连接时找不到它们。 - 影响:令牌残留在钥匙串里;远端进程失去入口,用户既接不回也停不掉。
记住的密码不受第 2 点影响:它按已保存连接的 id 存放(容器截掉 / 之后的部分),删除连接时已一并清除。
Proposed solution / 建议方案
1. 秘密全程用 []byte 持有,用完清零
- Viva 的密码输入框提供以
[]byte读取并清空内部缓冲的接口。在 Lithe-IDEA/viva 修改,同时向上游 vivaui/viva 提 PR。 core.Client的应答方法改收[]byte,编码请求时不经过string,发出后清零。credentials.Store增加[]byte版本的读写,macOS 钥匙串和 Windows 凭据管理器的实现读写后清零。remoteconn记住的答案改用不经过string的编码。
风险:encoding/json、cgo 边界和系统 API 可能仍会复制数据。需要逐层确认副本在哪里,做不到清零的地方写进 Agent Note。
2. 删除连接时处理它的保留会话
- 先列出这个连接(包括它上面的容器)的保留会话,询问是否同时停止远端进程,再删除令牌。
- 保留会话改为按所属的已保存连接分组存放,例如每个已保存连接一个条目,里面按容器身份区分,这样删除时能一次找全。
风险:存储格式变化要兼容已有条目,读取旧键后迁移到新格式。
Target platform / 目标平台
Cross-platform / 跨平台
Area / 模块
Remote and WSL / 远程与 WSL
Priority / 优先级
P2 / 后续考虑:目前不着急,可安排到后续版本
Alternatives considered / 已考虑的替代方案
- 依靠垃圾回收释放
string:回收时机不确定,不满足 S14。 - 删除连接时只删除这个连接 id 本身的令牌:容器的令牌仍然残留,只解决一半。
- 删除连接时直接删除令牌、不处理远端进程:远端进程失去入口,用户接不回也停不掉。
Additional context / 补充信息
- 设计依据:#2231 的 S12、S14 和设置表“连接”一行。
- 在 #2231 实现“SSH 身份验证”窗口的“记住密码”勾选时发现。那次改动已做到:只在勾选且登录成功后写入钥匙串,只在主机第一次询问时自动填入,被拒绝就删除,验证码和主机指纹从不记住,删除连接时清除记住的密码。上面两点需要单独设计,所以单独建单。
Checklist / 提交前检查
- I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
- Dominant language
- TypeScript
- Stars
- 1.8k
- Forks
- 151
- Avg merge
- 3h 48m
- Merged PRs (30d)
- 571
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 1lck/Lithe-IDEA
-
review: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
1lck/Lithe-IDEA#2432 ·
Maintainers usually reply within 1 day
-
review: medium
Difficulty 1/5 Under an hour Newbie friendliness 82/100
1lck/Lithe-IDEA#2431 ·
Maintainers usually reply within 1 day
-
refactor review: high
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
1lck/Lithe-IDEA#2376 ·
Maintainers usually reply within 1 day
-
area:ui enhancement P2 platform:cross-platform refactor review: high
Difficulty 1/5 Under an hour Newbie friendliness 84/100
1lck/Lithe-IDEA#2365 ·
Maintainers usually reply within 1 day
-
review: medium
Difficulty 3/5 1-2 days Newbie friendliness 57/100
1lck/Lithe-IDEA#2434 ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
rel: fix
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Deltares/fews-web-oc#2400 ·
Maintainers usually reply within 1 day
-
Command bar: Tab-to-search on claude.ai falls back to Google site: search instead of opening a prompt on ClaudePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ardia-browser/ardia#4426 ·
Maintainers usually reply within 1 day
-
Bug report: isValidISODateDashOnly accepts text before or after the date-timePossibly taken @bardrop claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
pnp/cli-microsoft365#7713 ·
Maintainers usually reply within 1 day
-
Diagram: Journey Type: Bug / Error
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
mermaid-js/mermaid-v13#1293 ·
Maintainers usually reply within 1 day