Skip to content

Commit 11ced58

Browse files
committed
Chain ID must not be 0 or 1
1 parent e5f634d commit 11ced58

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

evm/parser_impl_evm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ eth_tx_t eth_tx_obj;
4242

4343
#define ETHEREUM_RECOVERY_OFFSET 27
4444
#define EIP155_V_BASE 35
45+
#define INVALID_CHAIN_ID_0 0
46+
#define INVALID_CHAIN_ID_1 1
4547

4648
static parser_error_t readChainID(parser_context_t *ctx, rlp_t *chainId) {
4749
if (ctx == NULL || chainId == NULL) {
@@ -59,6 +61,12 @@ static parser_error_t readChainID(parser_context_t *ctx, rlp_t *chainId) {
5961
return parser_unexpected_error;
6062
}
6163

64+
// According to Ledger's specifications, chain ID must not be 0 or 1
65+
// when using an Ethereum derivation path
66+
if (tmpChainId == INVALID_CHAIN_ID_0 || tmpChainId == INVALID_CHAIN_ID_1) {
67+
return parser_invalid_chain_id;
68+
}
69+
6270
if (supported_networks_evm_len == 0) {
6371
return parser_invalid_chain_id;
6472
}

0 commit comments

Comments
 (0)