Skip to content

fix(browser): refuse to create/update local bookmarks with an executable URL scheme - #2390

Closed
carfeii wants to merge 1 commit into
floccusaddon:developfrom
carfeii:fix/sanitize-bookmark-url-scheme
Closed

carfeii wants to merge 1 commit into
floccusaddon:developfrom
carfeii:fix/sanitize-bookmark-url-scheme

Conversation

@carfeii

@carfeii carfeii commented Oct 17, 2026

Copy link
Copy Markdown

Fixes #2389.

BrowserTree.createBookmark()/updateBookmark() passed a synced bookmark's url straight through to browser.bookmarks.create()/update() with no scheme restriction. A bookmark synced in from any configured adapter can set url to javascript:... or data:text/html,..., which becomes a real browser bookmark that runs that code when clicked, in the context of whatever tab is active at the time.

This adds sanitizeBookmarkUrl(), which replaces javascript:/vbscript:/data: URLs with about:blank before the bookmark reaches the browser API. This is a blanket backstop across every adapter; Nextcloud's own opt-in javascript: bookmarklet support (hasFeatureJavascriptLinks) isn't threaded through to this layer, so if that feature should keep working specifically through this path, it would need its own explicit exception here.

…ble URL scheme

createBookmark()/updateBookmark() passed bookmark.url straight through to
browser.bookmarks.create()/update(). That value comes from whichever sync
adapter is configured (WebDAV, Google Drive, a Git repo, Nextcloud, ...),
i.e. from a remote the user trusted with bookmark data, not with the
ability to run code in their browser. A javascript:/vbscript: bookmark
executes in the context of whatever tab is active when the user clicks
it, and a data: bookmark can carry an inline HTML document with its own
script, so a compromised or malicious sync account could plant a working
bookmarklet directly into the browser's bookmarks.

Add sanitizeBookmarkUrl(), which replaces these schemes with about:blank
before the bookmark reaches the browser API. This is a blanket backstop
across every adapter; Nextcloud's own opt-in javascript: bookmarklet
support (hasFeatureJavascriptLinks) isn't threaded through to this layer
and would need its own explicit exception if that feature should keep
working through this adapter specifically.
@marcelklehr

Copy link
Copy Markdown
Member

Closing as syncing javascript bookmarks are an explicit feature of floccus.

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.

Synced bookmark URL with javascript:/data: scheme is created as a real browser bookmark unsanitized

2 participants