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

Add h2o cve #2

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7336e67
Add basic h2o mayhem target
sciencemanx Jun 1, 2020
d1ab6b2
Add remaining fuzz targets to h2o
sciencemanx Jun 2, 2020
c4e07c0
Add base image name and fix standalone cmd path
sciencemanx Jun 2, 2020
439d55d
Remove alternate fuzzers (just keep h2o binary)
sciencemanx Jun 3, 2020
1a8c4f2
Add starting corpus and crashing poc
sciencemanx Jun 3, 2020
0bf53fd
Simplify dockerfile
sciencemanx Jun 3, 2020
90c3578
Add readme for h2o
sciencemanx Jun 3, 2020
54eea77
Use multistage build for docker image
sciencemanx Jun 3, 2020
8675655
Change mayhemfile baseimage to use forallsecure dockerhub
sciencemanx Jun 3, 2020
cd708a5
Move push logic from docker_publish to external script in .github
sciencemanx Jun 3, 2020
9228e5e
Add h2o cve to docker_publish.yml
sciencemanx Jun 3, 2020
eb47ebe
Add shebang and set ex to push.sh
sciencemanx Jun 3, 2020
d9f1113
Remove now-unused modified CMakeLists.txt
sciencemanx Jun 3, 2020
5db463b
Fix indentation in docker_publish
sciencemanx Jun 3, 2020
b18d3ee
Remove unnecessary env specification in mayhemfile
sciencemanx Jun 3, 2020
4519c28
Update ubuntu base image to specify version tag
sciencemanx Jun 3, 2020
86d82b5
Improve readme intro with more detail (thanks david)
sciencemanx Jun 3, 2020
be1fadc
Add credit to Marlies Ruck to readme
sciencemanx Jun 3, 2020
597a7d3
Update note markdown to match formatting
sciencemanx Jun 3, 2020
1adb6e3
Remove envtest string from project name in mayhemfile
sciencemanx Jun 5, 2020
65d4fd9
Merge branch 'master' into add-h2o-cve
sciencemanx Jun 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Published on Dockerhub
name: Publish on Dockerhub

on:
push:
Expand All @@ -7,10 +7,8 @@ on:
branches: [ master ]

jobs:

openssl-cve-2014-0160:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build the Docker image
Expand All @@ -35,3 +33,16 @@ jobs:

- name: Push the docker image
run: ./.github/push.sh forallsecure/cereal-cve-2020-11104-11105 "${{ github.ref }}"

h2o-cve-2018-0608:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: ./mayhemit.sh --build h2o-cve-2018-0608

- name: Log into the registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

- name: Push the docker image
run: ./.github/push.sh forallsecure/h2o-cve-2018-0608 "${{ github.ref }}"
23 changes: 23 additions & 0 deletions h2o-cve-2018-0608/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:20.10 AS base

RUN apt-get update && \
apt-get install -y libssl-dev zlib1g-dev

FROM base AS builder

RUN export DEBIAN_FRONTEND="noninteractive" && \
apt-get update && \
apt-get install -y cmake build-essential git

WORKDIR /h2o
RUN git clone https://github.com/h2o/h2o . && \
git checkout 69506c9e2defa4922f62f389c76d89e9274b3cc1 && \
sciencemanx marked this conversation as resolved.
Show resolved Hide resolved
git checkout HEAD^

RUN mkdir build && cd build && cmake .. && make

FROM base

WORKDIR /fuzz
COPY --from=builder /h2o/build/h2o .
COPY h2o.conf .
47 changes: 47 additions & 0 deletions h2o-cve-2018-0608/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# h2o memory corruption CVE example

This repo replicates finding [CVE-2018-0608](https://nvd.nist.gov/vuln/detail/CVE-2018-0608), a memory corruption bug that may allow a remote attacker to run arbitrary code ([CVSS Score](https://nvd.nist.gov/vuln-metrics/cvss): 9.8).

We reported this bug responsibly to the maintainers, with the follow-on issue tracking [here](https://github.com/h2o/h2o/issues/1775).

> Note: since this finds the bug in an unmodified h2o binary
> (a *network target*), it can only be found by fuzzers that support network
> fuzzing (such as Mayhem).
sciencemanx marked this conversation as resolved.
Show resolved Hide resolved

## To build

Assuming you just want to build the docker image, run from the project
directory (`h2o-cve-2018-0608`):

```bash
docker build -t forallsecure/h2o-cve-2018-0608 .
```

## Get from Dockerhub

If you don't want to build locally, you can pull a pre-built image
directly from dockerhub:

```bash
docker pull forallsecure/h2o-cve-2018-0608
```


## Run under Mayhem

From the project directory (`h2o-cve-2018-0608`) run:

```bash
mayhem run mayhem/h2o
```

## POC

We have included a proof of concept output under the `poc`
directory.

> Note: Fuzzing has some degree of non-determinism, so when you run
yourself you may not get exactly this file. This is expected; your
output should still trigger the memory corruption bug.
sciencemanx marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add how long it takes us to find. Such as:
On our test cluster, given the original seed, it takes about xxx minutes to reproduce the bug.


This bug was originally found and [responsibly disclosed](https://github.com/h2o/h2o/issues/1775) by ForAllSecure employee [Marlies Ruck](https://blog.forallsecure.com/author/marlies-ruck). As such, this bug has since been [fixed](https://github.com/h2o/h2o/commit/69506c9e2defa4922f62f389c76d89e9274b3cc1) by project maintainers.
30 changes: 30 additions & 0 deletions h2o-cve-2018-0608/h2o.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# to find out the configuration commands, run: h2o --help

listen: 8080
num-threads: 4
#listen:
# port: 8081
# ssl:
# certificate-file: examples/h2o/server.crt
# key-file: examples/h2o/server.key
# minimum-version: TLSv1.2
# cipher-preference: server
# cipher-suite: "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256"
# # Oldest compatible clients: Firefox 27, Chrome 30, IE 11 on Windows 7, Edge, Opera 17, Safari 9, Android 5.0, and Java 8
# # see: https://wiki.mozilla.org/Security/Server_Side_TLS
hosts:
"127.0.0.1.xip.io:8080":
paths:
/:
file.dir: examples/doc_root
access-log: /dev/stdout
# "alternate.127.0.0.1.xip.io:8081":
# listen:
# port: 8081
# ssl:
# certificate-file: examples/h2o/alternate.crt
# key-file: examples/h2o/alternate.key
# paths:
# /:
# file.dir: examples/doc_root.alternate
# access-log: /dev/stdout
11 changes: 11 additions & 0 deletions h2o-cve-2018-0608/mayhem/h2o/Mayhemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '1.4'
project: h2o-cve-2018-0608
target: h2o
baseimage: forallsecure/h2o-cve-2018-0608
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify a duration (upper bound on what it would take to find, say on demo).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok haven't found the bug from scratch yet (ran target shortly and verified crash repro) but will update when it is found

cmds:
- cmd: /fuzz/h2o -c /fuzz/h2o.conf
network:
is_client: false
timeout: 2.0
url: tcp://localhost:8080
timeout: 15
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: localhost:8080
Accept: */*

11 changes: 11 additions & 0 deletions h2o-cve-2018-0608/mayhem/h2o/poc/crashing-input

Large diffs are not rendered by default.