fix use after free on premature connection close (CVE-2016-4817) #920

Merged
merged 1 commit into from May 26, 2016

Conversation

Projects
None yet
3 participants
@kazuho
Member

kazuho commented May 26, 2016

A use-after-free vulnerability has been reported by Tim Newsham and fixed by Frederik Deweerdt.

CVE-ID for this issue is CVE-2016-4817. The issue has been fixed in version 1.7.3 and version 2.0.0-beta5. Users are encouraged to update to the latest versions.

The issue is that when H2O tries to disconnect a premature HTTP/2 connection, it calls free(3) to release memory allocated for the connection and immediately after then touches the memory. No malloc-related operation is performed by the same thread between the time it calls free and the time the memory is touched.

Therefore, it is estimated that the exploitability of the issue depends on if an attacker can overwrite the memory chunk at the appropriate moment from another thread (note: the number of threads used to accept incoming connections are governed by num-threads configuration directive).

In case the issue is exploitable, then it would mean that a remote attacker can mount a DoS attack against H2O, or at worst result in remote code execution.

We would like to thank the aforementioned people for finding and fixing the issue.

h2: use after free on premature connection close
lib/http2/connection.c:on_read() calls parse_input(), which might free
`conn`. It does so in particular if the connection preface isn't
the expected one in expect_preface(). `conn` is then used after the free
in `if (h2o_timeout_is_linked(&conn->_write.timeout_entry)`.
We fix this by adding a return value to close_connection that returns a
negative value if `conn` has been free'd and can't be used anymore.

Credits for finding the bug to Tim Newsham.

@kazuho kazuho added bug http2 labels May 26, 2016

@kazuho kazuho merged commit 65b8941 into master May 26, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

kazuho added a commit that referenced this pull request May 26, 2016

h2: use after free on premature connection close #920
lib/http2/connection.c:on_read() calls parse_input(), which might free
`conn`. It does so in particular if the connection preface isn't
the expected one in expect_preface(). `conn` is then used after the free
in `if (h2o_timeout_is_linked(&conn->_write.timeout_entry)`.
We fix this by adding a return value to close_connection that returns a
negative value if `conn` has been free'd and can't be used anymore.

Credits for finding the bug to Tim Newsham.

@kazuho kazuho added vulnerability and removed bug labels May 26, 2016

@kazuho kazuho changed the title from fix use after free on premature connection close to fix use after free on premature connection close (CVE-2016-4817) May 26, 2016

@dch

This comment has been minimized.

Show comment
Hide comment
@dch

dch Jun 1, 2016

Collaborator

waiting on https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209926 to commit this to ports.

Collaborator

dch commented Jun 1, 2016

waiting on https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209926 to commit this to ports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment