Skip to content

harden client reply parsers against malformed server replies - #655

Merged
drakkan merged 1 commit into
pkg:masterfrom
drakkan:harden_client
Oct 8, 2026
Merged

drakkan merged 1 commit into
pkg:masterfrom
drakkan:harden_client

Conversation

@drakkan

@drakkan drakkan commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

The client response decoders parsed server replies with the unchecked unmarshalUint32/unmarshalString helpers and with fixed-offset reads in unmarshalStatus. A malicious or compromised server could return a truncated or oversized reply and panic the client goroutine with an index- or slice-bounds-out-of-range. Convert these paths to the bounds-checked Safe variants and clamp the data-length before slicing, so a hostile reply returns an error instead of panicking.

Reported by @mjbommar

Comment thread client.go Resolved
Comment thread client_test.go Resolved
@acts-1631

Copy link
Copy Markdown

I just discovered this same thing and was going to submit a PR, but found it's already pending.

@puellanivis

Copy link
Copy Markdown
Collaborator

Unfortunately, the OG author has not responded to the current suggestions. If you want to take the branch and move forward on this, it would still be appreciated.

The client response decoders parsed server replies with the unchecked
unmarshalUint32/unmarshalString helpers and with fixed-offset reads in
unmarshalStatus. A malicious or compromised server could return a truncated
or oversized reply and panic the client goroutine with an index- or
slice-bounds-out-of-range. Convert these paths to the bounds-checked Safe
variants and clamp the data-length before slicing, so a hostile reply
returns an error instead of panicking.

Reported by @mjbommar
@drakkan

drakkan commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Unfortunately, the OG author has not responded to the current suggestions. If you want to take the branch and move forward on this, it would still be appreciated.

Done, the CI failure looks unrelated

@drakkan
drakkan merged commit 16147c5 into pkg:master Oct 8, 2026
1 of 4 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