Non-administrators get 404 viewing images in snippets created by Administrators
Summary
When an Administrator creates a snippet that contains an uploaded image in the Description, that image will 404
for users except other users with the Administrator role. This happens for personal snippets created with a visibility level of Internal or Public.
Steps to reproduce
Setup
- As a user with the Administrator role, use the + button and choose New snippet
- Set any Title and any content in the Files section
- Click in the Description (optional) box, click Attach a file, choose a file
- Observe that the description box is updated with a reference to the image
- Click Preview and observe that the image appears properly
- Set the Visibility level to Internal or Public
- Click Create snippet
- Observe that the image in the snippet appears properly
Test
- As a user who is not an Administrator, browse to the snippet created above
- Observe that the image is not loaded
- Click the link to the image
- Observe a
404
Note: If the Administrator impersonates a user who does not have the Administrator role, the image in the snippet will be visible.
Example Project
Someone with the Administrator role on gitlab.com
would need to create a snippet for us to test that this can be reproduced on gitlab.com
.
What is the current bug behavior?
Only users with the Administrator role can view images in Internal or Public snippets created by an Administrator.
What is the expected correct behavior?
Any applicable user should be able to view images in Internal snippets created by an Administrator. Anyone should be able to view images in Public snippets created by an Administrator.
Relevant logs and/or screenshots
The same snippet is shown in each Web browser. On the left, we are logged in as Administrator. On the right, we are logged in as a user without the Administrator role. Given the
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.5p203 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.6 Redis Version: 6.2.6 Sidekiq Version:6.4.0 Go Version: unknown GitLab information Version: 14.8.2-ee Revision: 20a7fdf52c9 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.7 URL: https://gitlab.example.com HTTP Clone URL: https://gitlab.example.comg/some-group/some-project.git SSH Clone URL: git@gitlab.example.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.23.2 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Results of GitLab application Check
This has been observed in 14.7.4 (customer) 14.8.2 (test instance) and 14.9.1 (test instance).
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing) Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.23.2 ? ... OK (13.23.2) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 9 users of 100 limit.
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/1 ... yes 1/2 ... yes 10/3 ... yes 1/4 ... yes 13/5 ... yes 13/6 ... yes 13/7 ... yes 1/8 ... yes 7/9 ... yes 2/10 ... yes 1/11 ... yes 3/12 ... yes 3/13 ... yes 1/14 ... yes 3/15 ... yes 7/16 ... yes 27/17 ... yes 1/18 ... yes 31/19 ... yes 34/20 ... yes 31/21 ... yes 37/22 ... yes 30/23 ... yes 30/24 ... yes 42/25 ... yes 44/26 ... yes 37/27 ... yes 48/29 ... yes 50/30 ... yes 31/31 ... yes 54/32 ... yes 54/33 ... yes 54/34 ... yes 58/35 ... yes 30/36 ... yes 8/37 ... yes 8/38 ... yes 1/39 ... yes 1/40 ... yes 76/41 ... yes 77/42 ... yes 77/43 ... yes 77/44 ... yes 77/45 ... yes 77/46 ... yes 84/48 ... yes 84/49 ... yes Redis version >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.5) Git user has default SSH configuration? ... yes Active users: ... 10 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished