Impact
Using well-crafted inputs to git_index_add can cause heap corruption that could be leveraged for arbitrary code execution.
Detailed description
There is an issue in the has_dir_name function in src/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 to git_index_add with a filename that starts with a / character. To control the heap corruption, the bad actor must be able to control the ctime 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 to git_index_add.
Impact
Using well-crafted inputs to
git_index_addcan cause heap corruption that could be leveraged for arbitrary code execution.Detailed description
There is an issue in the
has_dir_namefunction 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 to
git_index_addwith a filename that starts with a/character. To control the heap corruption, the bad actor must be able to control thectimefield 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.