Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a3d9b950
Commit
a3d9b950
authored
Aug 21, 2020
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix improper access control on deploy key
This commit fixes the vulnerability on the deploy key.
parent
adbf343a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
15 deletions
+131
-15
changelogs/unreleased/security-improper-access-control-on-deploy-key.yml
...leased/security-improper-access-control-on-deploy-key.yml
+5
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+8
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+118
-14
No files found.
changelogs/unreleased/security-improper-access-control-on-deploy-key.yml
0 → 100644
View file @
a3d9b950
---
title
:
Fix Improper Access Control on Deploy-Key
merge_request
:
author
:
type
:
security
lib/gitlab/git_access.rb
View file @
a3d9b950
...
...
@@ -98,6 +98,13 @@ module Gitlab
Guest
.
can?
(
download_ability
,
container
)
end
def
deploy_key_can_download_code?
authentication_abilities
.
include?
(
:download_code
)
&&
deploy_key?
&&
deploy_key
.
has_access_to?
(
container
)
&&
(
project?
&&
project
&
.
repository_access_level
!=
::
Featurable
::
DISABLED
)
end
def
user_can_download_code?
authentication_abilities
.
include?
(
:download_code
)
&&
user_access
.
can_do_action?
(
download_ability
)
...
...
@@ -257,7 +264,7 @@ module Gitlab
end
def
check_download_access!
passed
=
deploy_key?
||
passed
=
deploy_key
_can_download_code
?
||
deploy_token?
||
user_can_download_code?
||
build_can_download_code?
||
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
a3d9b950
...
...
@@ -472,31 +472,135 @@ RSpec.describe Gitlab::GitAccess do
let
(
:actor
)
{
key
}
context
'pull code'
do
context
'when project is authorized'
do
before
do
key
.
projects
<<
project
context
'when project is public'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
*
options
)
}
context
'when deploy key exists in the project'
do
before
do
key
.
projects
<<
project
end
context
'when the repository is public'
do
let
(
:options
)
{
%i[repository_enabled]
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
end
context
'when the repository is private'
do
let
(
:options
)
{
%i[repository_private]
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
end
context
'when the repository is disabled'
do
let
(
:options
)
{
%i[repository_disabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'You are not allowed to download code from this project.'
)
}
end
end
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
context
'when deploy key does not exist in the project'
do
context
'when the repository is public'
do
let
(
:options
)
{
%i[repository_enabled]
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
end
context
'when the repository is private'
do
let
(
:options
)
{
%i[repository_private]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'You are not allowed to download code from this project.'
)
}
end
context
'when the repository is disabled'
do
let
(
:options
)
{
%i[repository_disabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'You are not allowed to download code from this project.'
)
}
end
end
end
context
'when unauthorized'
do
context
'from public project'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
)
}
context
'when project is internal'
do
let
(
:project
)
{
create
(
:project
,
:internal
,
:repository
,
*
options
)
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
context
'when deploy key exists in the project'
do
before
do
key
.
projects
<<
project
end
context
'when the repository is public'
do
let
(
:options
)
{
%i[repository_enabled]
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
end
context
'when the repository is private'
do
let
(
:options
)
{
%i[repository_private]
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
end
context
'when the repository is disabled'
do
let
(
:options
)
{
%i[repository_disabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'You are not allowed to download code from this project.'
)
}
end
end
context
'from internal project'
do
let
(
:project
)
{
create
(
:project
,
:internal
,
:repository
)
}
context
'when deploy key does not exist in the project'
do
context
'when the repository is public'
do
let
(
:options
)
{
%i[repository_enabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_not_found
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'The project you were looking for could not be found.'
)
}
end
context
'when the repository is private'
do
let
(
:options
)
{
%i[repository_private]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'The project you were looking for could not be found.'
)
}
end
context
'when the repository is disabled'
do
let
(
:options
)
{
%i[repository_disabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'The project you were looking for could not be found.'
)
}
end
end
end
context
'from private project
'
do
let
(
:project
)
{
create
(
:project
,
:private
,
:repository
)
}
context
'when project is private
'
do
let
(
:project
)
{
create
(
:project
,
:private
,
:repository
,
*
options
)
}
it
{
expect
{
pull_access_check
}.
to
raise_not_found
}
context
'when deploy key exists in the project'
do
before
do
key
.
projects
<<
project
end
context
'when the repository is private'
do
let
(
:options
)
{
%i[repository_private]
}
it
{
expect
{
pull_access_check
}.
not_to
raise_error
}
end
context
'when the repository is disabled'
do
let
(
:options
)
{
%i[repository_disabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'You are not allowed to download code from this project.'
)
}
end
end
context
'when deploy key does not exist in the project'
do
context
'when the repository is private'
do
let
(
:options
)
{
%i[repository_private]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'The project you were looking for could not be found.'
)
}
end
context
'when the repository is disabled'
do
let
(
:options
)
{
%i[repository_disabled]
}
it
{
expect
{
pull_access_check
}.
to
raise_error
(
'The project you were looking for could not be found.'
)
}
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment