Repository navigation
fix: skip NODES records with an unsupported identity scheme - #315
Open
paschal533 wants to merge 2 commits into
Open
paschal533 wants to merge 2 commits into
paschal533 wants to merge 2 commits into
Conversation
A record signed with an identity scheme we don't support can't be verified, but that doesn't make it invalid. Skip it instead of dropping the whole NODES response. Every other decode error still fails the message. See sigp#308.
Runs a FINDNODE from a real handler against a peer that answers with an encrypted NODES response where one record uses an unknown identity scheme. The handler gets the other records back. Without the fix in rpc.rs the request times out.
Member
|
FYI, I'm working on https://github.com/sigp/enr/pull/93 to make error handling cleaner. |
Author
|
Hi @ackintosh, Thanks, that's the kind of helper. I'll switch over once it lands. One thing for the switch: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to the discussion in #308.
Right now, if one record in a NODES response fails to decode, the whole response is dropped. That's the right call for records we know are broken, but it also catches records that are just signed with an identity scheme we don't support yet (anything other than
v4). Those aren't invalid, we just can't check them, and a peer sending one may be perfectly correct and simply ahead of us.This makes the decoder skip records with an unsupported identity scheme and keep the rest of the response. Every other decode error (bad signature, unsorted keys, oversized record, etc.) still fails the whole message like before, so the strict behaviour stays for anything we know is bad.
Changes, all in
src/rpc.rs:enr's "Unsupported identity scheme" error is skipped by advancing past it using the length from its RLP header, which is already bounds checked aboveNotes & open questions
enrreports this case asDecoderError::Custom("Unsupported identity scheme")andDecoderErroris alloy-rlp's type, so there's no dedicated variant to match on. I matched on the message through a constant. Ifenrever changes the text, the new tests fail, so it can't drift silently. If you'd preferenrto expose a small helper for this instead, I'm happy to open that PR and switch over.enrstops parsing a record when it hits theidcheck, so the rest of a skipped record is never looked at. That's fine since the record is thrown away and never reaches the routing table, but it does mean a peer can put junk afteridin one record without the message failing.enrchecks the size first. EIP-778 caps every record at 300 bytes, so that seemed right to keep.tracerather thandebug, since a peer can fit a lot of small records into one packet.cargo clippy --workspace --tests --all-features -- -D warningscurrently fails on master with stable 1.95 because ofnonminimal_boolinsrc/ipmode.rs:57. I left it out of this PR to keep it focused.Change checklist