A WebView grants location access to every page that asks

tx0/kotlin:geolocation-granted-to-every-originrecommendedwarningsecurity/sensitive-datadepth fastsecurity, android, cwe-359

What it finds

onGeolocationPermissionsShowPrompt asks whether a page may read the device location. Answering callback.invoke(origin, true, ...) without looking at the origin hands the location to any site the web view loads.

From the rule's source, geolocation_granted.rs.

Example from the rule's tests
class Chrome : WebChromeClient() {    override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) {        callback.invoke(origin, true, false)tx0 reports: every origin is given the device location    }} class CarefulChrome : WebChromeClient() {    override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) {        if (origin == TRUSTED) callback.invoke(origin, true, false) else callback.invoke(origin, false, false)    }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:geolocation-granted-to-every-origin" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/kotlin:geolocation-granted-to-every-origin] reason="..."

tx0 explain tx0/kotlin:geolocation-granted-to-every-origin shows the same in the terminal. Found a false positive? Report it.