Details
-
Bug
-
Resolution: Fixed
-
Major
-
2.8.3, 3.1.0, 3.1.1
-
Security Level: Public
-
None
-
CBG Sprint 136
-
1
Description
In https://github.com/couchbase/sync_gateway/blob/master/db/document.go#L519
body = data[xattrsLen+4:] can panic in some cases where KV sends a malformed xattr content over DCP.
An explicit check on xattr length is needed to avoid this panic
Another related panic can occur on
pairLen := binary.BigEndian.Uint32(data[pos : pos+4])
can be reproduced with the last test case on TestParseXattr with
emptyBody, emptyXattr, _, emptyErr := parseXattrStreamData(base.SyncXattrName, "", []byte{math.MaxUint8, math.MaxUint8, math.MaxUint8, math.MaxUint8})
but can also be avoided by checking xattr length before the body assignment. Could use that test to test the panic doesn't occur after adding a check.
Attachments
Issue Links
- Clones
-
CBG-3238 Explicit check on xattr length to avoid panics
- Resolved