Skip to content

fix(matrix): fix E2EE SSSS bootstrap for passwordless token-auth bots#66228

Merged
gumadeiras merged 9 commits into
openclaw:mainfrom
SARAMALI15792:fix/matrix-e2ee-ssss-bootstrap
Apr 15, 2026
Merged

fix(matrix): fix E2EE SSSS bootstrap for passwordless token-auth bots#66228
gumadeiras merged 9 commits into
openclaw:mainfrom
SARAMALI15792:fix/matrix-e2ee-ssss-bootstrap

Conversation

@SARAMALI15792

@SARAMALI15792 SARAMALI15792 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #66171

Passwordless token-auth Matrix bots fail to complete E2EE bootstrap when the homeserver has existing SSSS data but the bot has no local recovery key.

Problem Statement

Two independent bugs in extensions/matrix/src/matrix/sdk.ts combine to permanently block E2EE bootstrap for passwordless token-auth bots connecting to a homeserver with existing (but inaccessible) SSSS:

Bug 1: MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS (line 140) is missing allowSecretStorageRecreateWithoutRecoveryKey: true. Without this flag, when bootstrapCrossSigning encounters a null getSecretStorageKey response (because the bot has no local recovery key), shouldRepairSecretStorage evaluates to false && true = false, so SSSS is never recreated. The explicit bootstrap path (bootstrapOwnDeviceVerification) already sets this flag correctly — the initial auto-startup path does not.

Bug 2: bootstrapCryptoIfNeeded repair path (line ~609) is gated behind this.password?.trim(). Passwordless token-auth bots have no password, so even if Bug 1 were fixed, the repair bootstrap would never run. The intent of the gate was to ensure a UIA credential was available — but UIA failures are already caught and logged gracefully in the existing try/catch, so the gate is overly conservative.

Solution Approach Applied

Two minimal edits to extensions/matrix/src/matrix/sdk.ts:

Edit 1 — Add flag to initial bootstrap options (~line 140):

const MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS = {
  allowAutomaticCrossSigningReset: false,
  allowSecretStorageRecreateWithoutRecoveryKey: true,  // added
} satisfies MatrixCryptoBootstrapOptions;

Edit 2 — Remove password gate in repair path (~line 609):
Replace else if (this.password?.trim()) { ... } else { LogService.warn(...) } with a plain else { ... } — the try/catch body stays identical, only the gate is removed. Added comment explaining passwordless repair intent to prevent regression.

Test updates in extensions/matrix/src/matrix/sdk.test.ts:

  • Line 1283: Update initial bootstrap options assertion to include new flag
  • Lines 1287-1324: Update test to assert repair runs without password (was asserting repair does NOT run)
  • Lines 1326-1358: New regression test verifying repair catches UIA failure without throwing

Bottleneck Solved

Before: Fresh bot / bot with wiped data directory connecting to homeserver that has existing SSSS → getSecretStorageKey returns null → error silently swallowed → no repair attempted → bot stays unverified forever.

After: Same scenario → getSecretStorageKey returns null → repair bootstrap runs → SSSS recreated with new keys → bot becomes verified.

Expected Outcomes

  • Passwordless token-auth bots can complete E2EE bootstrap on first connection to homeserver with existing SSSS
  • Bots with wiped data directories can recover by recreating SSSS
  • UIA failures (when homeserver requires password but bot has none) are caught and logged as warnings, not fatal errors
  • No behavior change for bots with passwords or explicit bootstrap flows

Current Flow

  1. Bot connects to homeserver with encryption enabled
  2. Initial bootstrap runs with MATRIX_INITIAL_CRYPTO_BOOTSTRAP_OPTIONS (now includes allowSecretStorageRecreateWithoutRecoveryKey: true)
  3. If getSecretStorageKey returns null, bootstrapCrossSigning recreates SSSS
  4. If initial bootstrap incomplete and device not owner-signed, repair bootstrap runs (no password gate)
  5. Repair bootstrap attempts SSSS recreation with MATRIX_AUTOMATIC_REPAIR_BOOTSTRAP_OPTIONS
  6. UIA failures caught and logged, bot continues operating

Verification

pnpm build passes (TypeScript compilation confirms types are correct).

Full test suite not run in this PR (monorepo tests take 10+ min). CI will verify.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: S labels Apr 14, 2026
@greptile-apps

greptile-apps Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes two interrelated E2EE bootstrap bugs for passwordless token-auth Matrix bots: (1) adds allowSecretStorageRecreateWithoutRecoveryKey: true to the initial bootstrap options so SSSS can be recreated when no recovery key is present, and (2) removes the this.password?.trim() guard from the repair path so passwordless bots attempt forced-reset repair — with UIA failures caught and logged by the existing try/catch. Test coverage covers the happy path, successful repair without password, and UIA error resilience.

Confidence Score: 5/5

Safe to merge — fixes are narrowly scoped, pre-existing error handling is preserved, and test coverage directly validates both new behaviors.

No P0/P1 issues found. The logic correctly gates repair on !status.signedByOwner, the catch block already covered UIA failures for password-bots, and extending it to passwordless bots is the intended semantic.

No files require special attention.

Reviews (1): Last reviewed commit: "test(matrix): add regression test for re..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b3fcc90b0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/matrix/src/matrix/sdk.ts Outdated
@gumadeiras gumadeiras self-assigned this Apr 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Apr 15, 2026
@gumadeiras
gumadeiras force-pushed the fix/matrix-e2ee-ssss-bootstrap branch from ead329a to 8e4b4a0 Compare April 15, 2026 15:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e4b4a019b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/matrix/src/matrix/sdk.ts
@gumadeiras
gumadeiras force-pushed the fix/matrix-e2ee-ssss-bootstrap branch from cc37e54 to c62cebf Compare April 15, 2026 15:48
@gumadeiras
gumadeiras merged commit b2753fd into openclaw:main Apr 15, 2026
25 of 26 checks passed
@gumadeiras

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @SARAMALI15792!

xudaiyanzi pushed a commit to xudaiyanzi/openclaw that referenced this pull request Apr 17, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…openclaw#66228)

Merged via squash.

Prepared head SHA: c62cebf
Co-authored-by: SARAMALI15792 <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Matrix E2EE: getSecretStorageKey callback not implemented — bots cannot bootstrap cross-signing

2 participants