IllIllI - Oracles are vulnerable to cross-chain replay attacks #152
Description
IllIllI
medium
Oracles are vulnerable to cross-chain replay attacks
Summary
Oracles are vulnerable to cross-chain replay attacks
Vulnerability Detail
If there's a hard fork (e.g. miner vs proof of stake), signatures/txns submitted on one chain can be replayed on the other chain.
Impact
Keepers on the forked chain can use oracle prices from the original chain, even though they may not be correct for the current chain (e.g. USDC's price on the fork may be worth zero until Circle adds support on that fork), leading to invalid execution prices and or liquidations.
Code Snippet
The SALT
used in signatures is hard-coded to an immutable variable in the constructor, and uses the block.chainid
from the time of construction:
// File: gmx-synthetics/contracts/oracle/Oracle.sol : Oracle.constructor() #1
108 constructor(
109 RoleStore _roleStore,
110 OracleStore _oracleStore
111 ) RoleModule(_roleStore) {
112 oracleStore = _oracleStore;
113
114 // sign prices with only the chainid and oracle name so that there is
115 // less config required in the oracle nodes
116 @> SALT = keccak256(abi.encode(block.chainid, "xget-oracle-v1"));
117: }
Signatures use the SALT
without also including the block.chainid
separately
Tool used
Manual Review
Recommendation
Include the block.chainid
in the signature, separately from the SALT
, and ensure that the value is looked up each time