fix: strengthen explore portfolio site condition#25433
Conversation
|
Cursor Agent can help with this pull request. Just |
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|



Description
Replaced URL substring check with hostname comparison for portfolio site identification to fix a security vulnerability.
This should be pretty safe since we own the underlying data, but still good practice to use stricter url condition.
Changelog
CHANGELOG entry: fix: strengthen explore portfolio site condition
Related issues
Fixes: https://github.com/MetaMask/metamask-mobile/security/code-scanning/134
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk: small, localized change to Portfolio site detection logic; the main risk is accidentally missing/duplicating the Portfolio entry if URL parsing/normalization behaves unexpectedly for edge-case inputs.
Overview
Strengthens how the Explore sites list detects whether MetaMask Portfolio is already present by replacing a
url.includes('portfolio.metamask.io')substring check with strict hostname parsing/comparison.Adds
PORTFOLIO_HOSTNAMEand a newisPortfolioSiteUrl()normalizer (handles missing schemes/whitespace) and uses it inmergePortfolioSiteto avoid false matches that could let non-Portfolio URLs bypass or trigger the Portfolio entry logic.Written by Cursor Bugbot for commit 3214479. This will update automatically on new commits. Configure here.