Skip to content

Require connections permission on the upload page - #726

Open
chrisclark wants to merge 1 commit into
masterfrom
fix/upload-view-permission
Open

chrisclark wants to merge 1 commit into
masterfrom
fix/upload-view-permission

Conversation

@chrisclark

Copy link
Copy Markdown
Collaborator

Summary

Fixes the unauthenticated upload page. High.

DatabaseConnectionUploadCreateView is the only view in explorer/ee/db_connections/views.py without PermissionRequiredMixin, so anyone who could reach the URL got the upload form back with a 200. Confirmed before the fix:

staff      create_upload -> 200 UPLOAD PAGE
non-staff  create_upload -> 200 UPLOAD PAGE
anonymous  create_upload -> 200 UPLOAD PAGE

Meanwhile /explorer/connections/ correctly showed the login page to the same non-staff and anonymous requests, which is what made this stand out.

The impact is disclosure, not upload: the template renders valid_connections, so it leaked the alias and id of every user's uploaded SQLite database, and those ids are exactly the values UploadDbView accepts as append. The POST that performs the upload is separately guarded, so this was the flow's unguarded entry point rather than a way to write files.

Fix

Requires EXPLORER_PERMISSION_CONNECTIONS, matching every sibling view in the module. Also added ExplorerContextMixin alongside it — the other connection views use it, and without it this page was rendered without the shared context (can_manage_connections and friends).

Tests

In SimpleViewTests:

  • anonymous GET is denied (login template used);
  • the connection aliases are not present in an unauthorized response — this is the actual disclosure being closed, asserted on content rather than status, because denial renders the login page with a 200;
  • staff still gets the page.

Full suite: 294 tests, OK. ruff check explorer/: clean.

DatabaseConnectionUploadCreateView was the one view in this module without
PermissionRequiredMixin, so anyone who could reach the URL -- including an
anonymous visitor -- got the upload form back with a 200. The template
renders valid_connections, the list of uploaded SQLite connections, so it
also disclosed the alias and id of every user's uploaded database. Those
ids are the values UploadDbView accepts as "append".

The POST that actually uploads is guarded, so this was disclosure rather
than an upload path; still, it was the upload flow's entry point and every
sibling view requires connections_permission.

Added ExplorerContextMixin alongside the permission mixin, matching the
other connection views, so the page is rendered with the same context
(can_manage_connections and friends) rather than silently missing it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant