Repository navigation
Commit ff27b5b
pgtype: bound hstore binary decode against malicious server input
Two issues in scanPlanBinaryHstoreToHstoreScanner.Scan: pairCount was
read as int32 from the wire, checked only for < 0, then passed directly
to make(Hstore, pairCount) and make([]string, pairCount), allowing a
server-claimed 0x3FFFFFFF count to allocate ~16+ GiB from a 4-byte
payload; and the per-value branch sliced src[rp:rp+valueLen] without
the remaining-bytes check that keys already had, allowing a crafted
body to trigger an index-out-of-range panic.
Bound pairCount by len(src[rp:]) / 8 (each pair needs at minimum two
int32 length headers) and check remaining bytes before slicing the
value.
Reported by CrowdStrike (F05).1 parent a6002e1 commit ff27b5b
1 file changed
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
201 | 207 | | |
202 | 208 | | |
203 | 209 | | |
| |||
226 | 232 | | |
227 | 233 | | |
228 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
229 | 238 | | |
230 | 239 | | |
231 | 240 | | |
| |||
0 commit comments