Skip to contentSkip to conversation

slirp: check len against dhcp options array end

PATCH In review P J P 4 participants 5 messages Jul 17, 2017 – Aug 2, 2017

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 slirp: check len against dhcp options array end

From: Prasad J Pandit <[email protected]>

While parsing dhcp options string in 'dhcp_decode', if an options' length 'len' appeared towards the end of 'bp_vend' array, ensuing read could lead to an OOB memory access issue. Add check to avoid it.

---
 slirp/bootp.c | 3 +++
 1 file changed, 3 insertions(+)
slirp/bootp.c +3 -0
index 5a4646c..5dd1a41 100644
@@ -123,6 +123,9 @@ static void dhcp_decode(const struct bootp_t *bp, int *pmsg_type,
             if (p >= p_end)
                 break;
             len = *p++;
+            if (p + len > p_end) {
+                break;
+            }
             DPRINTF("dhcp: tag=%d len=%d\n", tag, len);
 
             switch(tag) {
Signature · 1 line
2.9.4
#1 lore raw
Quoted 8 lines · P J P, on lun. 17 juil. 2017 17:33:26 +0530, wrote:

From: Prasad J Pandit <[email protected]>

While parsing dhcp options string in 'dhcp_decode', if an options' length 'len' appeared towards the end of 'bp_vend' array, ensuing read could lead to an OOB memory access issue. Add check to avoid it.

Oops, sure, applied to my tree, thanks!

Samuel

#2 lore raw

+ if (p + len > p_end) {

Shouldn't this be (p + len >= p_end) ?

Quoted 13 lines · Samuel Thibault
Quoted 8 lines · P J P, on lun. 17 juil. 2017 17:33:26 +0530, wrote:

From: Prasad J Pandit <[email protected]>

While parsing dhcp options string in 'dhcp_decode', if an options' length 'len' appeared towards the end of 'bp_vend' array, ensuing read could lead to an OOB memory access issue. Add check to avoid it.

Oops, sure, applied to my tree, thanks!

Samuel

Signature · 3 lines
Regards,
Reno Robert
http://v0ids3curity.blogspot.in/
#3 lore raw
Quoted 3 lines · Reno Robert, on lun. 17 juil. 2017 23:10:02 +0530, wrote:

+ if (p + len > p_end) {

Shouldn't this be (p + len >= p_end) ?

No: if p_end-p is 1, len being 1 is fine.

Samuel

#4 lore raw
In reply to Samuel Thibault
Quoted 11 lines · Samuel Thibault
Quoted 8 lines · P J P, on lun. 17 juil. 2017 17:33:26 +0530, wrote:

From: Prasad J Pandit <[email protected]>

While parsing dhcp options string in 'dhcp_decode', if an options' length 'len' appeared towards the end of 'bp_vend' array, ensuing read could lead to an OOB memory access issue. Add check to avoid it.

Oops, sure, applied to my tree, thanks!

Can we have it in 2.10 please?

This is CVE-2017-11434, which can be mentioned in the commit message.

Thanks,

/mjt