Skip to content

[INFRA-1222] fix: validate editor asset ids before API calls - #10306

Merged
sriramveeraghanta merged 1 commit into
previewfrom
fix/infra-1222-editor-asset-id-validation
Nov 16, 2026
Merged

sriramveeraghanta merged 1 commit into
previewfrom
fix/infra-1222-editor-asset-id-validation

Conversation

@pablohashescobar

Copy link
Copy Markdown
Member

Description

The src of an editor file node is stored document content, but the editor's file handlers placed it straight into API request paths (duplicate, delete, restore, existence check, and the source/download URL builders). A src that is not a plain asset id could therefore choose the path of a request made by whoever opened or edited the document.

The rule is now: a node src reaches an API path only if it is a valid asset id, and it is always encoded when interpolated.

  • packages/utils: new isValidAssetId (UUID). getEditorAssetSrc and getEditorAssetDownloadSrc return undefined for anything else and encode the id.
  • apps/web and apps/space file handlers: delete, restore and checkIfAssetExists make no request for an invalid non-http src; the duplicate path is guarded in duplicateEditorAsset, and the image node view does not start duplication for an invalid src.
  • Web and sites file services encode the id in the duplicate, check and restore paths.
  • Legacy http sources: both copies of getAssetIdFromUrl read the key from a parsed URL (so dot segments and backslashes are resolved first), and refuse non-http(s) schemes, empty keys and encoded path separators. The legacy delete/restore calls make no request when there is no key.

Behaviour for valid asset ids is unchanged.

Behavior change:

  • An image node whose src is neither a valid asset id nor an http(s) URL shows the "Add an image" placeholder instead of "Error loading image".
  • isValidAssetId uses the uuid package's validate, which is RFC-strict on the version and variant bits. Server-generated uuid4 ids pass; a hand-written id such as 00000000-0000-0000-0000-000000000001 would not.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

  • packages/services/src/file/helper.test.ts: added cases for the legacy key derivation (27 passed; the new cases fail without the fix).
  • Types, lint and format pass for @plane/utils, @plane/services, @plane/editor, web and space.
  • packages/utils has no test runner, so the predicate and URL builders have no committed test.

Not run in a browser. Please check manually:

  • Upload, delete and undo-delete an image in a work item description and in a page.
  • Copy an image between two editors (duplication) and confirm the copy loads.
  • A legacy image with an http source still loads, deletes and restores.

References

  • INFRA-1222
  • Same root cause, please confirm before closing: INFRA-1221, INFRA-1224, INFRA-1226, INFRA-1227, INFRA-1228, INFRA-1236

Created with Claude Code

An editor file node's src is stored document content. Only a plain asset id (UUID) is now used to build an asset API path, and it is encoded where it is interpolated; any other non-http src results in no request. For legacy http sources the asset key is read from a parsed URL and must be a single plain path segment.
Copilot AI balanced review requested due to automatic review settings November 15, 2026 23:03
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 29 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7b5626ca-8b29-41a2-a23e-5616bed24291
Commits

Reviewing files that changed from the base of the PR and between 290383d and 27e5edc.

Files selected for processing: 11

  • apps/space/helpers/editor.helper.ts
  • apps/web/hooks/editor/use-editor-config.ts
  • apps/web/services/file.service.ts
  • apps/web/store/editor/asset.store.ts
  • packages/editor/src/extensions/custom-image/components/node-view.tsx
  • packages/services/src/file/file.service.ts
  • packages/services/src/file/helper.test.ts
  • packages/services/src/file/helper.ts
  • packages/services/src/file/sites-file.service.ts
  • packages/utils/src/editor/common.ts
  • packages/utils/src/file.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 27e5edc.

@pablohashescobar pablohashescobar changed the title [INFRA-1222] fix(security): validate editor asset ids before API calls [INFRA-1222] fix: validate editor asset ids before API calls Nov 16, 2026

@sriramveeraghanta sriramveeraghanta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Real uuid4 asset ids pass, and the undefined return is handled in web, space and the pages assets tab. Non-blocking: the old getAssetIdFromUrl in apps/space/helpers/file.helper.ts is now unused.

@sriramveeraghanta
sriramveeraghanta merged commit c9d9ee7 into preview Nov 16, 2026
16 checks passed
@sriramveeraghanta
sriramveeraghanta deleted the fix/infra-1222-editor-asset-id-validation branch November 16, 2026 20:23
sriramveeraghanta pushed a commit that referenced this pull request Nov 16, 2026
An editor file node's src is stored document content. Only a plain asset id (UUID) is now used to build an asset API path, and it is encoded where it is interpolated; any other non-http src results in no request. For legacy http sources the asset key is read from a parsed URL and must be a single plain path segment.
Pawel-Kranzberg pushed a commit to klazwi/pi-plane that referenced this pull request Nov 18, 2026
…ne#10306)

An editor file node's src is stored document content. Only a plain asset id (UUID) is now used to build an asset API path, and it is encoded where it is interpolated; any other non-http src results in no request. For legacy http sources the asset key is read from a parsed URL and must be a single plain path segment.

(cherry picked from commit bdb24bc)
ygpark2 added a commit to ygpark2/plane that referenced this pull request Nov 30, 2026
…dpoint

Image nodes whose src is the resolved /api/assets/v2/.../<asset_id>/ URL
(e.g. images copied from a rendered editor) were routed to the legacy
file-assets restore endpoint because the src starts with "http". That
endpoint looks the asset up by storage key, so it always returned 404 and
the soft-deleted asset was never restored.

Extract the asset id from absolute v2 asset URLs (only when the path is a
v2 asset path ending in a valid asset id) and restore it through the v2
endpoint, in both the web and space editors. Only the validated plain
asset id reaches the API path, consistent with makeplane#10306.

Fixes makeplane#9993

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants