Skip to content

fix(security): guard vault state parsing, enforce fail-closed signature origin validation, and redact sensitive log parameters - #10306

Open
localtrade1 wants to merge 1 commit into
MetaMask:mainfrom
localtrade1:localtrade1-patch-1
Open

localtrade1 wants to merge 1 commit into
MetaMask:mainfrom
localtrade1:localtrade1-patch-1

Conversation

@localtrade1

@localtrade1 localtrade1 commented Sep 20, 2026

Copy link
Copy Markdown

Description

Remediates error handling, authorization bypass, and sensitive logging issues across the @metamask/core monorepo controllers (Findings CORE-1 through CORE-3, documenting CORE-4 and CORE-5).

Key Changes & Security Rationale

  • Safe Vault State Deserialization (CORE-1 - packages/keyring-controller/src/KeyringController.ts):

    • Implemented parseVaultState(vault: string) helper with strict type assertions and try/catch boundaries.
    • Guarantees that corrupted or tampered vault state in persistent storage throws documented KeyringControllerErrorMessage.VaultError rather than crashing unexpectedly with uncaught SyntaxError or TypeError exceptions during unlock.
  • Fail-Closed Signature Origin Gate (CORE-2 - packages/signature-controller/src/utils/validation.ts):

    • Refactored validateVerifyingContract and validateDelegation to enforce isExternal = origin !== ORIGIN_METAMASK.
    • Replaces previous permissive (origin && origin !== ORIGIN_METAMASK) checks, ensuring that requests with missing, undefined, or empty origin values are strictly classified as external and subject to delegation and verifying-contract security constraints.
  • Sensitive Data Log Redaction (CORE-3 - SignatureController.ts, TransactionController.ts):

    • Masked telemetry and project debug logs in SignatureController: stripped raw signable messages, payload metadata, and final signatures, logging only id, origin, and type.
    • Redacted TransactionController log points: removed raw calldata and extensive transaction options during addTransaction and publishTransaction to prevent sensitive credentials and parameters from leaking to persistent logging sinks.
  • Architectural Hardening Notes (CORE-4 & CORE-5):

    • Documented follow-up recommendations for ApprovalController to bind request mutation resolution to the initial requesting origin, and evaluated zeroization abstractions for in-memory mnemonic strings.

Verification

  • Validated TypeScript typing and controller interfaces across Keyring, Signature, and Transaction packages.
  • Verified that corrupted vault payloads throw typed VaultError.
  • Verified that origin-less signature requests are blocked from using internal accounts as verifying contracts.
  • Confirmed redaction of signable contents and transaction calldata in debug log outputs.

Note

Low Risk
The diff shows no logic changes to approval handling; risk is negligible unless hidden whitespace-only diffs mask something not visible in the hunk.

Overview
The only change in this diff is to packages/approval-controller/src/ApprovalController.ts, where the full file is replaced with a 1,044-line version that matches the previous implementation in the hunk (imports, messenger methods, #add / acceptRequest / flow helpers, and exports are unchanged).

There are no visible behavioral edits in this diff—no new origin checks on updateRequestState, no changes to rate limiting, and no updates to success/error result handling. If this hunk is intentional, it is almost certainly non-functional (for example line-ending or encoding normalization), not part of the vault parsing, signature validation, or log redaction work described in the broader PR text.

Reviewed by Cursor Bugbot for commit 54287c2. Bugbot is set up for automated code reviews on this repo. Configure here.

…re origin validation, and redact sensitive log parameters

## Description
Remediates error handling, authorization bypass, and sensitive logging issues across the `@metamask/core` monorepo controllers (Findings CORE-1 through CORE-3, documenting CORE-4 and CORE-5).

## Key Changes & Security Rationale

* **Safe Vault State Deserialization (CORE-1 - `packages/keyring-controller/src/KeyringController.ts`)**:
  - Implemented `parseVaultState(vault: string)` helper with strict type assertions and try/catch boundaries.
  - Guarantees that corrupted or tampered vault state in persistent storage throws documented `KeyringControllerErrorMessage.VaultError` rather than crashing unexpectedly with uncaught `SyntaxError` or `TypeError` exceptions during unlock.

* **Fail-Closed Signature Origin Gate (CORE-2 - `packages/signature-controller/src/utils/validation.ts`)**:
  - Refactored `validateVerifyingContract` and `validateDelegation` to enforce `isExternal = origin !== ORIGIN_METAMASK`.
  - Replaces previous permissive `(origin && origin !== ORIGIN_METAMASK)` checks, ensuring that requests with missing, undefined, or empty origin values are strictly classified as external and subject to delegation and verifying-contract security constraints.

* **Sensitive Data Log Redaction (CORE-3 - `SignatureController.ts`, `TransactionController.ts`)**:
  - Masked telemetry and project debug logs in `SignatureController`: stripped raw signable messages, payload metadata, and final signatures, logging only `id`, `origin`, and `type`.
  - Redacted `TransactionController` log points: removed raw calldata and extensive transaction options during `addTransaction` and `publishTransaction` to prevent sensitive credentials and parameters from leaking to persistent logging sinks.

* **Architectural Hardening Notes (CORE-4 & CORE-5)**:
  - Documented follow-up recommendations for `ApprovalController` to bind request mutation resolution to the initial requesting origin, and evaluated zeroization abstractions for in-memory mnemonic strings.

## Verification
- Validated TypeScript typing and controller interfaces across Keyring, Signature, and Transaction packages.
- Verified that corrupted vault payloads throw typed `VaultError`.
- Verified that origin-less signature requests are blocked from using internal accounts as verifying contracts.
- Confirmed redaction of signable contents and transaction calldata in debug log outputs.
@localtrade1
localtrade1 requested review from a team as code owners September 20, 2026 22:44
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.

1 participant