Skip to content

mixing: Validate RS hashes during blame assignment - #3760

Merged
davecgh merged 1 commit into
decred:masterfrom
jholdstock:validate-rs
Aug 18, 2026
Merged

mixing: Validate RS hashes during blame assignment#3760
davecgh merged 1 commit into
decred:masterfrom
jholdstock:validate-rs

Conversation

@jholdstock

Copy link
Copy Markdown
Member

Ensuring that the RS hashes from rs.SeenSecrets actually exist in the current session closes a loophole where a peer could escape blame by simply filling rs.SeenSecrets with junk in order to bypass the len!=0 check.

@jrick

jrick commented Aug 11, 2026

Copy link
Copy Markdown
Member

This looks necessary but we should be stricter about it. If a RS message references both junk and a valid RS message, we should similarly treat the peer as misbehaving, rather than permitting them because at least one of the hashes was valid.

@davecgh davecgh added this to the 2.2.0 milestone Aug 11, 2026
@jholdstock

Copy link
Copy Markdown
Member Author

Done

@jrick

jrick commented Aug 17, 2026

Copy link
Copy Markdown
Member

This is correct but the loop could read simpler. If there are no hashes in the slices, blame the peer (and continue to the next RS). Otherwise, iterate all hashes, and if any hash is unknown, blame the peer. And we can remove the check for a self-referencing RS, because that is only happening if our hash function is horribly broken.

@jholdstock

jholdstock commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

I don't think we can remove the self-reference check because the message hash does not commit to the SeenSecrets field - i.e. it's possible to hash the message then insert that hash into the SeenSecrets field without invalidating the hash.

With the assumption that the self check needs to stay, I don't think the loop can be simplified much further. I have wrapped the decision into a func which removes one of the bools, removes the duplicated logging, and just overall helps things to read more smoothly (IMO).

@jrick jrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, thanks.

Ensuring that the RS hashes from rs.SeenSecrets actually exist in the
current session closes a loophole where a peer could escape blame by
simply filling rs.SeenSecrets with junk in order to bypass the len!=0
check.
@davecgh
davecgh merged commit 3d1c81e into decred:master Aug 18, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants