Details of blocking merge request can be exposed via list and get merge request dependencies API endpoints
Background
It was discovered in #364160 (comment 2121282707) that there's a vulnerability in list and get API endpoints of merge request dependencies.
How to reproduce
- Create a private project with a MR (
private-mr). - Create a public project with a MR (
public-mr). - Add
private-mras dependency ofpublic-mr. - View the blocks of
public-mrvia list or get API even as non-signed in user. (e.g.http://gdk.test:3000/api/v4/projects/1/merge_requests/1/blocksorhttp://gdk.test:3000/api/v4/projects/1/merge_requests/1/blocks/1). - You'll be able to see the details of
private-mrasblocking_merge_request.
Expected Behavior
The details of private-mr shouldn't be exposed.
Proposed fix
Don't include any blocks wherein current_user cannot read the blocking_merge_request from the response.
OR
- Still return the
API::Entities::MergeRequestDependencyentity butblocking_merge_requestshould benilifcurrent_usercan't read it. - Add a
hidden_blocking_merge_requestattribute toAPI::Entities::MergeRequestDependencyand it should be true or false depending ifcurrent_usercan read the blocking merge request.