Skip to content

Commit fa852d4

Browse files
authored
Tweaks and creaks: Disable UNS, fix Ledger signing on built-in non-ETH/MATIC networks (#3746)
These are unrelated changes: UNS is disabled due to compromise during the late-last-week SquareSpace domain theft issues, while the Ledger signing issue is long-standing. The Ledger signing issue is partial—it doesn't work for custom networks, and it is handled in a way that's different for EIP191 messages than for other messages; further refinement is needed to fix it the rest of the way. Latest build: [extension-builds-3746](https://github.com/tahowallet/extension/suites/25994003749/artifacts/1700133481) (as of Mon, 15 Jul 2024 02:27:54 GMT).
2 parents 0024916 + 7a25914 commit fa852d4

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

background/constants/networks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ export const TEST_NETWORK_BY_CHAIN_ID = new Set(
162162
[SEPOLIA, ARBITRUM_SEPOLIA].map((network) => network.chainID),
163163
)
164164

165-
export const NETWORK_FOR_LEDGER_SIGNING = [ETHEREUM, POLYGON]
166-
167165
// Networks that are not added to this struct will
168166
// not have an in-wallet Swap page
169167
export const CHAIN_ID_TO_0X_API_BASE: {

background/services/ledger/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import {
1616
isEIP1559TransactionRequest,
1717
isKnownTxType,
18-
sameNetwork,
1918
SignedTransaction,
2019
TransactionRequestWithNonce,
2120
} from "../../networks"
@@ -25,7 +24,7 @@ import { ServiceCreatorFunction, ServiceLifecycleEvents } from "../types"
2524
import logger from "../../lib/logger"
2625
import { getOrCreateDB, LedgerAccount, LedgerDatabase } from "./db"
2726
import { ethersTransactionFromTransactionRequest } from "../chain/utils"
28-
import { NETWORK_FOR_LEDGER_SIGNING } from "../../constants"
27+
import { ETHEREUM } from "../../constants"
2928
import { normalizeEVMAddress } from "../../lib/utils"
3029
import { AddressOnNetwork } from "../../accounts"
3130

@@ -542,10 +541,14 @@ export default class LedgerService extends BaseService<Events> {
542541
{ address, network }: AddressOnNetwork,
543542
hexDataToSign: HexString,
544543
): Promise<string> {
544+
// Currently the service assumes the Eth app, which requires a network that
545+
// uses the same derivation path as Ethereum, or one that starts with the
546+
// same components.
547+
// FIXME This should take a `LedgerAccountSigner` and use `checkCanSign`
548+
// FIXME like other signing methods.
545549
if (
546-
!NETWORK_FOR_LEDGER_SIGNING.find((supportedNetwork) =>
547-
sameNetwork(network, supportedNetwork),
548-
)
550+
network.derivationPath !== ETHEREUM.derivationPath &&
551+
!network.derivationPath?.startsWith(ETHEREUM.derivationPath ?? "")
549552
) {
550553
throw new Error("Unsupported network for Ledger signing")
551554
}

background/services/name/resolvers/uns.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const UNS_SUPPORTED_NETWORKS = [ETHEREUM, POLYGON]
7070
/**
7171
* Lookup a UNS domain name and fetch the owners address
7272
*/
73+
// FIXME UNS issues
74+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7375
const lookupUNSDomain = async (domain: string) => {
7476
const response = await fetchJson({
7577
url: `https://resolve.unstoppabledomains.com/domains/${domain}`,
@@ -149,10 +151,13 @@ export default function unsResolver(): NameResolver<"UNS"> {
149151
},
150152

151153
async lookUpAddressForName({
152-
name,
153-
network,
154+
name: _,
155+
network: __,
154156
}: NameOnNetwork): Promise<AddressOnNetwork | undefined> {
155-
// We try to resolve the name using unstoppable domains resolution
157+
// FIXME Restore body once UNS is back in action and we have a new API key.
158+
return undefined
159+
160+
/* We try to resolve the name using unstoppable domains resolution
156161
const address = (await lookupUNSDomain(name))?.meta?.owner
157162
158163
if (address === undefined || address === null) {
@@ -162,11 +167,13 @@ export default function unsResolver(): NameResolver<"UNS"> {
162167
return {
163168
address,
164169
network,
165-
}
170+
} */
166171
},
167-
async lookUpAvatar(
168-
addressOrNameOnNetwork: AddressOnNetwork | NameOnNetwork,
169-
) {
172+
async lookUpAvatar(_: AddressOnNetwork | NameOnNetwork) {
173+
// FIXME Restore body once UNS is back in action and we have a new API key.
174+
return undefined
175+
176+
/*
170177
const { network } = addressOrNameOnNetwork
171178
const { address } =
172179
"address" in addressOrNameOnNetwork
@@ -200,12 +207,14 @@ export default function unsResolver(): NameResolver<"UNS"> {
200207
return {
201208
uri: avatarUrn,
202209
network,
203-
}
210+
} */
204211
},
205212
async lookUpNameForAddress({
206213
address,
207214
network,
208215
}: AddressOnNetwork): Promise<NameOnNetwork | undefined> {
216+
return Promise.resolve(undefined)
217+
209218
// Get all the records associated with the particular ETH address
210219
const data = (await reverseLookupAddress(address))?.data
211220
// Since for a given address you can have multiple UNS records, we just pick the first one

ui/components/Signing/Signer/SignerLedger/SignerLedgerSigning/index.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,21 @@ function SignerLedgerSigningTypedData({
5656
typedData: EIP712TypedData
5757
}): ReactElement {
5858
const { EIP712Domain: _, ...typesForSigning } = typedData.types
59-
const domainHash = _TypedDataEncoder
59+
60+
// Below, we prefix the 0x so that we can uppercase the hex characters
61+
// without uppercasing the X. This is because the Ledger displays hex
62+
// characters all uppercase for this operation, but an uppercased X
63+
// both makes our display and the Ledger's less accurate and makes it
64+
// harder to scan the values.
65+
const domainHash = `0x${_TypedDataEncoder
6066
.hashDomain(typedData.domain)
61-
.toUpperCase()
62-
const messageHash = _TypedDataEncoder
67+
.substring(2)
68+
.toUpperCase()}`
69+
const messageHash = `0x${_TypedDataEncoder
6370
.from(typesForSigning)
6471
.hash(typedData.message)
65-
.toUpperCase()
72+
.substring(2)
73+
.toUpperCase()}`
6674

6775
return (
6876
<TransactionDetailContainer>

ui/pages/Send.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,12 @@ export default function Send(): ReactElement {
268268
</button>
269269
)}
270270
{addressErrorMessage !== undefined && (
271-
<p className="error">{addressErrorMessage}</p>
271+
<p
272+
className="error"
273+
title="Note: UNS temporarily disabled for security reasons."
274+
>
275+
⚠️ {addressErrorMessage}
276+
</p>
272277
)}
273278
</div>
274279
<div className="send_footer standard_width_padded">

0 commit comments

Comments
 (0)