gitlab-org--gitlab-foss/spec/requests
Nick Thomas 5b075413d9
Verify that LFS upload requests are genuine
LFS uploads are handled in concert by workhorse and rails. In normal
use, workhorse:

* Authorizes the request with rails (upload_authorize)
* Handles the upload of the file to a tempfile - disk or object storage
* Validates the file size and contents
* Hands off to rails to complete the upload (upload_finalize)

In `upload_finalize`, the LFS object is linked to the project. As LFS
objects are deduplicated across all projects, it may already exist. If
not, the temporary file is copied to the correct place, and will be
used by all future LFS objects with the same OID.

Workhorse uses the Content-Type of the request to decide to follow this
routine, as the URLs are ambiguous. If the Content-Type is anything but
"application/octet-stream", the request is proxied directly to rails,
on the assumption that this is a normal file edit request. If it's an
actual LFS request with a different content-type, however, it is routed
to the Rails `upload_finalize` action, which treats it as an LFS upload
just as it would a workhorse-modified request.

The outcome is that users can upload LFS objects that don't match the
declared size or OID. They can also create links to LFS objects they
don't really own, allowing them to read the contents of files if they
know just the size or OID.

We can close this hole by requiring requests to `upload_finalize` to be
sourced from Workhorse. The mechanism to do this already exists.
2019-01-31 16:52:48 +01:00
..
api Do not expose trigger token when user should not see it 2019-01-31 16:51:17 +01:00
projects Enable the Layout/ExtraSpacing cop 2019-01-24 13:05:45 +01:00
git_http_spec.rb Switch use of Rack::Request to ActionDispatch::Request 2019-01-07 00:35:53 -08:00
jwt_controller_spec.rb Update specs to rails5 format 2018-12-19 10:04:31 +11:00
lfs_http_spec.rb Verify that LFS upload requests are genuine 2019-01-31 16:52:48 +01:00
lfs_locks_api_spec.rb Enable the Layout/ExtraSpacing cop 2019-01-24 13:05:45 +01:00
oauth_tokens_spec.rb Update specs to rails5 format 2018-12-19 10:04:31 +11:00
openid_connect_spec.rb Rename GroupHierarchy into ObjectHierarchy 2018-12-19 15:24:29 +01:00
rack_attack_global_spec.rb Fix deprecation: Using positional arguments in integration tests 2018-12-22 14:42:41 +01:00
request_profiler_spec.rb Enable the Layout/ExtraSpacing cop 2019-01-24 13:05:45 +01:00