Repository navigation
Add optional length limit to ProgressiveVariableList - #86
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #86 +/- ##
==========================================
+ Coverage 53.37% 59.25% +5.88%
==========================================
Files 18 18
Lines 622 675 +53
==========================================
+ Hits 332 400 +68
+ Misses 290 275 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
665b0b8 to
9292e9f
Compare
|
huh, I thought progressive lists didn't have any limits? where are the limits defined? |
|
they dont have limits. This adds a guard to decoding so that we dont end up decoding a massive object and OOM ourselves for example we dont have to necessarily include the guard here, but I thought it might be the cleanest option this issue was flagged by one of the security researchers here: |
|
my understanding was that we'd try to enforce bounds one level up at the network later, e.g. don't decode a block larger than X kB I think we have those limits in LH but they are set absurdly high at the moment due to the payload size. We could probably greatly reduce the cap for blocks |
|
I'm coming around to this change, I think we should try to put the length limit checks as "low" and early as possible. I tried putting them into the decode for |
michaelsproul
left a comment
There was a problem hiding this comment.
Impl looks solid, I think this is the way to go.
I'll try cooking up a Lighthouse branch to use these changes.
9292e9f to
742c4c6
Compare
|
rebased on |
|
I checked all your commits and they look good, so I'm happy to merge this. |
|
yeah it just seemed overly complex, my b for the last minute changes! |
|
|
||
| /// Returns the optional length limit. | ||
| /// | ||
| /// `None` means no limit (`N = U0`). `Some(n)` rejects any input with more than `n` elements. |
There was a problem hiding this comment.
I'm a bit late here but just noting that this could lead to an edge case since we cannot define anything to have a limit of 0. It would instead have no limit. This is most relevant for Deposit which is spec'd with a limit of 0: https://github.com/ethereum/consensus-specs/blob/638af25cd7adea0314c71a6052262c1a5ad6f368/specs/gloas/beacon-chain.md?plain=1#L305-L312
This likely isn't an issue for Lighthouse currently since we reject non-empty deposits either way:
Theoretically if we could de-couple U0 from None we could set MaxDeposits to U0 and reject non-empty Deposits at decode time rather than during verification.
Also, as a side note, for VariableList, U0 actually does mean "limit of 0" so this is inconsistent API-wise.
## Issue Addressed Trying to solve ProgressiveList DoS vectors. ## Proposed Changes Go back to type-level limits like before, using: - sigp/ssz_types#86 ## Additional Info Several imperfections we still need to solve: - [ ] There's no bound on transactions and we probably need a spec change to safely add one (related: ethereum/consensus-specs#5642 (comment)) - [x] The upstream `ssz_types` initially only enforced the limits in some places. I've now changed it to enforce them everywhere to avoid oversized lists slipping through. For example `ProgressiveVariableList::try_from_iter` didn't enforce the limit but was reachable from indexed attestation JSON decoding (via `quoted_u64_var_list`). See: sigp/ssz_types#86 (comment). Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
Add an optional length limit to
ProgressiveVariableListThis lets Gloas fields easily enforce their spec count limits