add a chainID check to pm ticket auxData validation to prevent cross-chain replay attacks
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- solidity
- Domain
- blockchain, security
Research direction
Start by locating requireValidTicketAuxData() and getCreationRoundAndBlockHash(), then check the contract's Solidity compiler version and existing ticket validation tests. Confirm how _auxData is encoded before updating validation for the 96-byte layout and chain ID; done means cross-chain ticket data is rejected while valid tickets continue to pass.
Written by the indexing model from the issue text.
Description
The istanbul upgrade for ethereum includes EIP1344 which introduces a new assembly chainid opcode allowing a contract to query the chainID of the network it is running on.
We'd need to upgrade to solidity 0.5.12
We should add validation for it to prevent cross-chain replay attacks whereby a message signed off-chain could be re-used on a different chain if the same keys are used.
This can be done by adding a new 32-byte word to the _auxData field for tickets.
We can then add a method that verifies the chain ID
e.g.
// _auxData format:
// Bytes [0:31] = creationRound
// Bytes [32:63] = creationRoundBlockHash
// Bytes [64:95] = chainID
function isValidChainID(bytes memory _auxData) internal pure returns (bool) {
uint256 chainID;
uint256 ticketChainID;
assembly {
chainID := chainid()
ticketChainID := mload(add(_auxData), 96)
}
return chainID == ticketChainID;
}
}
which would then be called in requireValidTicketAuxData()
require(
isValidChainID(_auxData),
"ticket chainID is not compatible with the network being used"
);
** extra **
We currently check the length of _auxData in the getCreationRoundAndBlockHash(_auxData) helper, I would suggest moving this at the top of requireValidTicketAuxData() instead so we don't have to validate the length in the functions called in that body. We'd also have to increase the length check to 96 bytes if we're adding a word.
function requireValidTicketAuxData(bytes memory _auxData) internal view {
// _auxData format:
// Bytes [0:31] = creationRound
// Bytes [32:63] = creationRoundBlockHash
// Bytes [64:95] = chainID
require(
_auxData.length == 96,
"invalid length for ticket auxData: must be 96 bytes"
);
...
}
- Dominant language
- JavaScript
- Stars
- 155
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from livepeer/protocol
-
known-issue
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Winning tickets can settle for less than their face value once the recipient’s reserve is exhausted Openknown-issue
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
blockchain enhancement pm
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
known-issue
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
known-issue
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in livepeer/protocol
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·