Skip to content

Commit 1dc4299

Browse files
committed
Add checks for malicious input
1 parent 7ccd8e9 commit 1dc4299

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

packages/address-book-controller/src/AddressBookController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class AddressBookController extends BaseControllerV1<
110110
delete(chainId: Hex, address: string) {
111111
address = toChecksumHexAddress(address);
112112
if (
113+
[chainId, address].includes('__proto__') ||
113114
!isValidHexAddress(address) ||
114115
!this.state.addressBook[chainId] ||
115116
!this.state.addressBook[chainId][address]

packages/ens-controller/src/EnsController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ export class EnsController extends BaseController<
194194
delete(chainId: Hex, ensName: string): boolean {
195195
const normalizedEnsName = normalizeEnsName(ensName);
196196
if (
197+
// @ts-expect-error suppressing to perform runtime check
198+
chainId === '__proto__' ||
197199
!normalizedEnsName ||
198200
!this.state.ensEntries[chainId] ||
199201
!this.state.ensEntries[chainId][normalizedEnsName]

packages/name-controller/src/NameController.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,13 @@ export class NameController extends BaseController<
441441
const normalizedValue = this.#normalizeValue(value, type);
442442
const normalizedVariation = this.#normalizeVariation(variationKey, type);
443443

444+
if (
445+
normalizedValue === '__proto__' ||
446+
normalizedVariation === '__proto__'
447+
) {
448+
return;
449+
}
450+
444451
this.update((state) => {
445452
const typeEntries = state.names[type] || {};
446453
state.names[type] = typeEntries;

0 commit comments

Comments
 (0)