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

[SECURITY] Several command injections #246

Open
maple3142 opened this issue May 26, 2023 · 1 comment
Open

[SECURITY] Several command injections #246

maple3142 opened this issue May 26, 2023 · 1 comment

Comments

@maple3142
Copy link

There are several command injection vulnerabilities in Gitly:

gitly/src/repo_routes.v

Lines 530 to 543 in d0e1f3a

['/:user/:repository/raw/:branch_name/:path...']
pub fn (mut app App) handle_raw(username string, repo_name string, branch_name string, path string) vweb.Result {
user := app.get_user_by_username(username) or { return app.not_found() }
repo := app.find_repo_by_name_and_user_id(repo_name, user.id)
if repo.id == 0 {
return app.not_found()
}
// TODO: throw error when git returns non-zero status
file_source := repo.git('--no-pager show ${branch_name}:${path}')
return app.ok(file_source)
}

is_patch_request := hash.ends_with('.patch')
if is_patch_request {
commit_hash := hash.trim_string_right('.patch')
patch := repo.get_commit_patch(commit_hash) or { return app.not_found() }
return app.ok(patch)
}

patch := r.git('format-patch --stdout -1 ${commit_hash}')

I think there are more possible injection points so it is probably not enough to fix these parts only.

If possible, consider Adding a security policy to your repository in the future.

@ghost
Copy link

ghost commented May 26, 2023

Yes, you are right. Thank you for your feedback. I haven't done any checks in any place of calling the git command yet.

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

No branches or pull requests

1 participant