Skip to content

fix(messages): reject incomplete mutable put requests - #114

Merged
andrei-21 merged 1 commit into
mainfrom
fix/parsing-mutable-item
Aug 4, 2026
Merged

fix(messages): reject incomplete mutable put requests#114
andrei-21 merged 1 commit into
mainfrom
fix/parsing-mutable-item

Conversation

@andrei-21

Copy link
Copy Markdown
Contributor

Prevent malformed network packets from panicking the DHT actor

@andrei-21
andrei-21 requested a review from SeverinAlexB August 3, 2026 14:48
@andrei-21
andrei-21 force-pushed the fix/parsing-mutable-item branch from b0bacc4 to 3731d3e Compare August 3, 2026 14:55
Return decode errors for mutable PUTs missing required fields. Reject
immutable PUTs that include mutable-only fields.

BREAKING CHANGE: DecodeMessageError adds MissingMutableSequence,
MissingMutableSignature, and UnexpectedMutableFieldsInImmutablePut.

@SeverinAlexB SeverinAlexB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking good. One AI finding that I have a hard time judging:

- Medium: Incomplete mutable PUTs missing k are still decoded as immutable. The branch at src/common/messages.rs:461 (src/common/messages.rs#L461) classifies solely by k; with k: None, any supplied seq, sig, salt, or cas is silently discarded at src/common/messages.rs:484 (src/common/messages.rs#L484). A valid immutable target could therefore be stored and acknowledged instead of rejected. Validate the full field combination: immutable PUTs must omit all mutable-only fields; mutable PUTs must contain k, seq, and sig. Add coverage for k: None with each mutable-only field present.

@andrei-21
andrei-21 force-pushed the fix/parsing-mutable-item branch from 3731d3e to 8bd0fff Compare August 4, 2026 07:41
@andrei-21

Copy link
Copy Markdown
Contributor Author

Looking good. One AI finding that I have a hard time judging:

- Medium: Incomplete mutable PUTs missing k are still decoded as immutable. The branch at src/common/messages.rs:461 (src/common/messages.rs#L461) classifies solely by k; with k: None, any supplied seq, sig, salt, or cas is silently discarded at src/common/messages.rs:484 (src/common/messages.rs#L484). A valid immutable target could therefore be stored and acknowledged instead of rejected. Validate the full field combination: immutable PUTs must omit all mutable-only fields; mutable PUTs must contain k, seq, and sig. Add coverage for k: None with each mutable-only field present.

It makes sense, since we are breaking API anyway, I added the fix here also.

@andrei-21
andrei-21 merged commit f0492fb into main Aug 4, 2026
17 of 18 checks passed
@andrei-21
andrei-21 deleted the fix/parsing-mutable-item branch August 4, 2026 07:56
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.

2 participants