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

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

Merged
merged 1 commit into from May 26, 2016

Conversation

@kazuho
Copy link
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.

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 merged commit 65b8941 into master May 26, 2016
2 checks passed
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
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 changed the title fix use after free on premature connection close fix use after free on premature connection close (CVE-2016-4817) May 26, 2016
@dch
Copy link
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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.