shouldInterceptRequest is a WebView callback that lets an app examine and replace a resource request before the WebView loads it. It can be used to serve local content, modify responses, or block requests, so it directly affects what network data and scripts the page can access.
What it does in a WebView
shouldInterceptRequest is a WebView callback that sits in the request path before a resource is loaded. It gives the app a chance to inspect the URL, decide whether the request should proceed, and optionally return an alternate response. That makes it part of the WebView’s content control boundary rather than a passive observer.
Because it runs before the page consumes the resource, it can change what HTML, JavaScript, images, or other assets the WebView sees. In practice, that means the callback can be used for local caching, offline substitution, content filtering, or request blocking, all of which influence the page’s effective security posture.
Why it matters for page isolation
The security significance of shouldInterceptRequest comes from the fact that a WebView often renders remote and local content in the same execution environment. If interception is too broad, a trusted app can accidentally weaken origin separation by serving untrusted content, rewriting script responses, or allowing a page to load resources that would otherwise be blocked.
This makes the callback a control point for data exposure as well as for rendering behavior. A small logic mistake can change what network locations are reachable, whether a script executes, or whether a response is treated as trusted application content rather than external content.
Common uses and safe design choices
Developers usually use interception for legitimate reasons such as offline support, local asset delivery, custom headers, or policy-based request blocking. The safest pattern is to keep the interception rule set narrow, deterministic, and easy to audit, so the app only modifies the requests it truly owns.
When the callback is used to substitute content, the replacement response should be treated as security-sensitive code or data, not as a convenience feature. A replacement resource can inherit the page’s trust context, so its origin, integrity, and content type handling need to be deliberate.
Failure modes to watch
The main failure modes are overmatching, unintended bypass, and trust confusion. Overmatching happens when a broad URL pattern intercepts requests that were not meant to be handled, while bypass happens when a security rule is incomplete and hostile content slips through. Trust confusion appears when intercepted content is served as if it were same-origin or application-owned.
These mistakes can expose cookies, session state, sensitive API responses, or JavaScript execution paths to content the app did not intend to trust. In a WebView, that can turn a convenience feature into a content injection point.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V12 — Secure Communication | WebView interception changes how resources are fetched and trusted. |
| V15 — Secure Coding and Architecture | The callback is an architectural security boundary inside the app. | |
| Recommendation — Constrain intercepted resource handling so only intended content is delivered over approved channels. Design interception logic as a narrow security control with explicit ownership and review. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | Application-layer content handling and request rewriting are code security concerns. |
| Recommendation — Review WebView interception code as application software security logic before release. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | Intercepted requests and replacements must be validated before influencing execution. |
| SC-7 — Boundary Protection | The callback mediates traffic across a browser-like trust boundary. | |
| Recommendation — Validate intercepted URLs and replacement content before the WebView consumes them. Apply boundary controls to restrict which requests can be rewritten or blocked. | ||
Practitioner Guidance
Why practitioners should care: Treat shouldInterceptRequest as a security-relevant policy hook, not just a loading optimization. The rule should be designed so that every intercepted request has an explicit owner, purpose, and replacement behavior.
What to watch for: Review any interception logic that rewrites scripts, serves local files, or conditionally blocks network access. Those are the cases most likely to change execution behavior in ways that are hard to spot during normal testing.
Practitioner takeaway: If the callback can alter what the page executes or trusts, it deserves the same scrutiny you would give any other content security control.
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org