Insufficient Type Check leading to Developer ability to delete Project, Repository, Group, ...
The GraphQL deleteAnnotation mutation did not verify that the supplied global ID referred to an annotation, so a Developer could pass a project's ID and the service would delete the project and its repository. An attacker with Developer access could therefore delete projects they were not authorised to delete.
Originally disclosed on HackerOne
- Triaged in 4 days
- Fixed in 50 days
- Paid in 4 days
- Disclosed after 3 months
Summary
Similar bug to #858671, but this time with annotations mutation: DeleteAnnotation
in app/graphql/mutations/metrics/dashboard/annotations/base.rb
module Mutations
module Metrics
module Dashboard
module Annotations
class Base < BaseMutation
private
# This method is defined here in order to be used by `authorized_find!` in the subclasses.
def find_object(id:)
GitlabSchema.object_from_id(id)
end
end
end
end
end
end
There is no type check for find_object in app/graphql/mutations/metrics/dashboard/annotations/delete.rb
annotation = authorized_find!(id: id)
result = ::Metrics::Dashboard::Annotations::DeleteService.new(context[:current_user], annotation).execute
And luckily, Developer is sufficient for the permission check
app/services/metrics/dashboard/annotations/delete_service.rb
Ability.allowed?(user, :delete_metrics_dashboard_annotation, annotation)
Steps to reproduce
- For User A, Create project A Private adding User B as Developer
- For User B, execute the following mutation in
http://gitlab.example.vm/-/graphql-explorer
mutation {
deleteAnnotation(input: {id: "gid://Gitlab/Project/<project-id>"}) {
clientMutationId
}
}
- Project disappear along with Repository
███████
Results of GitLab environment info
System information
System:
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.6.6p146
Gem Version: 2.7.10
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 5.0.9
Git Version: 2.27.0
Sidekiq Version:5.2.9
Go Version: unknown
GitLab information
Version: 13.2.3-ee
Revision: 640e2695514
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 11.7
URL: http://gitlab.example.vm
HTTP Clone URL: http://gitlab.example.vm/some-group/some-project.git
SSH Clone URL: [email protected]:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 13.3.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
Impact
Unauthorized deleting of repository/project by maintainers, developers
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
The mutation resolved the supplied global ID without checking its type, so an object of any type could be passed to a service that assumed it was an annotation.
Impact
A Developer could delete a project and its repository without authorisation.
What the attacker needed
Developer role on the target project
How it was found
- Create a private project as User A and add User B as a Developer.
- As User B, open the GraphQL explorer and run the deleteAnnotation mutation with the project's global ID as the id argument.
- The project and its repository are deleted.
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 GraphQL mutation is an action a user can ask the server to perform. The server looked up whatever object the user named by its ID but never checked it was actually an annotation, then ran a delete action on it. Because the permission check only asked whether the user could delete annotations, a low-privileged Developer could delete a whole project.
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.