Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malformed DHCP runs endless loop #4452

Closed
AvihaiSam opened this issue Jul 4, 2024 · 4 comments
Closed

malformed DHCP runs endless loop #4452

AvihaiSam opened this issue Jul 4, 2024 · 4 comments

Comments

@AvihaiSam
Copy link

when running a malformed DHCP packet with DHCP(data) - scapy runs endlessly and increasing memory consumption.

The mechanism is this partial code runs getfield() (in layers/dhcp.py:457) which runa

# fields.py:2059
while s:
    if c is not None:
        if c <= 0:
            break
        c -= 1
    s, v = self.field.getfield(pkt, s)
    val.append(v)

where dhcp's getfield is:

# layers/dhcp.py:192
def getfield(self, pkt, s):
    if not s:
        return None

    prefix = orb(s[0])
    # if prefix is invalid value ( 0 > prefix > 32 ) then break
    if prefix > 32 or prefix < 0:
        warning("Invalid prefix value: %d (0x%x)", prefix, prefix)
        return s, []

    route_len = 5 + (prefix + 7) // 8
    return s[route_len:], self.m2i(pkt, s[:route_len])

and it returns in line 200 with s, [] which causes the same data going in again and again endlessly.
each iteration val gets appended with another [] so it looks like [[], [], [], [], [], [], ......, []]

i think you should raise excepion in line 200 instead of return s, []

@evverx
Copy link
Contributor

evverx commented Jul 4, 2024

I think it was fixed in 9946ef1.

@AvihaiSam
Copy link
Author

I think it was fixed in 9946ef1.

Cool I agree, it sounds like a fix...
when would 2.6.0 be official then?

@evverx
Copy link
Contributor

evverx commented Jul 4, 2024

I'm not a scapy maintainer so I can't answer this question but it's being discussed in #4196. 2.6.0rc1 was already released.

@gpotter2
Copy link
Member

gpotter2 commented Jul 5, 2024

when would 2.6.0 be official

Hopefully soon.

Thanks a lot @evverx. Closing

@gpotter2 gpotter2 closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants