Android

Origin validation for WebView messages

Intents, storage, permissions, WebView and inter-app communication.

Android components1 min readEditorial methods

Web content that can call native functions has substantial power. Missing origin validation can expose that power to unintended content.

Evaluation approach

Define allowed origins and message schemas. Restrict both message names and the fields permitted for each action.

Application example

A payment bridge can use a server-created transaction identifier instead of directly trusting a web-supplied amount.

Limits and considerations

Checking the initial page URL does not secure later navigation or subframes.

Is a valid message shape enough?

A well-formed message can come from the wrong origin. Validate source and fields together. The server still authorizes users and objects; a success label from the bridge is not business approval.

Checks and decisions

  • Narrow origins
  • Validate schemas
  • Keep sensitive decisions server-side

Sources

The primary references above provide the technical basis. Example workflows and evaluation suggestions are this publication’s explanations, not independent test results for a particular product.