You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Filter untrusted annotation links in the native PDF viewer - #102754
Filter untrusted PDF annotation links before the native viewer forwards them to the operating system or the travel flow.
Allow only absolute external HTTP(S) URLs.
Reject custom schemes, malformed/relative URLs, and HTTP(S) links to app hosts derived from the existing linking prefixes.
Normalize host casing and trailing dots so equivalent app-host URLs remain blocked.
Preserve external web links and the existing authenticated external travel-link flow.
Apply the filter to all uses of the native PDF viewer, including attachments. Web PDF rendering and general deep-link/authentication handling are unchanged.
This is scoped PDF-viewer containment, not a general deep-link fix. It does not inspect external websites' redirect destinations. Non-HTTP(S) annotations, including mail and phone links, are also blocked.
For manual replication, follow the concrete PDF download/send/open/tap steps in QA Steps below. Native-device verification is pending; automated results are recorded in AI Tests.
AI Tests
Performed on an isolated branch based on current main, reusing the existing checkout's installed dependencies:
Passed: npm run lint-changed and targeted npm run lint -- src/components/PDFView/index.native.tsx src/components/PDFView/isAllowedPDFLink.ts tests/unit/IsAllowedPDFLinkTest.ts tests/unit/NativePDFViewTest.tsx.
Passed: npm run react-compiler-compliance-check -- check-changed.
Passed: npm run spell-changed and git diff --check.
Blocked: npm run typecheck reports errors in untouched files involving missing MFA action constants (CHANGE_PRIMARY_LOGIN, ADD_DELEGATE, UPDATE_DELEGATE), emoji/parser APIs, and Onyx exportState. No errors were reported in the changed files. Some failures reflect the reused dependencies not matching current main.
Incomplete: full-repository npm run lint exceeded the 120-second timeout.
Not run: full Jest suite, Storybook smoke test, native-device QA, offline-device QA, or high-traffic-account testing.
Offline tests
Pending device verification:
Open both PDFs from the QA steps while online so they are cached. Enable airplane mode and turn Wi-Fi off.
Reopen each cached attachment and tap a blank area of the PDF page. Expected: neither PDF signs you out or navigates away from the viewer.
Restore connectivity before sending the confirmation message in QA step 6.
QA Steps
Run on iOS and Android native, using only test accounts you own. Device verification is still pending.
Install a native build containing this PR and sign in to your recipient test account.
On a computer, save these two PDFs from the original report (right-click each link and choose Save Link As):
In NewDot's desktop/web app, sign in to a second test account you own. Open a chat with the recipient account, drag each downloaded PDF into the message composer, and send it. Use the same environment as the native build.
On the recipient's native app, open that chat and tap transition_control.pdf to open it in the in-app PDF attachment viewer. Tap a blank area in the center of the page three times. The link annotation covers the entire page, so there is no visible link to find.
Close the viewer, open signout_poc.pdf in the same way, and tap a blank area of its page three times.
Close the viewer and send a normal text message in the chat to confirm the same account is still signed in and usable.
Expected with this PR: neither PDF logs the recipient out, opens a login/session-expired screen, opens a browser, or navigates to another app screen. The PDF stays open during the taps; normal viewer-control toggling is fine.
To reproduce the original bug: perform steps 2–5 on an affected build without the fix, using your own accounts. Tapping the PDF page is expected to sign the recipient out. Repeat on the PR build to verify that the same PDF no longer does so. Do not open the PDFs in Files, Preview, or an external PDF app; this flow tests NewDot's viewer.
PR Author Checklist
Verify that no new errors appear in the JS/native logs
I linked the correct issue in the ### Fixed Issues section above
I wrote clear testing steps that cover the changes made in this PR
I added steps for local testing in the Tests section
I added steps for the expected offline behavior in the Offline steps section
I added steps for Staging and/or Production testing in the QA steps section
I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
I included screenshots or videos for tests on all platforms
I ran the tests on all platforms & verified they passed on:
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
I verified that comments were added to code that is not self explanatory
I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
If a new CSS style is added I verified that:
A similar style doesn't already exist
The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
If new assets were added or existing ones were modified, I verified that:
The assets are optimized and compressed (for SVG files, run npm run compress-svg)
The assets load correctly across all supported platforms.
If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
I verified that all the inputs inside a form are aligned with each other.
I added Design label and/or tagged @Expensify/design so the design team can review the changes.
If the PR adds or modifies the UI:
I asked an AI agent to review the changes for accessibility issues and addressed its findings.
I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
I verified all new/changed elements have meaningful accessible names and roles.
I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
Screenshots/Videos
Android: Native
Pending native-device QA; no recording captured.
Android: mWeb Chrome
N/A — native PDF viewer only; web rendering is unchanged.
iOS: Native
Pending native-device QA; no recording captured.
iOS: mWeb Safari
N/A — native PDF viewer only; web rendering is unchanged.
MacOS: Chrome / Safari
N/A — native PDF viewer only; web rendering is unchanged.
@marcaaron Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]
I have verified the author checklist is complete (all boxes are checked off).
I verified the correct issue is linked in the ### Fixed Issues section above
I verified testing steps are clear and they cover the changes made in this PR
I verified the steps for local testing are in the Tests section
I verified the steps for Staging and/or Production testing are in the QA steps section
I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
I checked that screenshots or videos are included for tests on all platforms
I included screenshots or videos for tests on all platforms
I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
I verified tests pass on all platforms & I tested again on:
Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
I verified that comments were added to code that is not self explanatory
I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
I verified that this PR follows the guidelines as stated in the Review Guidelines
I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
If a new component is created I verified that:
A similar component doesn't exist in the codebase
All props are defined accurately
The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
The only data being stored in the state is data necessary for rendering and nothing else
The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
If a new CSS style is added I verified that:
A similar style doesn't already exist
The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
I verified that all the inputs inside a form are aligned with each other.
I added Design label and/or tagged @Expensify/design so the design team can review the changes.
If the PR adds or modifies the UI:
I asked an AI agent to review the changes for accessibility issues and addressed its findings.
I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
I verified all new/changed elements have meaningful accessible names and roles.
I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.
No help site update needed. This PR is a security fix that blocks unsafe links inside PDFs opened in the mobile app's viewer, and no help article describes tapping links inside PDF attachments, so no sentence became incorrect.
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
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.
Explanation of Change
Filter untrusted PDF annotation links before the native viewer forwards them to the operating system or the travel flow.
This is scoped PDF-viewer containment, not a general deep-link fix. It does not inspect external websites' redirect destinations. Non-HTTP(S) annotations, including mail and phone links, are also blocked.
Fixed Issues
For https://github.com/Expensify/Expensify/issues/687024
PROPOSAL: N/A — internal mitigation.
Tests
For manual replication, follow the concrete PDF download/send/open/tap steps in QA Steps below. Native-device verification is pending; automated results are recorded in AI Tests.
AI Tests
Performed on an isolated branch based on current
main, reusing the existing checkout's installed dependencies:npm test -- --runInBand --silent --runTestsByPath tests/unit/IsAllowedPDFLinkTest.ts tests/unit/NativePDFViewTest.tsx tests/unit/libs/TravelUtilsTest.ts— 3 suites, 65 tests. Existing duplicate-manual-mock warnings remain.npm run lint-changedand targetednpm run lint -- src/components/PDFView/index.native.tsx src/components/PDFView/isAllowedPDFLink.ts tests/unit/IsAllowedPDFLinkTest.ts tests/unit/NativePDFViewTest.tsx.node_modules/.bin/oxfmt --check src/components/PDFView/index.native.tsx src/components/PDFView/isAllowedPDFLink.ts tests/unit/IsAllowedPDFLinkTest.ts tests/unit/NativePDFViewTest.tsx.npm run react-compiler-compliance-check -- check-changed.npm run spell-changedandgit diff --check.npm run typecheckreports errors in untouched files involving missing MFA action constants (CHANGE_PRIMARY_LOGIN,ADD_DELEGATE,UPDATE_DELEGATE), emoji/parser APIs, and OnyxexportState. No errors were reported in the changed files. Some failures reflect the reused dependencies not matching currentmain.npm run lintexceeded the 120-second timeout.Offline tests
Pending device verification:
QA Steps
Run on iOS and Android native, using only test accounts you own. Device verification is still pending.
Expected with this PR: neither PDF logs the recipient out, opens a login/session-expired screen, opens a browser, or navigates to another app screen. The PDF stays open during the taps; normal viewer-control toggling is fine.
To reproduce the original bug: perform steps 2–5 on an affected build without the fix, using your own accounts. Tapping the PDF page is expected to sign the recipient out. Repeat on the PR build to verify that the same PDF no longer does so. Do not open the PDFs in Files, Preview, or an external PDF app; this flow tests NewDot's viewer.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Pending native-device QA; no recording captured.
Android: mWeb Chrome
N/A — native PDF viewer only; web rendering is unchanged.
iOS: Native
Pending native-device QA; no recording captured.
iOS: mWeb Safari
N/A — native PDF viewer only; web rendering is unchanged.
MacOS: Chrome / Safari
N/A — native PDF viewer only; web rendering is unchanged.