< Return to Video

www.youtube.com/.../watch?v=DobIrGdLEi0

  • 0:01 - 0:14
    *37c3 premusic* [Translated by Viljami Kittilä (KYBS2004 course assignment at JYU.FI)]
  • 0:14 - 0:16
    All right, everyone, welcome back. Our
  • 0:16 - 0:19
    next talk is fuzzing the fuzzing
  • 0:19 - 0:22
    TCP/IP stack with Ilya. Please give him
  • 0:22 - 0:23
    a warm round of applause.
  • 0:23 - 0:30
    *Applause*
  • 0:30 - 0:32
    Great. Thank you for the introduction. As
  • 0:33 - 0:35
    was just mentioned, I will be talking
  • 0:35 - 0:37
    about fuzzing stack going beyond
  • 0:37 - 0:40
    trivial. Just a fair warning and I'll get
  • 0:40 - 0:42
    into this a bit later. This is a very,
  • 0:42 - 0:44
    very early pre-alpha version.
  • 0:44 - 0:47
    There's more to come, but I have
  • 0:47 - 0:50
    some things to talk about and report and
  • 0:51 - 0:54
    hoping to maybe move to the kind of
  • 0:54 - 0:56
    current state of this a bit further.
  • 0:59 - 1:01
    Right, so who am I? My name is Ilya.
  • 1:02 - 1:04
    I have been coming to the CC Congress
  • 1:04 - 1:07
    since 18C3, which is really
  • 1:07 - 1:09
    not a way of saying I'm old and decrepit.
  • 1:12 - 1:14
    I've in the in a
  • 1:15 - 1:17
    handful of those times. I've also spoke
  • 1:17 - 1:19
    here before. I spoke on some issues with
  • 1:19 - 1:22
    clearing memory, which I called Memsad.
  • 1:22 - 1:24
    I spoke on some X11 things about a decade
  • 1:24 - 1:27
    ago. I spoke on some Windows stuff. I did
  • 1:27 - 1:30
    a general fuzzing talk about 15-16 years
  • 1:30 - 1:32
    ago, and there were a few others that I
  • 1:32 - 1:34
    can't really remember because I'm old and
  • 1:34 - 1:36
    my memory sucks. But
  • 1:37 - 1:38
    what's really cool is it's really,
  • 1:38 - 1:40
    really glad. I'm really glad to be back
  • 1:40 - 1:42
    here after four years.
  • 1:44 - 1:45
    Yeah, right. Yeah,
  • 1:45 - 1:49
    absolutely. Oh, man, *Applause*
  • 1:49 - 1:51
    I was almost. It was almost going to
  • 1:51 - 1:52
    happen last year. And then I guess
  • 1:52 - 1:54
    something happened. It didn't.
  • 1:55 - 1:58
    But hey, here we are. All good again.
  • 1:58 - 2:00
    Hopefully we, hopefully, you know, we
  • 2:00 - 2:01
    won't have to wait another three or four
  • 2:01 - 2:03
    years for the next one. I'm definitely
  • 2:03 - 2:04
    looking forward to the next one already,
  • 2:05 - 2:06
    even though I guess we're only halfway
  • 2:06 - 2:09
    through. But yeah, that's kind of who I
  • 2:09 - 2:11
    am. Yeah. I mean, also I work at a
  • 2:11 - 2:14
    company called IO Active. We do computer
  • 2:14 - 2:16
    security. I do code review and
  • 2:17 - 2:19
    pen test and fuzzing and all those kind
  • 2:19 - 2:21
    of things. You know, I'm a security kind
  • 2:21 - 2:23
    of consultant/engineer.
  • 2:25 - 2:28
    Right. So what am I going to talk about?
  • 2:29 - 2:32
    Basically, I'll have a slide kind of
  • 2:32 - 2:33
    talking about the audience that might be
  • 2:33 - 2:35
    interested in here. But if you're here,
  • 2:35 - 2:37
    you probably only know who you are. And
  • 2:37 - 2:39
    then I'll kind of go into a little bit of
  • 2:39 - 2:42
    the history of doing TCP/IP
  • 2:42 - 2:44
    stack fuzzing and this like low-level
  • 2:44 - 2:47
    network fuzzing and kind
  • 2:47 - 2:49
    of where the state is today
  • 2:50 - 2:52
    and then kind of move on to.
  • 2:52 - 2:55
    Where I see it going, what I'm, what I
  • 2:55 - 2:56
    will be the crux of what I'll be
  • 2:56 - 2:58
    presenting and then sort of the how do we
  • 2:58 - 3:01
    go beyond that. And then
  • 3:01 - 3:04
    the the kind of middle part of my talk is
  • 3:04 - 3:06
    kind of the where I'm at. So
  • 3:07 - 3:10
    sort of how I want to do some or I
  • 3:10 - 3:12
    envision doing sort of the quote unquote
  • 3:12 - 3:15
    next level, whatever that means. Of
  • 3:15 - 3:18
    TCP/IP stack fuzzing, you know, and I'll
  • 3:18 - 3:20
    talk about kind of what I want to fuzz
  • 3:20 - 3:22
    and how I want to fuzz it. And I'll talk
  • 3:22 - 3:25
    about the set up and I'll talk about
  • 3:26 - 3:29
    certain modifications I made to a network
  • 3:29 - 3:31
    stacks to try to make this happen.
  • 3:32 - 3:34
    I'll show how to get all this thing
  • 3:34 - 3:37
    set up and how to kind of the
  • 3:37 - 3:40
    usage of the stuff I've been that I kind
  • 3:40 - 3:42
    of built and then I'll
  • 3:42 - 3:45
    do a small demo. And
  • 3:46 - 3:48
    then after that, if anybody is still in
  • 3:48 - 3:50
    the room, I'll take questions.
  • 3:53 - 3:54
    Right. So the audience, I mean, you know
  • 3:54 - 3:57
    who you are, but if it isn't clear, if
  • 3:57 - 3:59
    you're if you like fuzzing, this might be
  • 3:59 - 4:00
    interesting. If you're a network geek,
  • 4:00 - 4:02
    this might be interesting. If you're
  • 4:02 - 4:04
    operating systems guy, this might be
  • 4:04 - 4:07
    interesting. If you like technology, you
  • 4:07 - 4:09
    might like this. If any any kind of sort
  • 4:09 - 4:12
    of security, network, OS, fuzzing.
  • 4:13 - 4:16
    Then this may be for you, but even if you
  • 4:16 - 4:18
    don't fall in that category, you might
  • 4:18 - 4:19
    still find this interesting,
  • 4:22 - 4:24
    right? So let's let's get into kind of
  • 4:24 - 4:27
    the history of things, right? So I'm
  • 4:27 - 4:29
    obviously, you know, not the very first
  • 4:29 - 4:31
    guy to go, hey, you know, we have these
  • 4:31 - 4:34
    TCP/IP stacks and they
  • 4:34 - 4:35
    take network packets and they parse bits
  • 4:35 - 4:38
    and bytes and they handle state. Isn't
  • 4:38 - 4:40
    that interesting? Surely that's attack
  • 4:40 - 4:43
    surface, right? In fact, you know,
  • 4:43 - 4:45
    you go back to the 90s and probably
  • 4:45 - 4:46
    before that, but you know, I wasn't
  • 4:46 - 4:49
    around before that. So if you
  • 4:49 - 4:52
    look at kind of the the state of
  • 4:53 - 4:56
    network stack bugs in the 90s,
  • 4:56 - 4:59
    it was sort of very trivial stuff. For
  • 4:59 - 5:02
    those who were around, you might remember
  • 5:02 - 5:04
    like WinDuke and we had things like SYN
  • 5:04 - 5:07
    floods and Ping of dead
  • 5:07 - 5:09
    and you know Smurf and
  • 5:09 - 5:12
    LAND and Teardrop and Bonk and all
  • 5:12 - 5:15
    these mutations and Boink and what have
  • 5:15 - 5:17
    you and
  • 5:17 - 5:19
    and I wouldn't say they were really a
  • 5:19 - 5:21
    result of fuzzing, but they definitely
  • 5:21 - 5:23
    were some kind of result of some kind of
  • 5:23 - 5:26
    runtime testing. I think at this time
  • 5:26 - 5:27
    very few people were actually doing any
  • 5:27 - 5:30
    kind of targeted code review or
  • 5:30 - 5:32
    fuzzing, but people were at least, you
  • 5:32 - 5:34
    know, people observed certain bugs in the
  • 5:34 - 5:37
    network stack and. Observe that they
  • 5:37 - 5:38
    could write tools and exploits to use
  • 5:39 - 5:41
    them mostly for things like denial of
  • 5:41 - 5:44
    service. But that's kind of
  • 5:44 - 5:46
    where this starts, sort of mid 90s
  • 5:46 - 5:49
    ish with these kind of trivial tools.
  • 5:50 - 5:51
    None of this should work today,
  • 5:52 - 5:55
    but that's that's kind of the the where
  • 5:55 - 5:58
    the history starts of this. And then
  • 5:58 - 6:00
    we kind of get into the late 90s and the
  • 6:00 - 6:01
    2000s and
  • 6:03 - 6:06
    you know. We had better, we had
  • 6:06 - 6:08
    some libraries like libnet and things
  • 6:08 - 6:11
    like that. And somebody wrote this
  • 6:11 - 6:14
    tool called ISIC, the
  • 6:14 - 6:16
    IP Stack Integrity Checker.
  • 6:17 - 6:19
    And ISIC is really, really cool.
  • 6:20 - 6:23
    Somehow it's one of these tools that not
  • 6:23 - 6:25
    many people, everybody should know about
  • 6:25 - 6:27
    them. But you know, I when I talk to
  • 6:27 - 6:29
    people, oftentimes they'll be like, what
  • 6:29 - 6:31
    is this thing? And then you go download
  • 6:31 - 6:33
    this thing that's 20-25 years old and you
  • 6:33 - 6:36
    run it against. Network stack and
  • 6:37 - 6:40
    sometimes bugs come out. It
  • 6:40 - 6:43
    was extremely successful back in its day.
  • 6:44 - 6:46
    It it would break windows up to Windows
  • 6:46 - 6:48
    7. There was some nasty bug in the UDP
  • 6:48 - 6:51
    handler. It's broken. It only sees IP
  • 6:51 - 6:54
    stack several times. I mean they twiddle
  • 6:54 - 6:56
    with their stack often, so sometimes
  • 6:56 - 6:57
    stuff breaks and they fix it and then two
  • 6:57 - 7:00
    years later it breaks again on something
  • 7:00 - 7:03
    else and so on and so on. It's definitely
  • 7:03 - 7:06
    broken to that BSDTCP/IP stack. The
  • 7:06 - 7:08
    top three I know because I I hit those
  • 7:08 - 7:11
    bugs too. And then kind of the bottom
  • 7:11 - 7:13
    one's the like Checkpoint Firewall and
  • 7:13 - 7:15
    the Gauntlet Firewall and the Raptor and
  • 7:15 - 7:18
    so on. I didn't, I never observed any of
  • 7:18 - 7:19
    that because I don't have access to that
  • 7:19 - 7:22
    hardware. And of course that hardware, I
  • 7:22 - 7:25
    mean this is this is basically from their
  • 7:25 - 7:27
    trophies file which is from the late 90s
  • 7:28 - 7:29
    and so this these these are kind of
  • 7:29 - 7:32
    products of that time. But like
  • 7:32 - 7:35
    dot, dot, dot because this this stuff,
  • 7:35 - 7:36
    this thing really used to break
  • 7:36 - 7:39
    everything and on occasion it still
  • 7:39 - 7:41
    breaks stuff, right? And
  • 7:42 - 7:44
    the the way ISIC really works is it
  • 7:45 - 7:48
    understands the structure of an IP packet
  • 7:48 - 7:50
    and the structure of a UDP packet and the
  • 7:50 - 7:52
    TCP packet and an ICMP packet and an
  • 7:52 - 7:55
    Ethernet frame and it just,
  • 7:55 - 7:58
    you know, bit bangs around and
  • 7:58 - 8:01
    has some options to go hey. Do you want
  • 8:01 - 8:03
    to fiddle with these flags or TCP flags?
  • 8:03 - 8:06
    Or do you want to fiddle with IP options
  • 8:06 - 8:08
    or TCP options? And or do you want to
  • 8:08 - 8:11
    mess with the checksum? And then it just
  • 8:11 - 8:14
    keeps this one buffer and then has this
  • 8:14 - 8:17
    loop and it just keeps changing a few
  • 8:17 - 8:18
    bits and keeps firing these things off.
  • 8:19 - 8:22
    The speed of ISIC is really pretty bad,
  • 8:22 - 8:24
    pretty insane. Like it's it's fast.
  • 8:26 - 8:29
    But it it's limited, right?
  • 8:29 - 8:31
    It can only it doesn't understand any
  • 8:31 - 8:34
    kind of state and
  • 8:34 - 8:36
    so it while it finds a certain amount of
  • 8:36 - 8:38
    bugs, there is beyond a certain point it
  • 8:38 - 8:40
    just it can't get beyond that. It can't
  • 8:40 - 8:43
    find those bugs, right. But even so
  • 8:43 - 8:45
    that's this is kind of where
  • 8:45 - 8:46
    we've been stuck for 20 years, right.
  • 8:46 - 8:48
    That's so it's kind of why I wanted to do
  • 8:48 - 8:51
    this presentation. Since, you know, you
  • 8:51 - 8:53
    can use SCAPI and do similar things with
  • 8:53 - 8:56
    SCAPI. The reason I like ISIC and still
  • 8:56 - 8:58
    like it today is because it's it's
  • 8:59 - 9:01
    it's very simple C code and it's just
  • 9:01 - 9:02
    blazingly fast.
  • 9:04 - 9:07
    Anyway, how do we go beyond this trivial
  • 9:07 - 9:08
    state? We've been stuck here for 20
  • 9:08 - 9:11
    something years. It's time to
  • 9:11 - 9:14
    move on, right? As I mentioned
  • 9:14 - 9:17
    before, it turns out. TCP,
  • 9:17 - 9:19
    which sits on top of IP and some other
  • 9:20 - 9:22
    things, has state
  • 9:24 - 9:26
    and there are, and you
  • 9:26 - 9:29
    can ask network engineers and people that
  • 9:29 - 9:30
    build these network stacks and so on.
  • 9:31 - 9:33
    There are bugs that sit behind these
  • 9:33 - 9:35
    states that if you just throw packets at
  • 9:35 - 9:36
    it without ever getting into the state,
  • 9:37 - 9:38
    you will never hit these kind of bugs,
  • 9:38 - 9:41
    right? You can't. So
  • 9:41 - 9:43
    you just can't get there with crafting
  • 9:43 - 9:46
    packets, simple packets. You need to like
  • 9:46 - 9:47
    complete your three-way handshake and
  • 9:47 - 9:50
    like set up like the right extensions and
  • 9:50 - 9:52
    the right flags. And like I send you this
  • 9:52 - 9:53
    and you send me this and I send you this
  • 9:53 - 9:55
    other thing and you send me this thing.
  • 9:55 - 9:57
    And all of a sudden you get into this
  • 9:57 - 10:00
    weird state where maybe some bug happens,
  • 10:00 - 10:03
    right? But that's pretty deep. That's
  • 10:03 - 10:04
    pretty deep into like your network
  • 10:04 - 10:07
    protocol. If you're just banging out some
  • 10:07 - 10:10
    bits, you never get there, right?
  • 10:11 - 10:14
    And so. Getting to
  • 10:14 - 10:16
    this point and trying to fuzz beyond
  • 10:16 - 10:19
    that, this is hard and it takes a lot of
  • 10:19 - 10:19
    time.
  • 10:22 - 10:23
    As I said, the state really hasn't
  • 10:23 - 10:25
    advanced much beyond this.
  • 10:26 - 10:29
    There's been some research the last
  • 10:29 - 10:31
    couple of years cause I kind of googled
  • 10:31 - 10:32
    around for these things. And so there's
  • 10:32 - 10:35
    this Amnesia33 and then there's
  • 10:35 - 10:37
    this academic paper TCP Fuzz
  • 10:38 - 10:39
    where they kind of use this.
  • 10:41 - 10:43
    Network stress / test
  • 10:43 - 10:46
    tool by Google, which isn't really a
  • 10:46 - 10:48
    fuzzer, but you can kind of
  • 10:49 - 10:51
    coax it into like becoming a fuzzer-ish
  • 10:51 - 10:54
    called packet driller. And so they found
  • 10:54 - 10:56
    some interesting things with that and
  • 10:56 - 10:58
    I'll kind of circle back to these
  • 10:58 - 10:59
    things a bit later.
  • 11:01 - 11:04
    So of course you know with with the
  • 11:04 - 11:06
    enormous success in the last decade and
  • 11:06 - 11:08
    change of things like AFL and AFL+.
  • 11:08 - 11:10
    The first thought is, aha, let's let's
  • 11:10 - 11:13
    use coverage guided fuzzing. Fantastic.
  • 11:13 - 11:16
    Let's do that. And that would be
  • 11:16 - 11:18
    great. It turns out it's not that
  • 11:18 - 11:21
    simple. There there have been attempts
  • 11:21 - 11:23
    in principle. Yes, you want to do
  • 11:23 - 11:25
    coverage guided fuzzing. It's not
  • 11:25 - 11:28
    easy. There are some
  • 11:28 - 11:31
    problems, right? So first of all, AFL and
  • 11:31 - 11:34
    AFL++ work incredibly well
  • 11:34 - 11:37
    when: A you have a file
  • 11:37 - 11:39
    where really all of your state is
  • 11:39 - 11:41
    maintained in a file, or you have a very
  • 11:41 - 11:43
    simple API where you go.
  • 11:44 - 11:46
    Here's a here's data and here's a length
  • 11:46 - 11:49
    and go parse right. It is. It
  • 11:49 - 11:51
    works exceptionally well for those
  • 11:51 - 11:54
    situations and a lot of
  • 11:54 - 11:57
    attack surfaces like that. A
  • 11:57 - 12:00
    network stack doesn't quite work like
  • 12:00 - 12:02
    that, right? It's
  • 12:02 - 12:05
    not. It's not a file. It's a
  • 12:05 - 12:08
    protocol, which means there's things that
  • 12:08 - 12:10
    get to state that doesn't isn't like one
  • 12:10 - 12:13
    bit inside of a packet, right? So it's
  • 12:13 - 12:15
    it's this weird thing that you is like
  • 12:15 - 12:18
    encoded in a series of things. It isn't
  • 12:18 - 12:20
    like represented by one bit or one byte
  • 12:20 - 12:22
    or like a length field or something like
  • 12:22 - 12:24
    that. That's one. The
  • 12:24 - 12:27
    other one is packet queues.
  • 12:28 - 12:29
    What I mean by packet queues is
  • 12:29 - 12:32
    basically. So if you let's say if you
  • 12:32 - 12:34
    have a network, you have a file parser,
  • 12:34 - 12:36
    usually you have like file parse function
  • 12:36 - 12:38
    and you have a length and a pointer and
  • 12:38 - 12:40
    it parses the thing and it returns and it
  • 12:40 - 12:43
    does something. When you do a network
  • 12:43 - 12:45
    stack, because it is so tightly
  • 12:45 - 12:47
    integrated into the bowels of your
  • 12:47 - 12:49
    operating system, it
  • 12:50 - 12:52
    like what happens is a packet comes in
  • 12:53 - 12:54
    and the NIC kind of sees it and it
  • 12:54 - 12:56
    triggers an interrupt and the interrupt
  • 12:56 - 12:57
    handler kicks in and goes great and it
  • 12:58 - 12:59
    kind of takes it from the interrupt
  • 12:59 - 13:01
    queue. And then it looks at it and it
  • 13:01 - 13:03
    goes, oh, this is Ethernet. I'm going to
  • 13:03 - 13:04
    put this on Ethernet queue. And then at
  • 13:04 - 13:07
    some point your Ethernet handler wakes up
  • 13:07 - 13:08
    and it goes, oh great, I'm taking another
  • 13:08 - 13:10
    queue and it goes, oh, this is IP, great,
  • 13:11 - 13:12
    I'm put this on the IP queue and it goes
  • 13:12 - 13:14
    back to something else. The IP queue at
  • 13:14 - 13:17
    some point wakes up, takes this thing off
  • 13:17 - 13:18
    the queue and goes, Oh yeah, great, this
  • 13:18 - 13:21
    is IP so and so. Oh, it's TCP. Yes, yeah,
  • 13:21 - 13:23
    I have an open TCP port. Great. I'm going
  • 13:23 - 13:25
    to go put this on the TCP queue and then
  • 13:25 - 13:26
    the TCP queue at some point, you know,
  • 13:26 - 13:28
    TCP thread wakes up, takes it from the
  • 13:28 - 13:31
    TCP queue and goes. Yes, I know this guy.
  • 13:31 - 13:32
    I've been talking to this guy. I have a
  • 13:33 - 13:34
    userland service that's running. I'm
  • 13:34 - 13:36
    going to take this thing and give it to
  • 13:36 - 13:38
    the userland guy and the userland guy
  • 13:38 - 13:40
    just called receive and receive now
  • 13:40 - 13:42
    return. And and so it's you have
  • 13:43 - 13:46
    you have a bunch of these steps and
  • 13:46 - 13:48
    and it's it's they're not it's not
  • 13:48 - 13:51
    linear. It's not 1,2,3. It's one
  • 13:51 - 13:53
    guy and then somebody else and then
  • 13:53 - 13:55
    somebody else and then somebody else
  • 13:56 - 13:59
    and. While you can
  • 13:59 - 14:01
    instrument that, it's not quite as simple
  • 14:01 - 14:04
    right? As I mentioned
  • 14:05 - 14:07
    the other one issue is
  • 14:08 - 14:11
    the state can easily be captured in
  • 14:11 - 14:14
    in any kind of file or set of
  • 14:14 - 14:17
    data. It's really like a a sequence
  • 14:17 - 14:18
    of things.
  • 14:19 - 14:21
    So that that's where things get
  • 14:21 - 14:24
    problematic and and there are people that
  • 14:24 - 14:26
    have you know discussions and people have
  • 14:26 - 14:28
    tried. And
  • 14:30 - 14:32
    someone said, hey, you know, we actually
  • 14:32 - 14:34
    tried with AFL and we got somewhere,
  • 14:35 - 14:36
    but they said, you know, we ran into
  • 14:36 - 14:37
    problems, which is exactly what I was
  • 14:37 - 14:40
    just talking about. The the queues,
  • 14:40 - 14:42
    the async, the asynchronicity of
  • 14:42 - 14:45
    it all makes it very
  • 14:45 - 14:48
    difficult. It it doesn't mean you can't
  • 14:48 - 14:50
    do coverage guide fuzzing, but it means
  • 14:50 - 14:53
    it requires an extra set of work
  • 14:53 - 14:55
    beyond what we've done before
  • 14:57 - 15:00
    and so. I mean, my
  • 15:00 - 15:02
    opinion is we have to work towards
  • 15:02 - 15:05
    getting this, but we are
  • 15:05 - 15:08
    very far away from it. Getting that done
  • 15:08 - 15:11
    in any kind of way that is reproducible,
  • 15:11 - 15:13
    easy to set up, doing like a
  • 15:13 - 15:16
    one-off where it works for one guy and
  • 15:16 - 15:19
    then getting to some level
  • 15:19 - 15:21
    of fuzzing. That's what this this guy is
  • 15:21 - 15:23
    describing, right? But getting that to
  • 15:23 - 15:25
    any kind of level where we can repro that
  • 15:25 - 15:28
    and and make it, you know. Not make your
  • 15:28 - 15:30
    life miserable when you try to set it up.
  • 15:30 - 15:32
    Nowhere close to that.
  • 15:35 - 15:36
    So as I said, this is that this is why
  • 15:36 - 15:39
    like the state fuzzing is just hard and
  • 15:39 - 15:42
    time consuming and I'm
  • 15:42 - 15:44
    definitely not here to talk about
  • 15:44 - 15:45
    coverage guided fuzzing. I just wanted to
  • 15:45 - 15:48
    kind of see where we're going. I'm
  • 15:49 - 15:50
    basically I'm very I'm a
  • 15:53 - 15:55
    I write code I do you know I'm lazy right
  • 15:55 - 15:58
    so. And the thought
  • 15:58 - 16:00
    I had is instead of doing that,
  • 16:01 - 16:03
    what we really want is I want to have my
  • 16:03 - 16:05
    own network stack that I can fiddle with
  • 16:05 - 16:07
    and then talk to somebody else's network
  • 16:07 - 16:10
    stack. OK, basically, you know, modify
  • 16:10 - 16:11
    this network stack so that it adds
  • 16:11 - 16:13
    fuzzing. And because the network stack's
  • 16:13 - 16:14
    already there, I get all the state for
  • 16:14 - 16:17
    free because the stack is doing that. But
  • 16:17 - 16:20
    as I said, I am lazy. There's no way I'm
  • 16:20 - 16:21
    building my own network stack.
  • 16:24 - 16:26
    But the good news is I don't have to,
  • 16:26 - 16:29
    right? If this was 10,15,20 years
  • 16:29 - 16:31
    ago, you would have been out of luck and
  • 16:31 - 16:34
    you would have had to do that. But
  • 16:34 - 16:36
    today it turns out we have a number
  • 16:37 - 16:38
    of userland TCP/IP stacks, right?
  • 16:40 - 16:43
    And they're often used
  • 16:43 - 16:46
    for like in embedded stuff or to test
  • 16:46 - 16:48
    certain things. Somebody wrote a port
  • 16:48 - 16:50
    scanner with it, like you can do all
  • 16:50 - 16:52
    sorts of things with it. But somehow, as
  • 16:52 - 16:54
    far as I can tell, no one's ever looked
  • 16:54 - 16:56
    at it and said, Great, let's go
  • 16:56 - 16:59
    co-opt one of these network stacks and
  • 16:59 - 17:01
    turn them into a fuzzer. And that was
  • 17:01 - 17:03
    kind of the idea I had. That's kind of
  • 17:03 - 17:04
    the crux of this presentation.
  • 17:06 - 17:09
    One of the things I did is looked
  • 17:09 - 17:12
    around and said, Okay, what's what's out
  • 17:12 - 17:13
    there? And it turns out there's quite a
  • 17:13 - 17:15
    few. There's libuinet, which is a
  • 17:15 - 17:18
    port of the BZ network stack to use
  • 17:18 - 17:21
    LANs. It's fairly old. It hasn't been
  • 17:21 - 17:22
    touched in eight years. I have no idea
  • 17:22 - 17:25
    what its current state is. I just
  • 17:25 - 17:28
    looked at it the time stamp. I was like,
  • 17:28 - 17:31
    uh, I don't want to mess with this. It
  • 17:31 - 17:33
    might just be too painful. There's PyTCP,
  • 17:33 - 17:34
    which is a fully functioning network
  • 17:34 - 17:36
    stack in Python.
  • 17:38 - 17:40
    I considered using that. It was a
  • 17:41 - 17:44
    bit too painful for what I had in mind.
  • 17:44 - 17:47
    It it does like it comes with its own.
  • 17:47 - 17:50
    Like DHCP server and things like that.
  • 17:50 - 17:51
    And that's that's too much. I I don't
  • 17:51 - 17:53
    want that. I just want the network stack.
  • 17:55 - 17:57
    So there's a few others. I looked at
  • 17:57 - 18:00
    Netstack, which is Google made this as
  • 18:00 - 18:01
    part of their Gvizor
  • 18:02 - 18:04
    products, offering, whatever.
  • 18:06 - 18:08
    And Netstack used to be a
  • 18:08 - 18:11
    separate thing and then it somehow got
  • 18:11 - 18:14
    moved into Gvizor like the repo.
  • 18:15 - 18:16
    And trying to separate one from the
  • 18:16 - 18:18
    other, I'm sure there's a way to do it. I
  • 18:18 - 18:20
    tried, couldn't quite get
  • 18:20 - 18:22
    there. I didn't spend much time on it,
  • 18:22 - 18:24
    but I'd say couldn't get it done within
  • 18:24 - 18:27
    an hour. And that was kind of like, OK,
  • 18:27 - 18:28
    you're out. I need something easier.
  • 18:30 - 18:32
    There's LwIP, which I know is used in a
  • 18:32 - 18:35
    few places. There's Smoltcp, which
  • 18:35 - 18:38
    is a TCP stack entirely written in
  • 18:38 - 18:41
    Rust, which is very exciting. picoTCP
  • 18:41 - 18:44
    uIP, there's a bunch of others. I
  • 18:44 - 18:46
    settled on picoTCP and I'll talk about
  • 18:46 - 18:47
    that in a minute.
  • 18:50 - 18:52
    Before I get to like the actual
  • 18:52 - 18:54
    implementation and kind of testing I did,
  • 18:55 - 18:57
    what do we actually want to fuzz?
  • 18:58 - 19:00
    This this isn't really a hard question,
  • 19:00 - 19:02
    but you know, we should determine this
  • 19:02 - 19:04
    before we actually set out to to fuzz
  • 19:04 - 19:06
    this thing, right? So yes, the idea is we
  • 19:06 - 19:09
    take a userland TCP/IP stack, we modify
  • 19:09 - 19:11
    it. To fuzz the right things, we get the
  • 19:11 - 19:13
    state for free because the TCP cycle
  • 19:13 - 19:15
    already does that. But what do we then
  • 19:15 - 19:16
    want to fuzz, right? And the answer then
  • 19:16 - 19:19
    is, OK, let's go look at the
  • 19:19 - 19:22
    protocols and see what's there and where
  • 19:22 - 19:24
    we know their state and where we know
  • 19:24 - 19:26
    things go wrong and where we know things
  • 19:26 - 19:27
    have gone wrong in the past, right?
  • 19:27 - 19:29
    Basically stuff where there's complexity,
  • 19:29 - 19:32
    right? And if you're looking at, for
  • 19:32 - 19:35
    example, TCP. Like obviously your flags,
  • 19:35 - 19:38
    they tend to signal things and cause
  • 19:38 - 19:41
    transitions in states. You know,
  • 19:41 - 19:42
    obviously a SYN or a SYN ACK or
  • 19:44 - 19:45
    those kind of things tend to cause
  • 19:45 - 19:46
    transitions in state.
  • 19:48 - 19:50
    Window sizes are interesting. They've
  • 19:50 - 19:52
    definitely. They're kind of subtle, they
  • 19:52 - 19:55
    seem trivial, but they've caused problems
  • 19:55 - 19:56
    in the past. So messing with window size
  • 19:56 - 19:59
    is a great idea. Checksums
  • 19:59 - 20:00
    shouldn't be a problem,
  • 20:02 - 20:04
    but I have seen problems where checksum
  • 20:04 - 20:05
    functions will read out of bound by one
  • 20:05 - 20:08
    or two bytes. So on occasion checksums
  • 20:08 - 20:11
    are a problem. Obviously the
  • 20:11 - 20:13
    size of packets is interesting, right?
  • 20:13 - 20:16
    If, you know what happens if you get a 0
  • 20:16 - 20:18
    size packet, right? Is that even legal?
  • 20:18 - 20:20
    Spoiler turns out for UDP it is legal,
  • 20:20 - 20:22
    for TCP it is not.
  • 20:24 - 20:26
    What if you send really large packets?
  • 20:26 - 20:28
    What if they're larger than the MTU? What
  • 20:28 - 20:30
    if you use jumbo frames and so on? Some
  • 20:30 - 20:32
    of this triggers fragmentation, some of
  • 20:32 - 20:34
    it doesn't. And obviously
  • 20:35 - 20:36
    the obvious one is length fields, right?
  • 20:36 - 20:37
    Can we mess with length fields?
  • 20:39 - 20:41
    And then obviously fragmentation is
  • 20:42 - 20:43
    interesting, right? We know there have
  • 20:43 - 20:45
    been plenty of bugs with fragmentation in
  • 20:45 - 20:46
    the past. We know there's going to be
  • 20:46 - 20:48
    bugs in the future with fragmentation. So
  • 20:48 - 20:50
    that's that's definitely something you
  • 20:50 - 20:52
    you would want to fuzz. And you get into
  • 20:52 - 20:55
    all sorts of is it too big or too small
  • 20:55 - 20:56
    or too many or not enough or out of order
  • 20:56 - 20:59
    or some stuff timed out or some
  • 20:59 - 21:01
    duplicates or you set a don't fragment
  • 21:01 - 21:03
    flag, but you fragment anyway. You know,
  • 21:03 - 21:05
    you get all of these weird fragmentation
  • 21:05 - 21:07
    things. And then sort of
  • 21:07 - 21:10
    lastly is, you know, options, right?
  • 21:10 - 21:13
    So IPv4 options, TCP options,
  • 21:13 - 21:15
    IPv6 extension headers, right?
  • 21:16 - 21:19
    Insertion, truncation, removal, out of
  • 21:19 - 21:21
    order, any of combination of
  • 21:21 - 21:24
    these could be interesting, could lead to
  • 21:24 - 21:26
    some kind of issues
  • 21:27 - 21:30
    in state or parser or a combination of
  • 21:30 - 21:32
    both. So that's stuff that we would want
  • 21:32 - 21:33
    to fuzz.
  • 21:37 - 21:39
    So as all of these may or may not relate
  • 21:39 - 21:42
    to state, I care in the sense that I want
  • 21:42 - 21:44
    to get to state, but I also don't really
  • 21:44 - 21:47
    care in the sense that because I already
  • 21:47 - 21:49
    have a network, I userland TCP/IP stack
  • 21:49 - 21:51
    does the state for me. So I just kind of
  • 21:51 - 21:53
    piggyback off of that. And
  • 21:53 - 21:55
    then of course you can just build on it,
  • 21:55 - 21:57
    right? It's like, OK, well what about ICMP?
  • 21:57 - 21:59
    What about SCTP? What about IGMP and so
  • 21:59 - 22:02
    on for SCTP? It's like, OK, pick
  • 22:02 - 22:04
    SCTP doesn't support it. I wanted to use
  • 22:04 - 22:06
    loop UInet, but I never got that far. So
  • 22:07 - 22:08
    ultimately I want to get there, but
  • 22:10 - 22:12
    not not even close to it. SCTP, by the
  • 22:12 - 22:14
    way, is one of these weird things where,
  • 22:15 - 22:17
    like, if you're a network nerd, you've
  • 22:17 - 22:18
    probably heard of it, but you've never
  • 22:18 - 22:21
    seen it because nobody, nobody uses
  • 22:21 - 22:23
    SCTP except when you get to the TelCo
  • 22:23 - 22:25
    world. And then everybody uses
  • 22:25 - 22:27
    SCTP, right? So it's one of these really
  • 22:27 - 22:29
    large niches, but outside of that,
  • 22:29 - 22:31
    nobody, nobody really uses it.
  • 22:34 - 22:36
    Right. So that's kind of OK when I want
  • 22:36 - 22:39
    to fuzz and how I want to fuzz. Let's
  • 22:39 - 22:41
    let's let's talk practical things because
  • 22:41 - 22:43
    I did, I kind of built this fuzzer right
  • 22:43 - 22:46
    and it does this thing. So how does that
  • 22:46 - 22:48
    work right. So well the first thing you
  • 22:48 - 22:50
    do is as I said you pick one. So
  • 22:51 - 22:54
    I chose picoTCP and I'll get into that in
  • 22:54 - 22:56
    a moment. Your steps for set up are
  • 22:56 - 22:59
    relatively easy. Essentially
  • 22:59 - 23:02
    you set up a TUN/TAP interface. You
  • 23:02 - 23:04
    play around with like a bridge and like
  • 23:05 - 23:07
    add if and BRCTL and so on
  • 23:08 - 23:10
    and then you need something to drive
  • 23:10 - 23:13
    traffic. And So what I did is I created a
  • 23:13 - 23:15
    simple echo service and an echo client
  • 23:15 - 23:17
    and that obviously you do that in a
  • 23:17 - 23:19
    loop but it kind of ends up driving
  • 23:19 - 23:21
    traffic till the end of time, which is
  • 23:21 - 23:22
    great because now I can just hook into
  • 23:22 - 23:25
    the network stack and and start messing
  • 23:25 - 23:28
    with things. And because the, you know,
  • 23:28 - 23:30
    the echo client server just keeps sending
  • 23:30 - 23:32
    data back and forth and back and forth
  • 23:32 - 23:33
    and back and forth, it'll just that just
  • 23:33 - 23:36
    drives fuzzing, right? And then the last
  • 23:36 - 23:37
    step in the setup is yes, you need to
  • 23:37 - 23:39
    modify your TCP/IP stack and add fuzzing
  • 23:40 - 23:41
    to normal traffic.
  • 23:43 - 23:46
    So yeah, as I said, I
  • 23:46 - 23:48
    used picoTCP and here's why.
  • 23:49 - 23:51
    So I evaluated a bunch of these things.
  • 23:51 - 23:54
    Initially I wanted to go with PyTCP.
  • 23:56 - 23:58
    It I just didn't. It was a little bit too
  • 23:58 - 24:01
    hairy for what I wanted to do, but it
  • 24:02 - 24:05
    it it does work. I was like, OK, picoTCP
  • 24:05 - 24:07
    looks great. I used to write a ton of C
  • 24:07 - 24:09
    code. I haven't touched much C in the
  • 24:09 - 24:12
    last couple of years, but it was
  • 24:12 - 24:14
    nice because I got an I now have an
  • 24:14 - 24:17
    excuse to write some C code. And picoTCP
  • 24:18 - 24:20
    is it's pretty
  • 24:20 - 24:23
    simple C code. It's not very complicated.
  • 24:23 - 24:25
    It's easy to get started with it. It's
  • 24:25 - 24:28
    easy to integrate into into your own
  • 24:28 - 24:31
    userland program. It's easy to read the
  • 24:31 - 24:33
    code. It is easy to modify. And best of
  • 24:33 - 24:35
    all, it's open source and free software.
  • 24:36 - 24:39
    It's entirely GPL. So that means I
  • 24:39 - 24:40
    can do whatever the hell I want with it.
  • 24:43 - 24:46
    Sweet. So yeah, I should have
  • 24:46 - 24:49
    put one of this in this slide,
  • 24:49 - 24:51
    but essentially. I don't know if you can
  • 24:51 - 24:53
    read the code from how far, but
  • 24:53 - 24:54
    essentially one of the cool things about
  • 24:54 - 24:57
    picoTCP is that it it comes with
  • 24:58 - 25:01
    very simple, very easy APIs. And so I
  • 25:01 - 25:03
    built a simple echo client using the
  • 25:03 - 25:06
    APIs. And so essentially
  • 25:06 - 25:09
    you kind of go and say, yeah, I want the
  • 25:09 - 25:11
    stack to have this IP, you know, I want
  • 25:12 - 25:14
    to, you know, create a socket and
  • 25:15 - 25:16
    then go connect with somebody else on
  • 25:16 - 25:17
    that socket.
  • 25:20 - 25:22
    And that's just, I mean, it's the APIs
  • 25:22 - 25:23
    are really, really simple.
  • 25:25 - 25:27
    Sweet. So with that,
  • 25:28 - 25:30
    I I'll do a demo.
  • 25:31 - 25:34
    I'll say this though, lower expectations.
  • 25:35 - 25:38
    I didn't quite get as far
  • 25:38 - 25:40
    as I wanted to. The the fuzzer works.
  • 25:40 - 25:43
    Just barely though, but it works. I
  • 25:43 - 25:44
    didn't implement everything I wanted to
  • 25:44 - 25:47
    implement. There's lots of to do's.
  • 25:48 - 25:50
    The fragmentation, for example, I'm not
  • 25:50 - 25:52
    there yet. In terms of
  • 25:53 - 25:55
    trophies, not really any significant
  • 25:55 - 25:57
    crashes yet. I did find a minor denial of
  • 25:57 - 25:59
    service in like dominic street network
  • 25:59 - 26:02
    stack where if I'm throwing packets at
  • 26:02 - 26:04
    it, something else at some point can't
  • 26:04 - 26:05
    connect to it until you kind of stop
  • 26:05 - 26:08
    throwing packets at it. I don't know if
  • 26:08 - 26:10
    that's really a state thing. That may
  • 26:10 - 26:12
    just be that the stack is so slow it
  • 26:12 - 26:14
    can't keep up, even though I'm not
  • 26:14 - 26:16
    throwing packets at it that fast.
  • 26:17 - 26:19
    But yeah, let me let me do a little
  • 26:20 - 26:20
    demo.
  • 26:23 - 26:25
    Sweet. So here I have an open BSD machine
  • 26:25 - 26:27
    which is running my echo daemon
  • 26:30 - 26:31
    and here
  • 26:33 - 26:36
    I have my my fuzzer. This
  • 26:36 - 26:39
    runs, yeah, a Linux machine.
  • 26:40 - 26:41
    So this is this one is
  • 26:42 - 26:45
    182168.11 dot I think
  • 26:45 - 26:48
    131 or 130 and
  • 26:48 - 26:50
    then the open busy machine is 132
  • 26:52 - 26:54
    and so you'll see traffic here in a
  • 26:54 - 26:57
    second and should have
  • 27:02 - 27:04
    yeah sweet. OK
  • 27:05 - 27:08
    so kind of drive traffic from here and it
  • 27:08 - 27:09
    goes like yeah yeah I'm fuzzing and
  • 27:09 - 27:12
    fuzzing and fuzzing and fuzzing. And then
  • 27:12 - 27:15
    Wizzy goes, yeah, I see your packets and
  • 27:16 - 27:17
    they're kind of fuzzing and they're
  • 27:17 - 27:19
    echoing some things, but it's dropping a
  • 27:19 - 27:21
    lot because there's all sorts of things
  • 27:21 - 27:22
    it doesn't like.
  • 27:24 - 27:26
    And then like if you go through this
  • 27:26 - 27:28
    stuff, there's you'll see a whole bunch
  • 27:28 - 27:30
    of like retransmissions and like some
  • 27:30 - 27:33
    broken packets and all sorts of things
  • 27:33 - 27:36
    like it's not it's.
  • 27:36 - 27:38
    It's good enough that
  • 27:39 - 27:41
    packets get through and get processed and
  • 27:41 - 27:42
    make it pass the three-way handshake and
  • 27:42 - 27:44
    they get echoed back. It's broken enough
  • 27:44 - 27:46
    that a lot of this stuff doesn't get
  • 27:46 - 27:48
    through and gets stuck somewhere. And my
  • 27:48 - 27:50
    hope is somewhere in there, it will find
  • 27:50 - 27:53
    bugs. Uhm
  • 27:53 - 27:56
    This code started working this morning at
  • 27:56 - 27:57
    about 6 a.m.
  • 27:59 - 28:00
    Yeah, so
  • 28:00 - 28:06
    *Applause*
  • 28:06 - 28:08
    The the downside is I I'd hope to find a
  • 28:08 - 28:11
    bug or two. Not yet, which is kind of
  • 28:11 - 28:14
    annoying, but
  • 28:14 - 28:16
    this is this is about as far as as I go
  • 28:16 - 28:19
    with that. So yeah,
  • 28:19 - 28:21
    it's pre-alpha version. There's
  • 28:21 - 28:24
    work to be done. As I said, it works, but
  • 28:24 - 28:27
    just barely. As I said, I can force
  • 28:27 - 28:29
    packets through the stack, do a three-way
  • 28:29 - 28:32
    handshake, and sometimes the echo
  • 28:32 - 28:33
    service even acknowledges and sends it
  • 28:33 - 28:36
    back to me, which is great. Sometimes
  • 28:36 - 28:38
    my echo client crashes and that's why I
  • 28:38 - 28:41
    have a bash loop around it. As I said,
  • 28:41 - 28:43
    it's it's ugly, but it works.
  • 28:44 - 28:46
    And as I said, I haven't implemented
  • 28:46 - 28:49
    fragmentation yet, so lots of
  • 28:49 - 28:50
    work to be done. The code is incredibly
  • 28:50 - 28:53
    ugly, but given and I wanted to get
  • 28:53 - 28:55
    further than I did today, but it does
  • 28:55 - 28:58
    work somewhat
  • 28:59 - 29:02
    and I put it on GitHub. So if you want
  • 29:02 - 29:03
    to, if you want to play around with it,
  • 29:03 - 29:06
    you can. Expect updates in the
  • 29:06 - 29:08
    next couple of days and weeks. I hope to
  • 29:08 - 29:11
    get this in a much better state. It is
  • 29:11 - 29:12
    really ugly by the way,
  • 29:13 - 29:16
    and it currently
  • 29:16 - 29:18
    I don't actually have a full picoTCP code
  • 29:18 - 29:21
    in there. I just took a diff and the diff
  • 29:21 - 29:22
    is kind of screwed up so I do need to fix
  • 29:22 - 29:25
    it. But everything if you really want to
  • 29:25 - 29:27
    get working, everything is there. But
  • 29:27 - 29:28
    I'll in the next couple of days I will
  • 29:28 - 29:30
    clean it up and make it easier to work
  • 29:30 - 29:32
    with. But if you want to get going to
  • 29:32 - 29:34
    like right now. It's going to take you
  • 29:34 - 29:37
    some effort, but it's there. But
  • 29:37 - 29:39
    if you hold on for a few more days, maybe
  • 29:39 - 29:42
    a week, I will make sure
  • 29:42 - 29:44
    it works. It's it'll be easier.
  • 29:46 - 29:48
    Yeah, I'm kind of out of time, but last
  • 29:48 - 29:51
    thing I kind of wanted to talk about is
  • 29:52 - 29:54
    why stop at one fuzzer, right? One of the
  • 29:55 - 29:57
    really cool things I like about AFL++ is
  • 29:57 - 30:00
    its integration with other fuzzers. And I
  • 30:00 - 30:02
    think that's something we should start
  • 30:02 - 30:04
    doing in everything we fuzz. It's like,
  • 30:04 - 30:05
    why stop at one fuzzer? If there's
  • 30:05 - 30:08
    something else, find a way to make them
  • 30:08 - 30:10
    work together, to cooperate and
  • 30:10 - 30:13
    collaborate and so on. I
  • 30:13 - 30:16
    mentioned the package ruler before.
  • 30:16 - 30:17
    Like you could definitely get some
  • 30:17 - 30:19
    package ruler in there. Why not throw
  • 30:19 - 30:21
    some ISIC in there? There's IPv6
  • 30:21 - 30:24
    toolkit, there's a few others. So I'd say
  • 30:24 - 30:26
    don't just stop at one fuzzer, combine a
  • 30:26 - 30:29
    bunch of things. Yeah, I was talking
  • 30:29 - 30:30
    about some previous research.
  • 30:32 - 30:34
    Yeah. As for conclusion, I don't really
  • 30:34 - 30:37
    have much of A conclusion except for I
  • 30:37 - 30:38
    should have started this earlier and
  • 30:38 - 30:39
    gotten further.
  • 30:39 - 30:41
    *laughs*
  • 30:43 - 30:44
    I do have long-term goals and a call to
  • 30:44 - 30:46
    action, right? To me, it's clear
  • 30:46 - 30:49
    that using a userland TCP/IP stack
  • 30:49 - 30:52
    will move the state beyond where we are
  • 30:52 - 30:55
    today with. Just using
  • 30:55 - 30:57
    ISIC for example, right? ISIC still finds
  • 30:57 - 30:59
    bugs, but you know, it's twentyfive years
  • 30:59 - 31:02
    old. We let's have a better approach,
  • 31:02 - 31:04
    right? And so I think using
  • 31:04 - 31:06
    userland TCP/IP stack is seems very
  • 31:06 - 31:08
    promising to me. I think it's a good move
  • 31:08 - 31:11
    forward. It's not the end
  • 31:11 - 31:13
    goal, right? Ultimately we do want
  • 31:13 - 31:16
    coverage guided fuzzing and but I don't
  • 31:16 - 31:17
    think those are mutually exclusive. In
  • 31:17 - 31:19
    fact, I think both will work well
  • 31:19 - 31:22
    together. As I said, doing this
  • 31:22 - 31:23
    currently is very difficult.
  • 31:24 - 31:27
    I'm hoping to you know find other people
  • 31:27 - 31:28
    that will want to work on this as well.
  • 31:29 - 31:31
    My goal here is really just to get things
  • 31:31 - 31:33
    moving and get some ideas going, really.
  • 31:35 - 31:36
    Yeah, I guess I'm one minute over time,
  • 31:36 - 31:38
    but that's that's essentially my
  • 31:38 - 31:38
    presentation.
  • 31:39 - 31:46
    *Applause
  • 31:46 - 31:49
    Thank you. All right. We have
  • 31:49 - 31:52
    8 minutes for questions. So if you have
  • 31:52 - 31:55
    any questions, please line up at the
  • 31:55 - 31:58
    microphones and we will take them. And if
  • 31:58 - 32:00
    you're on the stream, you can also ask
  • 32:00 - 32:03
    questions on the Internet. And someone
  • 32:03 - 32:05
    already did. So please go ahead.
  • 32:05 - 32:07
    Yes, thank you. Thank you for the great
  • 32:07 - 32:09
    talk and the great effort and getting it
  • 32:09 - 32:12
    ready for today. One question from the
  • 32:12 - 32:15
    Internet here is where do you see like?
  • 32:15 - 32:17
    What else do you see that that could be
  • 32:17 - 32:20
    done like fuzzing ICMP
  • 32:20 - 32:22
    or or so on? It's like good userland
  • 32:22 - 32:25
    tools also available here. Just what are
  • 32:25 - 32:27
    general thoughts on the landscape?
  • 32:28 - 32:30
    Yeah, that's a really good question. ICMP
  • 32:30 - 32:31
    think is a good one because I mean that's
  • 32:31 - 32:34
    one of these things where usually. I
  • 32:34 - 32:36
    I see packets generally don't come out of
  • 32:36 - 32:37
    nowhere. They tend to come out of
  • 32:38 - 32:39
    something in the state went wrong. Like
  • 32:39 - 32:41
    you're talking to the TCP thing and all
  • 32:41 - 32:43
    of a sudden the port closes and then you
  • 32:43 - 32:44
    get an ICMP going, hey, you know, port
  • 32:44 - 32:47
    closed or something. So that's definitely
  • 32:47 - 32:50
    stuff you can do to
  • 32:50 - 32:52
    some extent. I have that implemented in
  • 32:52 - 32:55
    the sense that I don't, I haven't don't
  • 32:55 - 32:58
    have any code that explicitly evokes ICMP
  • 32:59 - 33:01
    packets, which is something that I think
  • 33:01 - 33:03
    should be added. But I do have code that
  • 33:03 - 33:05
    says, hey, if the network stack generates
  • 33:05 - 33:08
    ICMP messages, I will go fuzz that. So
  • 33:08 - 33:11
    that is implemented. But
  • 33:12 - 33:14
    ICMP is is a really good one. There's
  • 33:14 - 33:16
    definitely more work to be done there. I
  • 33:16 - 33:17
    mentioned some of these things before.
  • 33:19 - 33:22
    So it's yeah, so definitely
  • 33:22 - 33:24
    IPv6, which I haven't implemented yet.
  • 33:24 - 33:25
    The extensions I think is interesting.
  • 33:27 - 33:29
    Yeah, ICMP here, IGMP is another one.
  • 33:29 - 33:31
    SCTP. I mean the
  • 33:32 - 33:34
    opportunities are really boundless and
  • 33:34 - 33:36
    endless, right. So I think it's a great
  • 33:36 - 33:37
    question. I don't have the answer to all
  • 33:37 - 33:39
    of them. I think I enumerated some.
  • 33:40 - 33:43
    There's definitely more it would make
  • 33:43 - 33:45
    sense as an exercise to to really dive
  • 33:45 - 33:47
    deep into kind of every
  • 33:47 - 33:49
    possible thing you can have in in your
  • 33:49 - 33:51
    state in TCP/IP stack, explicitly
  • 33:51 - 33:54
    enumerate it and then go kind of like
  • 33:54 - 33:55
    this goal oriented approach where you go.
  • 33:56 - 33:58
    Have I implemented this? No. How do I do
  • 33:58 - 33:59
    it? Have I implemented this? Have I
  • 33:59 - 34:01
    implemented this? As I said, I kind of
  • 34:01 - 34:04
    ran out of time. I'd like to do this. I
  • 34:04 - 34:05
    haven't done that yet.
  • 34:07 - 34:09
    All right. We take mic #2, please.
  • 34:10 - 34:13
    Hello. Thank you. I wasn't quite
  • 34:13 - 34:16
    clear. Are you fuzzing picoTCP
  • 34:16 - 34:19
    or are you just using picoTCP
  • 34:19 - 34:22
    to take care of a bunch of stuff that you
  • 34:22 - 34:24
    are too lazy to do. That's exactly it. I
  • 34:24 - 34:27
    I'm not. I mean you you can fuzz picoTCP
  • 34:27 - 34:29
    with this too. It's not what I'm doing
  • 34:29 - 34:31
    right. I'm using picoTCP to be my TCP
  • 34:31 - 34:33
    stack, right? That means I don't have to
  • 34:33 - 34:35
    write it. And then what I did is I
  • 34:35 - 34:37
    basically the way picoTCP works
  • 34:37 - 34:39
    is like it's not a library that in the
  • 34:39 - 34:41
    sense that like it's on the system. It's
  • 34:41 - 34:43
    a it's a library in the sense that it's
  • 34:43 - 34:45
    part of your application. I compile it
  • 34:45 - 34:47
    with me. And so because of
  • 34:47 - 34:50
    that, I can like the the picoTCP
  • 34:50 - 34:53
    source code is part of my program. So
  • 34:53 - 34:55
    I literally just add hooks in a bunch of
  • 34:55 - 34:57
    places in picoTCP and go, oh, before you
  • 34:57 - 35:00
    send this out, if it's IP, do IP fuzzing.
  • 35:00 - 35:03
    If it's TCP, do TCP fuzzing. If it's
  • 35:03 - 35:06
    ICMP, do ICMP fuzzing. Add extensions,
  • 35:06 - 35:08
    mutate extensions, that kind of stuff. So
  • 35:08 - 35:10
    you're fuzzing the remote system.
  • 35:10 - 35:12
    Correct. All right. Thank you.
  • 35:14 - 35:16
    All right. Do we have any further
  • 35:16 - 35:18
    questions in the room? No.
  • 35:18 - 35:19
    Internet go.
  • 35:21 - 35:23
    Yes. Another one.
  • 35:24 - 35:26
    How do you meter kind of like the
  • 35:26 - 35:27
    underlying stacks? How do you look at
  • 35:28 - 35:29
    branch coverage and so on?Are you doing
  • 35:29 - 35:31
    that already on how are you doing it?Yep,
  • 35:32 - 35:35
    that is a great question. That's coverage
  • 35:35 - 35:38
    guided fuzzing. I'm currently not
  • 35:38 - 35:39
    doing that right. I spoke about that a
  • 35:39 - 35:42
    little bit. We need to move in
  • 35:42 - 35:45
    that direction. It's
  • 35:45 - 35:48
    definitely. I think that's the end goal
  • 35:48 - 35:51
    really. The problem, some of
  • 35:51 - 35:52
    the problems discussed there is, that
  • 35:52 - 35:55
    it's not quite as easy as it's made
  • 35:55 - 35:57
    out to be. You're dealing with a
  • 35:57 - 35:58
    low-level operating system, so it's not
  • 35:58 - 36:00
    as simple as instrumenting a user on a
  • 36:00 - 36:02
    program. You're dealing with queues
  • 36:02 - 36:05
    instead of files or like one file parser.
  • 36:06 - 36:08
    So dealing with queues is a pain in the
  • 36:08 - 36:10
    ass, and then you're dealing with state,
  • 36:10 - 36:12
    right? Which means a lot of things.
  • 36:13 - 36:15
    Don't necessarily encode to one bit or
  • 36:15 - 36:17
    one byte, but it's really a combination
  • 36:17 - 36:19
    of you sent this and then I sent that and
  • 36:19 - 36:22
    then this sent and then so on. And as you
  • 36:22 - 36:25
    separate different things lining up that
  • 36:25 - 36:27
    then causes a state transition, right.
  • 36:28 - 36:30
    And so it's there's at least from where
  • 36:30 - 36:32
    I'm standing right now, there's no easy
  • 36:32 - 36:35
    way to do this. As I said, we need to
  • 36:35 - 36:38
    go there. That's the end goal. How
  • 36:38 - 36:40
    we go there, there are certain gaps that
  • 36:40 - 36:42
    need to be filled. Were you in
  • 36:42 - 36:44
    yesterday's talk about the Qemu fuzzing?
  • 36:45 - 36:48
    Unfortunately, no, I had code to
  • 36:48 - 36:50
    write. I think that's a good, good start.
  • 36:52 - 36:54
    All right, mic #3, please. Hi,
  • 36:54 - 36:57
    great talk. I wanted to ask if it's maybe
  • 36:57 - 37:00
    possible to integrate fuzzing into the
  • 37:00 - 37:03
    Linux kernel itself to fuzz its TCP/IP
  • 37:03 - 37:06
    stack. Yes,
  • 37:06 - 37:09
    you can. So when you get to like
  • 37:09 - 37:12
    a net filter, there are places there
  • 37:12 - 37:15
    that you can use to to
  • 37:15 - 37:18
    to fuzz with. I looked into it. It's one
  • 37:18 - 37:21
    of the things I wanted to do. It was on
  • 37:21 - 37:23
    my ToDo List. Once I get done with, you
  • 37:23 - 37:26
    know where I get with picoTCP and some
  • 37:26 - 37:27
    other things. And again, it's one of
  • 37:27 - 37:28
    these things. It doesn't have to be one
  • 37:28 - 37:29
    or the other, right? You can combine these
  • 37:29 - 37:32
    things. So that is a great
  • 37:32 - 37:33
    approach. I thought about it. I want to
  • 37:33 - 37:36
    do it. I haven't gotten there
  • 37:36 - 37:39
    yet. That's 10 steps away from where I'm
  • 37:39 - 37:41
    now. I hope that answers your question,
  • 37:41 - 37:43
    but I think it's a great question and the
  • 37:43 - 37:46
    answer is yes, we we should do that. All
  • 37:46 - 37:49
    right. Thanks. All right. Do we have
  • 37:49 - 37:51
    any further questions from the Internet?
  • 37:54 - 37:56
    If yes, we have one and I think it's
  • 37:56 - 37:59
    it's very general so.
  • 38:00 - 38:02
    The question here is have you have used
  • 38:02 - 38:04
    considered using Rust for the fuzzer
  • 38:04 - 38:07
    itself like the hyperHTTP
  • 38:07 - 38:10
    library or something like this. Yeah
  • 38:11 - 38:13
    so I did I mentioned Smoltcp so the the
  • 38:13 - 38:14
    given that there's a network stack for it
  • 38:14 - 38:17
    you can use Rust. I haven't
  • 38:17 - 38:20
    I didn't use that I I'm I like Rust. I
  • 38:20 - 38:23
    think it's a great programming language.
  • 38:24 - 38:27
    I think it's. At some point,
  • 38:27 - 38:29
    hopefully it'll replace all or most of
  • 38:29 - 38:31
    our C or C++ code. I have
  • 38:32 - 38:34
    many great things to say about Rust.
  • 38:35 - 38:37
    I am not a great Rust developer. I've
  • 38:37 - 38:39
    written a little bit of Rust code, but I
  • 38:39 - 38:42
    I have a large learning curve and for
  • 38:42 - 38:43
    that reason and only that reason, I
  • 38:43 - 38:46
    didn't go with Rust or Smoltcp. It's
  • 38:46 - 38:49
    just it's my own limitations. I wish I
  • 38:49 - 38:51
    had known more Rust, but you know, life
  • 38:51 - 38:53
    happens and I didn't. I haven't had a
  • 38:53 - 38:55
    good opportunity yet to to write a bunch
  • 38:55 - 38:57
    of Rust code. Someday I hope to get
  • 38:57 - 38:59
    better at writing Rust code, and I would
  • 38:59 - 39:01
    love to do some of this stuff in Rust,
  • 39:01 - 39:02
    but the only reason I didn't
  • 39:03 - 39:06
    touch anything in Rust here was I
  • 39:06 - 39:08
    wasn't confident I would have gotten
  • 39:08 - 39:09
    anything done in time.
  • 39:11 - 39:14
    All right. Then we will
  • 39:14 - 39:16
    simply end the talk perfectly on time.
  • 39:16 - 39:17
    Thank you very much, Ilya.
  • 39:17 - 39:41
    *Applause* *37c3 music* [Translated by Viljami Kittilä (KYBS2004 course assignment at JYU.FI)]
Title:
www.youtube.com/.../watch?v=DobIrGdLEi0
Video Language:
English
Duration:
39:40

English subtitles

Revisions Compare revisions