State filter in IssuableFinder allows attacker to delete all issues and merge requests
The state filter in GitLab's IssuableFinder passed unsanitised user input to public_send, allowing an attacker to call delete_all or destroy_all on the underlying model. This could delete all issues and merge requests on the instance, and for public projects an unauthenticated user could exploit it.
- Triaged in 5 hours
- Fixed in 7 days
- Disclosed after 7 days
Summary by the researcher
Multiple versions of GitLab expose a dangerous method to any authenticated user that could lead to the deletion of all Issue and MergeRequest objects on a GitLab instance. For GitLab instances with publicly available projects this vulnerability could be exploited by an unauthenticated user. A fix was included in versions 8.14.3, 8.13.8, and 8.12.11, which were released on December 5th 2016 at 3:59 PST. The GitLab versions vulnerable to this are 8.13.0, 8.13.0-ee, 8.13.1, 8.13.1-ee, 8.13.2, 8.13.2-ee, 8.13.3, 8.13.3-ee, 8.13.4, 8.13.4-ee, 8.13.5, 8.13.5-ee, 8.13.6, 8.13.6-ee, 8.13.7, 8.14.0, 8.14.0-ee, 8.14.1, 8.14.2, and 8.14.2-ee.
More information can be found at https://about.gitlab.com/2016/12/05/cve-2016-9469/.
The report
Vulnerability details
The state filter in the IssuableFinder class has the ability to filter issues and merge requests by state. This filter is implemented by calling public_send with unfiltered user input. This allows an attacker to call delete_all or destroy_all. Because the method is called before the project / group scope is applied, it deletes all issues and merge requests of the GitLab instance.
Proof of concept
Create two users and a new project for each of them. It doesn't matter if they're private or not. Now create an issue (or merge request) for each project. Now browse to the Issues overview. When clicking All, you'll be redirected to http://gitlab-instance/root/xxxx/issues?scope=all&state=all. Simply substitude all with delete_all in the URL and ALL issues will be deleted: http://gitlab-instance/root/xxxx/issues?scope=all&state=delete_all. To delete all merge requests, substitude issues with merge_requests. When requesting the delete_all URL, a 500 internal server error will be shown. This is caused by the delete_all method returning a boolean instead of an ActiveRecord::Relation class. Do NOT call this on the GitLab production site.
Origin
The vulnerability comes from the fact that unsanitized user input is passed into a public_send call that is being called on model.all. Here's the execute method of the IssuableFinder:
def execute
items = init_collection
items = by_scope(items)
items = by_state(items)
items = by_group(items)
items = by_project(items)
items = by_search(items)
items = by_milestone(items)
items = by_assignee(items)
items = by_author(items)
items = by_label(items)
items = by_due_date(items)
sort(items)
end
Now take a look at the by_state method:
def by_state(items)
params[:state] ||= 'all'
if items.respond_to?(params[:state])
items.public_send(params[:state])
else
items
end
end
The controllers are passing the state parameter without any form of sanitization or validation to the finder. Since you're passing around ActiveRecord relations, delete_all can be called early on in the relation chain. Since the scope hasn't been applied (the by_project is called later), this will affect all issues and merge requests.
Remediation
Never pass unsanitized or unvalidated user input to public_send or send.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Unsanitised user input was passed to public_send on an ActiveRecord relation before project or group scoping was applied.
Impact
An authenticated user could delete all issues and merge requests on the instance, and for instances with public projects an unauthenticated user could do the same; the request returns a 500 error after deletion.
What the attacker needed
Authenticated user, or unauthenticated if public projects…
The fix
A fix was included in versions 8.14.3, 8.13.8 and 8.12.11; the text advises never passing unsanitised input to public_send or send.
How it was found
- Create two users and a new project for each.
- Create an issue or merge request for each project.
- Browse to the Issues overview and click All to get a URL with state=all.
- Replace all with delete_all in the state parameter and request the URL.
- To delete merge requests, change issues to merge_requests in the URL.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A web application lets users filter lists by a 'state' value, such as open or closed. The code took that value and used it to call a method on a database query without checking it. An attacker could supply a destructive method name instead, causing the application to delete every issue and merge request in the system.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.