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
49d90ade
Commit
49d90ade
authored
Apr 01, 2020
by
Stan Hu
Committed by
David Fernandez
Apr 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix filename bypass when uploading NuGet packages
Validate the incoming workhorse file.
parent
3b1fbe09
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
5 deletions
+26
-5
ee/changelogs/unreleased/security-fix-issue-213040.yml
ee/changelogs/unreleased/security-fix-issue-213040.yml
+5
-0
ee/lib/api/nuget_packages.rb
ee/lib/api/nuget_packages.rb
+2
-2
ee/spec/requests/api/nuget_packages_spec.rb
ee/spec/requests/api/nuget_packages_spec.rb
+5
-2
ee/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb
...d_examples/requests/api/nuget_packages_shared_examples.rb
+14
-1
No files found.
ee/changelogs/unreleased/security-fix-issue-213040.yml
0 → 100644
View file @
49d90ade
---
title
:
Fix filename bypass when uploading NuGet packages
merge_request
:
author
:
type
:
security
ee/lib/api/nuget_packages.rb
View file @
49d90ade
...
@@ -78,13 +78,13 @@ module API
...
@@ -78,13 +78,13 @@ module API
detail
'This feature was introduced in GitLab 12.6'
detail
'This feature was introduced in GitLab 12.6'
end
end
params
do
params
do
use
:workhorse_upload_params
requires
:package
,
type:
::
API
::
Validations
::
Types
::
WorkhorseFile
,
desc:
'The package file to be published (generated by Multipart middleware)'
end
end
put
do
put
do
authorize_upload!
(
authorized_user_project
)
authorize_upload!
(
authorized_user_project
)
file_params
=
params
.
merge
(
file_params
=
params
.
merge
(
file:
uploaded_package_file
(
:package
)
,
file:
params
[
:package
]
,
file_name:
PACKAGE_FILENAME
file_name:
PACKAGE_FILENAME
)
)
...
...
ee/spec/requests/api/nuget_packages_spec.rb
View file @
49d90ade
...
@@ -130,14 +130,17 @@ describe API::NugetPackages do
...
@@ -130,14 +130,17 @@ describe API::NugetPackages do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/packages/nuget"
}
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/packages/nuget"
}
let
(
:headers
)
{
{}
}
let
(
:headers
)
{
{}
}
let
(
:params
)
{
{
package:
temp_file
(
file_name
)
}
}
let
(
:params
)
{
{
package:
temp_file
(
file_name
)
}
}
let
(
:file_key
)
{
:package
}
let
(
:send_rewritten_field
)
{
true
}
subject
do
subject
do
workhorse_finalize
(
workhorse_finalize
(
api
(
url
),
api
(
url
),
method: :put
,
method: :put
,
file_key:
:package
,
file_key:
file_key
,
params:
params
,
params:
params
,
headers:
headers
headers:
headers
,
send_rewritten_field:
send_rewritten_field
)
)
end
end
...
...
ee/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb
View file @
49d90ade
...
@@ -171,7 +171,7 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
...
@@ -171,7 +171,7 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
end
end
context
'without a file from workhorse'
do
context
'without a file from workhorse'
do
let
(
:
params
)
{
{
package:
nil
}
}
let
(
:
send_rewritten_field
)
{
false
}
it_behaves_like
'returning response status'
,
:bad_request
it_behaves_like
'returning response status'
,
:bad_request
end
end
...
@@ -212,6 +212,19 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
...
@@ -212,6 +212,19 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
it_behaves_like
'returning response status'
,
:forbidden
it_behaves_like
'returning response status'
,
:forbidden
end
end
end
end
context
'with crafted package.path param'
do
let
(
:crafted_file
)
{
Tempfile
.
new
(
'nuget.crafted.package.path'
)
}
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/packages/nuget?package.path=
#{
crafted_file
.
path
}
"
}
let
(
:params
)
{
{
file:
temp_file
(
file_name
)
}
}
let
(
:file_key
)
{
:file
}
it
'does not create a package file'
do
expect
{
subject
}.
to
change
{
::
Packages
::
PackageFile
.
count
}.
by
(
0
)
end
it_behaves_like
'returning response status'
,
:bad_request
end
end
end
context
'and direct upload disabled'
do
context
'and direct upload disabled'
do
...
...
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