Merge request CI metrics still returned for users without CI access
A JSON endpoint for merge request CI metrics did not enforce CI access permissions, so anonymous users could view metrics from a public project even when public pipelines were disabled. This exposed CI job output to users without proper access.
GitLab
Originally disclosed on GitLab
- Fixed in 5 months
- Disclosed after 5 months
HackerOne report #705960 by xanbanx on 2019-10-01, assigned to @ankelly:
Hi GitLab security team,
Summary
It seems the report #546860 did not yet fixed properly. While the related request https://example.gitlab.com/<namespace>/<public-project-name>/merge_requests/1/test_reports.json , the metrics are still accessible via https://example.gitlab.com/<namespace>/<public-project-name>/merge_requests/1/metrics_reports.json
For public projects, GitLab allows to restrict CI pipelines to project members only (public pipelines disabled). However, in this case, the merge request widget still renders the CI metrics result, which is the outcome of a CI pipeline. These metrics are output of the CI job and should only be displayed if the visiting user has access to CI. However, right now GitLab displays the metric changes regardless of the CI permission.
Steps to reproduce
Tested on GitLab Enterprise Edition 12.3.0-pre a91e743e4cc
- Create a public project and push a
.gitlab-ci.ymlwith following content:
metrics:
script:
- echo 'my_metric first_value' > metrics.txt
artifacts:
reports:
metrics: metrics.txt
-
Create a merge request (assuming with iid 1) by modifying the
.gitlab-ci.ymlfile, especially by hanging the metrics line, e.g., to- echo ''my_metric new_value' > metrics.txt -
Restrict the visibility of CI pipelines to project members only and disable public pipelines
-
As an anonymous user, visit the page
https://example.gitlab.com/<namespace>/<public-project-name>/1
You see the metrics widget rendered although the user does not have access to CI. Behind the scenes, the JSON endpoint https://example.gitlab.com/<namespace>/<public-project-name>/merge_requests/1/metrics_reports.json loads this data and reveals the metrics information to unauthorized users.
Impact
Users without proper access level have access to metrics information.
Examples
Goto https://gitlab.com/test-public-wroup-wter-test/test-metrics/merge_requests/1/metrics_reports.json to see the metrics leaked.
What is the current bug behavior?
Users without access to CI have access to metrics, which are tied to a merge request and are an output of CI.
What is the expected correct behavior?
Users without proper access level should not have access to metrics.
Output of checks
This bug happens on GitLab.com
Best regards,
Xanbanx
Impact
See above.
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
Likely the metrics_reports.json endpoint lacked the same CI permission check that was added to the test_reports.json endpoint.
What the attacker needed
Public project; CI pipelines restricted to members; no authentication needed
How it was found
- Create a public project with a CI job that writes a metrics file.
- Open a merge request that changes the metrics value.
- Restrict CI visibility to project members and disable public pipelines.
- As an anonymous user, visit the merge request page and see the metrics widget.
- The metrics_reports.json endpoint returns the metrics data.
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 public project on GitLab can hide its CI pipelines from non-members. However, a separate web address that returns merge request metrics still worked for anyone, so outsiders could see the results of those hidden pipelines.
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.