Skip to content

Commit

Permalink
Properly secure snap and ethereum request functions (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding authored Feb 20, 2023
1 parent 27791fd commit dea4030
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ export class BaseSnapExecutor {

const request = async (args: RequestArguments) => {
assert(
args.method.startsWith('wallet_') || args.method.startsWith('snap_'),
String.prototype.startsWith.call(args.method, 'wallet_') ||
String.prototype.startsWith.call(args.method, 'snap_'),
'The global Snap API only allows RPC methods starting with `wallet_*` and `snap_*`.',
);
this.notify({ method: 'OutboundRequest' });
Expand Down Expand Up @@ -427,7 +428,7 @@ export class BaseSnapExecutor {

const request = async (args: RequestArguments) => {
assert(
!args.method.startsWith('snap_'),
!String.prototype.startsWith.call(args.method, 'snap_'),
ethErrors.rpc.methodNotFound({
data: {
method: args.method,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function getMockedStreamProvider() {

const request = async (args: RequestArguments) => {
assert(
!args.method.startsWith('snap_'),
!String.prototype.startsWith.call(args.method, 'snap_'),
ethErrors.rpc.methodNotFound({
data: {
method: args.method,
Expand Down

0 comments on commit dea4030

Please sign in to comment.