feat: add URL safety coordinator for navigation and bookmark flows - #108
Open
skrushna1704 wants to merge 1 commit into
Open
feat: add URL safety coordinator for navigation and bookmark flows#108skrushna1704 wants to merge 1 commit into
skrushna1704 wants to merge 1 commit into
Conversation
Introduces centralized URL trust, redirect tracking, and bookmark normalization wired through navigation, tabs, and share-import paths.
kododake
self-requested a review
July 5, 2026 05:05
kododake
requested changes
Jul 5, 2026
Owner
There was a problem hiding this comment.
Thank you for the PR. While the goal of introducing centralized URL trust checks, redirect tracking, and bookmark normalization is highly beneficial, there are several critical security vulnerabilities and functional bugs that need to be addressed before this can be merged.
- Critical Security Vulnerability: Insufficient Domain Validation
InUrlSafetyCoordinator.kt, the methodisTrustedNavigationTargetuseshost.contains(trustedRoot)to verify trusted domains. This partial match allows malicious hosts like "google.com.attacker.com" or "attacker-youtube.com" to be incorrectly classified as trusted targets. This bypasses the cleartext HTTP warning dialog without user consent, exposing users to MITM and phishing attacks.
- Fix: Use exact matches or subdomain suffixes:
host == trustedRoot || host.endsWith(".$trustedRoot").
- Critical Functional Bug: Broken Relative Redirect URL Resolution
InUrlSafetyCoordinator.kt,resolveRedirectTargetusesappendEncodedPathto resolve relative redirect paths. This incorrectly appends paths to the end of the current URL. For example, redirecting from "https://example.com/app/dashboard" to "/login" results in "https://example.com/app/dashboard/login" instead of the expected "https://example.com/login". The unit testresolveRedirectTarget_supportsRelativePathsmisses this because it only checks if the result is not blank.
- Fix: Use
java.net.URI'sresolve()method to properly handle relative and absolute paths.
- UX Bug: Incorrect Toast Message on Duplicate Batch Bookmark Import
InShareBookmarkActivity.kt, importing a batch of bookmarks always triggers thebookmark_addedtoast, even if all imported bookmarks were duplicates and no new bookmarks were actually added.
- Fix: Compare the size of the merged list with the existing list, and only show the success toast if the count increases.
- Thread-Safety and Test Isolation Issues
UrlSafetyCoordinator.sessionTrustedHostsis defined as a non-thread-safemutableSetOf(). SinceUrlSafetyCoordinatoris a singleton, concurrent access could throwConcurrentModificationException. Please use a thread-safe set (e.g.,ConcurrentHashMap.newKeySet()).- The tests in
UrlSafetyCoordinatorTestmodify the singleton's state (like redirect depth) but do not guarantee cleanup if an assertion fails. Please add cleanup logic in@Afterto prevent test contamination.
Please address these issues and update the PR.
JitendrapSnapwork0277
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces centralized URL trust, redirect tracking, and bookmark normalization wired through navigation, tabs, and share-import paths.