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

signature: fix out-of-bounds read when parsing timezone offset #4883

Merged
merged 1 commit into from
Nov 13, 2018

Conversation

pks-t
Copy link
Member

@pks-t pks-t commented Nov 9, 2018

When parsing a signature's timezone offset, we first check whether there
is a timezone at all by verifying that there are still bytes left to
read following the time itself. The check thus looks like time_end + 1 < buffer_end, which is actually correct in this case. After setting the
timezone's start pointer to that location, we compute the remaining
bytes by using the formula buffer_end - tz_start + 1, re-using the
previous time_end + 1. But this is in fact missing the braces around
(tz_start + 1), thus leading to an overestimation of the remaining
bytes by a length of two. In case of a non-NUL terminated buffer, this
will result in an overflow.

The function git_signature__parse is only used in two locations. First
is git_signature_from_buffer, which only accepts a string without a
length. The string thus necessarily has to be NUL terminated and cannot
trigger the issue.

The other function is git_commit__parse_raw, which can in fact trigger
the error as it may receive non-NUL terminated commit data. But as
objects read from the ODB are always NUL-terminated by us as a
cautionary measure, it cannot trigger the issue either.

In other words, this error does not have any impact on security.

When parsing a signature's timezone offset, we first check whether there
is a timezone at all by verifying that there are still bytes left to
read following the time itself. The check thus looks like `time_end + 1
< buffer_end`, which is actually correct in this case. After setting the
timezone's start pointer to that location, we compute the remaining
bytes by using the formula `buffer_end - tz_start + 1`, re-using the
previous `time_end + 1`. But this is in fact missing the braces around
`(tz_start + 1)`, thus leading to an overestimation of the remaining
bytes by a length of two. In case of a non-NUL terminated buffer, this
will result in an overflow.

The function `git_signature__parse` is only used in two locations. First
is `git_signature_from_buffer`, which only accepts a string without a
length. The string thus necessarily has to be NUL terminated and cannot
trigger the issue.

The other function is `git_commit__parse_raw`, which can in fact trigger
the error as it may receive non-NUL terminated commit data. But as
objects read from the ODB are always NUL-terminated by us as a
cautionary measure, it cannot trigger the issue either.

In other words, this error does not have any impact on security.
@pks-t
Copy link
Member Author

pks-t commented Nov 13, 2018

/rebuild

@libgit2-azure-pipelines
Copy link

Okay, @pks-t, I started to rebuild this pull request.

@pks-t
Copy link
Member Author

pks-t commented Nov 13, 2018

/rebuild

@libgit2-azure-pipelines
Copy link

Okay, @pks-t, I started to rebuild this pull request.

@pks-t
Copy link
Member Author

pks-t commented Nov 13, 2018

online::badssl is hitting again :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant