- Notifications
You must be signed in to change notification settings - Fork2.5k
Arbitrary code execution due to heap corruption in `git_index_add`
Package
Affected versions
Patched versions
Description
Impact
Using well-crafted inputs togit_index_add
can cause heap corruption that could be leveraged for arbitrary code execution.
Detailed description
There is an issue in thehas_dir_name
function insrc/libgit2/index.c
, which frees an entry that should not be freed. The freed entry is later used and overwritten with potentially bad actor-controlled data leading to controlled heap corruption. Depending on the application that uses libgit2, this could lead to arbitrary code execution.
To trigger the problem, the bad actor must be able to trigger two consecutive calls togit_index_add
with a filename that starts with a/
character. To control the heap corruption, the bad actor must be able to control thectime
field of the git_index_entry data structure.
Patches
Users should upgrade to v1.6.5 or v1.7.2.
Workarounds
Prevent paths beginning with/
from being provided togit_index_add
.