Skip to content

harden client reply parsers against malformed server replies - #655

Open
drakkan wants to merge 1 commit into
pkg:masterfrom
drakkan:harden_client
Open

harden client reply parsers against malformed server replies#655
drakkan wants to merge 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

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
}
count, data := unmarshalUint32(data)
for i := uint32(0); i < count; i++ {
for i := 0; i < count; i++ {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can switch this to range i since we’re here.

Comment thread client_test.go
Comment on lines +205 to +207
if len(body) >= 5 {
id, _ = unmarshalUint32(body[1:])
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think if this is false, then this would be an error… at least a ok == false situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants