MetaMask / MetaMask/metamask-extension

[Bug]: Signatures - Triggering a `eth_signTypedData` throws error `[createTrustSignalsMiddleware] error` and `SyntaxError#1: Unexpected non-whitespace character after JSON at position 1 (line 1 column 2)`

Open
#35,348 2 comments 0 reactions 0 assignees View on GitHub
INVALID-ISSUE-TEMPLATE regression-prod-13.1.0 regression-prod-13.12.1 Sev2-normal team-product-safety type-bug
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**Describe the bug**

Triggering a `eth_signTypedData` method throws the following errors:
- `[createTrustSignalsMiddleware] error`

and
- `SyntaxError#1: Unexpected non-whitespace character after JSON at position 1 (line 1 column 2)`

It seems it might be because the API response to this request `https://signature-insights.api.cx.metamask.io/v1/signature?chainId=0xaa36a7` which returns a 400 with this error, however we get the same bad response for typed 3 and 4 signatures, and we don't get the console errors there.

```
{
"stateChanges": [],
"error": {
"type": "ERROR",
"message": "Unsupported signature.",
"extraData": null
}
}
```

**Expected behavior**

Handle errors gracefully to avoid Sentry issues

**Steps to reproduce**

1. Make sure you have Security Alerts enabled from settings
2. Connect to the test dapp
3. Trigger Sign Typed Data
4. See console errors
**Error messages or log output**

```shell

```

**Detection stage**

In production (default)

**Version**

13.1.0

**Build type**

None

**Browser**

Chrome

**Operating system**

Linux

Contributor guide

Open the contributing guide

Research direction

Start at createTrustSignalsMiddleware and trace the signature-insights request for eth_signTypedData, especially the 400 response containing the Unsupported signature payload. Reproduce the issue with Security Alerts enabled and the test dapp, then verify that typed-data signing no longer emits console or Sentry errors when the API returns this response.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.