Skip to content

feat: validate URL schemes in SideNavItem, BreadcrumbsItem and Credits#9447

Draft
Artur- wants to merge 3 commits into
mainfrom
unsafe-urls
Draft

feat: validate URL schemes in SideNavItem, BreadcrumbsItem and Credits#9447
Artur- wants to merge 3 commits into
mainfrom
unsafe-urls

Conversation

@Artur-

@Artur- Artur- commented Jun 9, 2026

Copy link
Copy Markdown
Member

Mirror the Flow URL-scheme validation (vaadin/flow#24539) for the navigation and link sinks: SideNavItem#setPath, BreadcrumbsItem#setPath and Credits#setHref now reject URLs whose scheme is not considered safe, using UrlUtil#isSafeUrl and the shared UrlUtil#getUnsafeUrlMessage.

Safe schemes are configured through the com.vaadin.safeUrlSchemes property and default to http, https, mailto, tel and ftp. For trusted, hard-coded URLs each sink offers an unsafe variant that bypasses validation: SideNavItem#setUnsafePath, BreadcrumbsItem#setUnsafePath and Credits#setUnsafeHref.

Image and resource sinks (Avatar, SvgIcon, map and chart resource URLs) are intentionally left unvalidated: javascript: cannot execute there and data: URLs are a legitimate, common use.

Artur- and others added 3 commits June 8, 2026 13:23
Mirror the Flow URL-scheme validation (vaadin/flow#24539) for the
navigation and link sinks: SideNavItem#setPath, BreadcrumbsItem#setPath
and Credits#setHref now reject URLs whose scheme is not considered safe,
using UrlUtil#isSafeUrl and the shared UrlUtil#getUnsafeUrlMessage.

Safe schemes are configured through the com.vaadin.safeUrlSchemes
property and default to http, https, mailto, tel and ftp. For trusted,
hard-coded URLs each sink offers an unsafe variant that bypasses
validation: SideNavItem#setUnsafePath, BreadcrumbsItem#setUnsafePath and
Credits#setUnsafeHref.

Image and resource sinks (Avatar, SvgIcon, map and chart resource URLs)
are intentionally left unvalidated: javascript: cannot execute there and
data: URLs are a legitimate, common use.
* Update `SideNavItem` Javadoc to document unsafe scheme exceptions for constructors taking a path.
* Update `BreadcrumbsItem` Javadoc to document unsafe scheme exceptions for constructors taking a path.
* Add tests verifying that `IllegalArgumentException` is thrown when constructing items with unsafe URL schemes like `javascript:`.
* Update `AbstractLogin` to validate action URL schemes by default, throwing an `IllegalArgumentException` if an unsafe scheme (e.g., `javascript:`) is detected.
* Introduce a new `setUnsafeAction(String)` method to set the action URL without validation for controlled scenarios like hard-coded internal links.
* Add unit tests verifying that safe actions work as expected while unsafe schemes trigger exceptions in the default constructor but succeed when using `setUnsafeAction`.
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