Skip to content

fix(line): 不自行註冊 E2EE 群組金鑰,即時解密失敗改顯示佔位 - #3

Merged
YueyuHoshizora merged 1 commit into
mainfrom
fix/issue-2-e2ee-group-key
Oct 21, 2026
Merged

YueyuHoshizora merged 1 commit into
mainfrom
fix/issue-2-e2ee-group-key

Conversation

@YueyuHoshizora

Copy link
Copy Markdown
Contributor

Fixes #2

原因(推論,未以真實帳號重現)

linejs 3.5.0 getE2EELocalPublicKey 在 LINE 對群組金鑰回 NOT_FOUND 時,會呼叫 tryRegisterE2EEGroupKey 自行產生並註冊一把新的群組金鑰。這條路徑:

  • 傳送時會觸發(成員剛變動、LINE 還沒把新世代發到本裝置,此時剛好要回話);
  • 連解密也會觸發:訊息指定的世代 getE2EEGroupSharedKey 回 NOT_FOUND,再 getLastE2EEGroupSharedKey 也 NOT_FOUND 時,讀一則訊息就會註冊新金鑰。

issue 回報的「同一世代下有兩把金鑰、部分可解大部分不可解、換代後痊癒」與「本裝置自行註冊的金鑰和官方 App 的新世代並存」吻合。LINE 伺服器端如何處理同時註冊無法在本機驗證,因此屬推論。

另外,linejs 的即時事件迴圈先 decryptE2EEMessage 再 emit,解密失敗會被 catch 後靜默丟棄(還以 LegyPusherError 記錄),違反本專案「解密失敗 fail-closed 顯示佔位」的規則,也是 issue 裡「即時路徑收不到任何事件」的原因。

修正(只改 adapter)

  • activate 時把 base.e2ee.tryRegisterE2EEGroupKey 改為一律失敗:本服務不再自行建立群組金鑰,只用 LINE 發下的金鑰。
  • 包裝 decryptE2EEMessage:失敗時回傳原密文並標記為無法解密;即時訊息因此顯示「無法解密此訊息」佔位,不再消失。歷史路徑行為不變。

代價:成員剛變動、LINE 尚未發下新金鑰時,本服務傳送 E2EE 群組訊息會失敗(草稿保留)、收到的訊息顯示佔位;成員用官方 App 發言、LINE 建立新金鑰後恢復。

無法修復的部分:已經損壞的世代(如 178007062)無法由本修正救回,仍需換代(新成員加入)。

驗證

  • 新增回歸測試:使用真實 linejs BaseClient/E2EE 程式碼與真實 Client.listen 事件迴圈,只把 LINE 回應換成群組金鑰 NOT_FOUND。確認傳送失敗且未送出密文、歷史與即時訊息都是 decryptFailed 佔位、沒有任何註冊流程。
    • 修正前:同一情境發出 2 次註冊流程(getLastE2EEPublicKeys),即時訊息被丟棄(測試失敗)。
  • npm run typecheck、npm test(363/363)、npm audit --audit-level=high(0)。
  • 未以真實 LINE 帳號驗證,不宣稱通過 Gate。

文件:三語 README、AGENTS(adapter 規則)、PLAN 已同步。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T21:35:58.622143Z 1a2c914 PR opened
🔒 Security Review ✅ Completed 2026-10-21T21:40:34.411770Z 1a2c914 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@YueyuHoshizora
YueyuHoshizora merged commit 68ee382 into main Oct 21, 2026
1 check passed
@YueyuHoshizora
YueyuHoshizora deleted the fix/issue-2-e2ee-group-key branch October 21, 2026 21:37
@YueyuHoshizora YueyuHoshizora self-assigned this Oct 21, 2026
@YueyuHoshizora YueyuHoshizora added the bug Something isn't working label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[E2EE] 群組成員變動換代後,新世代訊息全部解密失敗(舊世代正常)

1 participant