Skip to content

Commit 13fa79c

Browse files
author
sashabeton
committed
internal/ethapi: add a single DoS protection to authorizations processing in eth_createAccessList
1 parent 4bcf144 commit 13fa79c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/ethapi/api.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -1171,14 +1171,18 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
11711171
addressesToExclude[addr] = struct{}{}
11721172
}
11731173

1174-
for _, auth := range args.AuthorizationList {
1175-
// Duplicating stateTransition.validateAuthorization() logic
1176-
if (!auth.ChainID.IsZero() && auth.ChainID.CmpBig(b.ChainConfig().ChainID) != 0) || auth.Nonce+1 < auth.Nonce {
1177-
continue
1178-
}
1174+
// Prevent redundant operations if args contain more authorizations than EVM may handle
1175+
maxAuthorizations := uint64(*args.Gas) / params.TxAuthTupleGas
1176+
if uint64(len(args.AuthorizationList)) <= maxAuthorizations {
1177+
for _, auth := range args.AuthorizationList {
1178+
// Duplicating stateTransition.validateAuthorization() logic
1179+
if (!auth.ChainID.IsZero() && auth.ChainID.CmpBig(b.ChainConfig().ChainID) != 0) || auth.Nonce+1 < auth.Nonce {
1180+
continue
1181+
}
11791182

1180-
if authority, err := auth.Authority(); err == nil {
1181-
addressesToExclude[authority] = struct{}{}
1183+
if authority, err := auth.Authority(); err == nil {
1184+
addressesToExclude[authority] = struct{}{}
1185+
}
11821186
}
11831187
}
11841188

0 commit comments

Comments
 (0)