cgit cgit_clone_objects() Directory Traversal

cgit suffers from a directory traversal vulnerability in cgit_clone_objects().

MD5 | f306e9c0fb056a4bc0fe47e73bb69b90

cgit: directory traversal in cgit_clone_objects() 


There is a directory traversal vulnerability in cgit_clone_objects(), reachable when the configuration flag enable-http-clone is set to 1 (default):

void cgit_clone_objects(void)
if (!ctx.qry.path) {
cgit_print_error_page(400, "Bad request", "Bad request");

if (!strcmp(ctx.qry.path, "info/packs")) {

send_file(git_path("objects/%s", ctx.qry.path));

send_file() is a function that simply sends the data stored at the given filesystem path out over the network.
git_path() partially rewrites the provided path and e.g. prepends the base path of the repository, but it does not sanitize the provided path to prevent directory traversal.

ctx.qry.path can come from querystring_cb(), which takes unescaped data from the querystring. To trigger this case:

$ curl

This bug is subject to a 90 day disclosure deadline. After 90 days elapse
or a patch has been made broadly available (whichever is earlier), the bug
report will become visible to the public.

Found by: jannh

Related Posts