Skip to content
Access control Disclosed report Intermediate

Maintainer can change the visibility of Project and Group

A maintainer of a private project or group could change its visibility to public or internal by supplying a crafted visibility value that bypassed the permission check. This allowed a maintainer to expose private projects and groups without the required owner permission.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 months

HackerOne report #1536559 by suruli on 2022-04-10, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Hi, According to gitlab docs, api and web_ui, a maintainer of a project is restricted from changing its visibility. The check for user permission is done after making sure the new_visibility is different from current_visibilty level of the project.

###  gitlab-development-kit/gitlab/app/services/concerns/update_visibility_level.rb

def valid_visibility_level_change?(target, new_visibility)  
    return true unless new_visibility

    new_visibility_level = Gitlab::VisibilityLevel.level_value(new_visibility)  
      
    if new_visibility_level != target.visibility_level_value   #target.visibility_level_value is 0 for private projects and groups  
      unless can?(current_user, :change_visibility_level, target) &&  
          Gitlab::VisibilityLevel.allowed_for?(current_user, new_visibility_level)

        deny_visibility_level(target, new_visibility_level)  
        return false  
      end  
    end

    true  
 end  
###  gitlab-development-kit/gitlab/lib/gitlab/visibility_level.rb

PRIVATE  = 0 unless const_defined?(:PRIVATE)  
INTERNAL = 10 unless const_defined?(:INTERNAL)  
PUBLIC   = 20 unless const_defined?(:PUBLIC)

 def string_options  
        {  
          'private'  => PRIVATE,  
          'internal' => INTERNAL,  
          'public'   => PUBLIC  
        }  
end

def level_value(level)  
        return level.to_i if level.to_i.to_s == level.to_s && string_options.key(level.to_i)

        string_options[level] || PRIVATE  
 end  

The level_value method returns 0 (the value of PRIVATE) for any input except 10, 20, 'internal', 'public'. For a private project or group, passing the new_visibility as 20r to the method level_value will return 0 that bypasses the check for user permission and then '20r'.to_i is 20 (PUBLIC) will be assigned as project visibility.

Requirements:
  1. Two gitlab accounts (Eg, victim_account and attacker_account).
  2. Burp or similar.

Steps to reproduce

Victim:
  1. Login to victim_account and goto New project>Create blank project
  2. Give any Project name. Make sure Project URL has victim's username and click Create project
new_project_form.png
new_project_form.png From the original on GitLab
  1. Visit the created project and goto Project Information>Members from the side menu. Click invite members.
  2. Enter the attacker_account's username or email address. Select the role Maintainer and click Invite.
invite_attacker.png
invite_attacker.png From the original on GitLab
Attacker:
  1. Visit the victim's project from attacker_account.
  2. Goto Settings>General from side menu.
  3. Expand Visibility, project features, permissions section.
  4. Turn the Burp intercept on and click Save changes at the bottom of that section.
save_changes.png
save_changes.png From the original on GitLab

Example Request

POST /victim-namespace/victim-project-slug HTTP/2  
.
.  
.
.  
.
-----------------------------31179005449602053611562110226  
Content-Disposition: form-data; name="_method"

patch  
-----------------------------31179005449602053611562110226  
Content-Disposition: form-data; name="update_section"

js-shared-permissions  
-----------------------------31179005449602053611562110226  
Content-Disposition: form-data; name="project[request_access_enabled]"

true  
-----------------------------31179005449602053611562110226  
Content-Disposition: form-data; name="project[project_feature_attributes][issues_access_level]"

20  
-----------------------------31179005449602053611562110226  
.
.  
.
-----------------------------31179005449602053611562110226--  
  1. Add the following value to the request along with the form boundary and Send the request.
Content-Disposition: form-data; name="project[visibility_level]"

20r  

Other visibility levels can also be set by replacing the value 20r with following values.

current visibility > input > resulting visibility

private>20r>public
private>10r>internal
public > public > private
internal > internal > private

  1. Refresh the page to see the change of Project visibility .

The same steps can be repeated for Groups as well.

What is the current bug behavior?

user permission is checked after the check for inequality of new and current visibility level.

What is the expected correct behavior?

user permission should be checked before the check for inequality.

Installed fresh gitlab instance from https://about.gitlab.com/install/#ubuntu on the date of the report.

Impact

A Maintainer can change:
Visibility of Projects and Groups in Self-managed Gitlab instance.
Visibility of Projects in gitlab.com.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

How To Reproduce

Please add reproducibility information to this section:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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 permission check was performed after comparing the new visibility level to the current one, and the comparison could be bypassed by a value that was interpreted as the current level but later converted to a different level.

What the attacker needed

Attacker has a GitLab account; victim invites attacker as Maintainer; attacker can intercept HTTP requests

The fix

The permission check should be performed before comparing the new and current visibility levels.

How it was found

  1. Log in as the victim and create a new blank project.
  2. Invite the attacker account as a Maintainer.
  3. As the attacker, go to the project's Settings > General and expand the visibility section.
  4. Intercept the save request with a proxy.
  5. Add a form field for project[visibility_level] with a crafted value and send the request.
  6. Refresh the page to see the changed project visibility.

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.

In GitLab, a maintainer is a user role that can manage a project but should not be able to change who can see it. The code that checks if you are allowed to change visibility had a flaw: it compared the new visibility value to the current one before checking your permission, and a specially crafted value made the comparison think nothing was changing. So the permission check was skipped, and the project became public.

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.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.