grpc / grpc/grpc-java

binder: Cached PERMISSION_DENIED results from SecurityPolicies.hasPermission() can be confusing

Offen
#10,950 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
binder enhancement
Vorherrschende Sprache
Java
Sterne
12.1k
Forks
4k
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
37

Beschreibung

Context: The gRPC framework assumes that a `SecurityPolicy`s verdict for a given peer UID will not change over the lifetime of any process with that UID. But Android runtime permissions can be granted or revoked by the user at any time so the `hasPermissions()` policy has the confusing behavior that calls may still fail even after the client requests and obtains the required permission. And on the flip side, clients can only safely require that servers hold install-time permissions which cannot change.

[The official Android advice](https://developer.android.com/training/permissions/requesting) is pretty clear that apps should check/request/obtain before attempting a permission controlled operation. So while I think the current behavior is technically fine, developers would be happier if our access control decisions reflected the current state of all grants.

Idea 1: keep the cache but listen for grant changes and invalidate. I'm not aware of an Android API that lets you get notified when a permission is granted to another app. So this may be infeasible.

Idea 2: don't cache SecurityPolicy outcomes that depend on grants. hasPermissions() costs two round trips to system_server. Paying that once per transport setup may not be that expensive compared to everything else going on.

Idea 3: stop caching *negative* SecurityPolicy outcomes. If devs are following the check/request/obtain rules, PERMISSION_DENIED should only happen during development when performance doesn't really matter. Repeated successful transport setup results in cache hits and remains just as fast as today.

(From b/326200530)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, SecurityPolicies.hasPermission() und hasPermissions() zu lesen, um zu verstehen, wie PERMISSION_DENIED-Ergebnisse zwischengespeichert werden. Vergleiche die drei vorgeschlagenen Ansätze und identifiziere die relevanten Tests; abgeschlossen ist die Aufgabe, wenn ein abgestimmtes Caching-Verhalten für sich ändernde Android-Laufzeitberechtigungen und eine Abdeckung für das Erteilen und Entziehen von Berechtigungen vorhanden sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, java
Bereich
authorization, mobile-dev, security
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.