Skip to content

Commit 6cb6faf

Browse files
committed
ODOH: check padding of plaintext, not ciphertext
1 parent 353e737 commit 6cb6faf

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

dnscrypt-proxy/oblivious_doh.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,12 @@ func (q ODoHQuery) decryptResponse(response []byte) ([]byte, error) {
179179
}
180180

181181
responseLength := binary.BigEndian.Uint16(responsePlaintext[0:2])
182+
if int(responseLength)+2 > len(responsePlaintext) {
183+
return nil, fmt.Errorf("Malformed response")
184+
}
182185
valid := 1
183186
for i := 4 + int(responseLength); i < len(responsePlaintext); i++ {
184-
valid &= subtle.ConstantTimeByteEq(response[i], 0x00)
187+
valid &= subtle.ConstantTimeByteEq(responsePlaintext[i], 0x00)
185188
}
186189
if valid != 1 {
187190
return nil, fmt.Errorf("Malformed response")

0 commit comments

Comments
 (0)