diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-04-19 11:36:57 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-04-19 11:36:57 +0000 |
commit | 1532d202f1ca4cd947dac1511328bbe315e3bde9 (patch) | |
tree | f9eed35c2243e3b8b732c5a4bc13c7dcf830c6b0 /app/controllers | |
parent | 51b777fa9c0530cd2735f207e0d96d210c08fdca (diff) | |
parent | b9e13c2481a4cc8c25a94a095c795ce9a1d61f4d (diff) | |
download | gitlab-ce-1532d202f1ca4cd947dac1511328bbe315e3bde9.tar.gz |
Merge branch 'fix/link-group-permissions' into 'master'
Check permissions when sharing project with group
## Summary
Unprivileged user was able to share project with group he didn't have access to, and therefore gain partial access to that group, which opened possibilities for further actions like listing private projects in that group.
See https://gitlab.com/gitlab-org/gitlab-ce/issues/15330
## Fix
This change introduces additional check for group read access.
## Further work
We can think about preventing such problems in the future (this is quite common problem) by moving permissions checks to another layer of abstraction (TBD).
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/15330
See merge request !1949
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/group_links_controller.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/projects/group_links_controller.rb b/app/controllers/projects/group_links_controller.rb index 4159e53bfa9..606552fa853 100644 --- a/app/controllers/projects/group_links_controller.rb +++ b/app/controllers/projects/group_links_controller.rb @@ -7,10 +7,12 @@ class Projects::GroupLinksController < Projects::ApplicationController end def create - link = project.project_group_links.new - link.group_id = params[:link_group_id] - link.group_access = params[:link_group_access] - link.save + group = Group.find(params[:link_group_id]) + return render_404 unless can?(current_user, :read_group, group) + + project.project_group_links.create( + group: group, group_access: params[:link_group_access] + ) redirect_to namespace_project_group_links_path(project.namespace, project) end |