Skip to content

fix(middleware): let a route fix the node type to an application - #3415

Draft
rubenvdlinde wants to merge 1 commit into
mainfrom
fix/noid/permission-fixed-node-type
Draft

rubenvdlinde wants to merge 1 commit into
mainfrom
fix/noid/permission-fixed-node-type

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

The routes of an application check permissions with #[RequirePermission(..., typeParam: 'context')]. The middleware reads the node type from a request parameter named context. None of these routes has that parameter in its URL, so a client can send ?context=table (or 0) and have the permission checked on the table with the same id instead of on the application.

The same flaw lets someone outside an application read its pages: whoever owns a table with the same id as the application gets 200 on GET /api/2/contexts/{contextId}/pages/{pageId}?context=table. With the fixed type that answers 404.

RequirePermission now accepts type: 'context', a fixed node type the request cannot change. The nine application routes in ContextController and ContextPageController use it, and no typeParam: 'context' is left on main.

Found by @blizzz in the review of #3135. The menu routes there move to the fixed type once both have landed.

How it was tested

New tests/unit/Middleware/PermissionMiddlewareTest.php: with the type fixed, the application is checked whatever context the request sends (none, table, 0 or 1), and a manager passes. Full unit suite (788 tests) and psalm green.

How it was tested on a live instance

On Nextcloud 34 with PostgreSQL, with an owner, a reader and an outside user, where the reader owns a table with the same id as the application and the outside user owns a table with the id of an application they are not in. On main the reader created a page with ?context=table and with ?context=0 and renamed the owner's page (200 each), and the outside user read a page of the application with ?context=table (200). With this change the same requests answer 403 for the reader and 404 for the outside user, also against the application created on main; the owner still creates and renames pages and exports the scheme (200), and the reader still reads the application (200).

🖼️ Screenshots

None, no visible change.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable2
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

RequirePermission takes 'context' as a fixed type, so the request cannot
name another node type and get the permission checked on a table or view
with the same id. The application routes use it.

Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
@blizzz blizzz added bug Something isn't working 2. developing Work in progress labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants