Skip to content

fix(security): enforce note edit access on PDF derive-page - #1063

Merged
otomatty merged 1 commit into
developfrom
cursor/critical-bug-investigation-6113
Jun 13, 2026
Merged

fix(security): enforce note edit access on PDF derive-page#1063
otomatty merged 1 commit into
developfrom
cursor/critical-bug-investigation-6113

Conversation

@cursor

@cursor cursor Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Critical bug investigation (triggered by PR #1062) found a permission bypass in the PDF derive-page API. This PR adds the missing note edit check and corrects a misleading MCP tool description that could cause accidental page deletion.

Bug and impact

PDF derive-page authorization bypass

POST /api/sources/pdf/:sourceId/highlights/:highlightId/derive-page accepted an optional noteId in the request body but never verified that the caller could edit that note. Any authenticated user who owned a PDF highlight could create a page inside another user's note by supplying the victim's noteId.

Impact: Cross-note content injection — pages appear in notes the attacker does not belong to.

Trigger scenario:

  1. Attacker is authenticated and owns a PDF highlight.
  2. Attacker knows (or guesses) a target note UUID.
  3. POST .../derive-page with { "noteId": "<victim-note-uuid>", "title": "injected" }.
  4. A page is created with owner_id = attacker but note_id = victim note.

Root cause

POST /api/pages gained getNoteRole + canEdit checks when an explicit note_id is provided, but the PDF derive-page route (added in #858) was never updated. A comment deferred the check ("将来 import で共有してもよい").

Fix

Validation

  • Added server/api/src/__tests__/routes/pdfSources.test.ts — asserts 403 when noteId points to a foreign private note.
  • bunx vitest run src/__tests__/routes/pdfSources.test.ts passes.

Other findings (not fixed in this PR)

PR #1062 itself (actions/checkout 6.0.2 → 6.0.3) contains no application logic changes.

Open in Web View Automation 

@otomatty
otomatty marked this pull request as ready for review June 13, 2026 04:53
@otomatty
otomatty self-requested a review as a code owner June 13, 2026 04:53
POST /api/sources/pdf/.../derive-page accepted an arbitrary noteId without
checking membership, allowing authenticated users to inject pages into notes
they cannot edit. Mirror POST /api/pages permission checks when noteId is set.

Also correct zedi_remove_page_from_note MCP description: after issue #823 the
endpoint soft-deletes the page; there is no unlink-only mode.

Co-authored-by: akimasa.sugai <akimasa.sugai@saedgewell.com>
@otomatty
otomatty force-pushed the cursor/critical-bug-investigation-6113 branch from 7dfb273 to b6adebc Compare June 13, 2026 05:33
@otomatty
otomatty merged commit d10ae95 into develop Jun 13, 2026
18 checks passed
@otomatty
otomatty deleted the cursor/critical-bug-investigation-6113 branch June 13, 2026 05:45
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.

2 participants