Modern Apps git

← Modern-Apps.git

security: guard weather IPC; stop logging secrets; safer HTML default

Commit
b699b7343d0b2676afd87a022d93f63bd4d6dc3a
Author
Vayun Mathur <[email protected]>
When
2026-11-20 20:44 UTC (15 days ago)
Parents
e7e5793
weather's two assistant intent activities were exported with
no permission - the repo's only unguarded assistant surface.
They now carry a signature ACCESS_WEATHER permission like
every peer app.

Always-on logs printing secrets are gone or status-only:
WhatsApp/Signal registration tokens and bodies, Google Voice
raw dumps, Outlook OAuth bodies/state, photos OCR preview text,
Lyft payment bodies, maps' full deep-link string.

library/ui HtmlText defaulted javaScriptEnabled=true (every
untrusted caller already passed false) - default now false.
securemail extraction rules switch include-all to the deny-all
peer pattern; code stops cloud-backing the prefs file holding
its git token.

Diff

code/src/main/res/xml/data_extraction_rules.xml
diff --git a/code/src/main/res/xml/data_extraction_rules.xml b/code/src/main/res/xml/data_extraction_rules.xmlindex 06d5b93cc2..e578961ebc 100644--- a/code/src/main/res/xml/data_extraction_rules.xml+++ b/code/src/main/res/xml/data_extraction_rules.xml@@ -2,17 +2,29 @@ <!-- Code editor. Overrides the permissive default in the shared :library module.       Storage audit:-       file  datastore/code_editor.preferences_pb   Two keys: soft_wrap and folder_uri, the-                                                    SAF tree URI of the last opened project-                                                    folder.+       file  datastore/code_editor.preferences_pb   The app's only persisted state+                                                    (EditorPrefs): editor settings+                                                    (soft_wrap, font size, tab width,+                                                    theme, smart-input toggles), session+                                                    and recent-file paths, snippets, fold+                                                    state, the last opened folder, and git+                                                    credentials โ€” git_username, git_token,+                                                    git author name/email.        No database, no SharedPreferences, no app-private files or caches. Source files are        edited in place through SAF in storage the app does not own. -     Both keys are settings, so the DataStore is allowlisted for cloud backup. folder_uri will-     need re-granting after a restore but is harmless to carry. -->+     Because that one DataStore file now holds a git token, it must not leave the+     device in cloud backup: cloud backup is denied outright (the file was the+     only thing cloud backup ever carried here, so nothing else is lost).+     Device transfer still carries it, so settings and sign-in survive a direct+     device-to-device move; folder access will need re-granting after a restore. --> <data-extraction-rules>     <cloud-backup>-        <include domain="file" path="datastore/code_editor.preferences_pb" />+        <exclude domain="root" path="." />+        <exclude domain="file" path="." />+        <exclude domain="database" path="." />+        <exclude domain="sharedpref" path="." />+        <exclude domain="external" path="." />     </cloud-backup>     <device-transfer>         <include domain="file" path="datastore/code_editor.preferences_pb" />
communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.ktindex 4b991edad4..bad1affff7 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.kt@@ -116,11 +116,8 @@ class GoogleVoiceClient(private val session: GoogleVoiceSession) {             body = jsonBody,         )         checkVoiceResponse(path, response)-        // TEMP diagnostic logging of raw protojson so the positional parser can be pinned to the-        // real wire shapes. Chunked because logcat truncates long lines.         val body = response.body         Log.dev(TAG, "$path <= ${body.length} bytes")-        body.chunked(LOG_CHUNK).forEachIndexed { i, chunk -> Log.dev(TAG, "$path[$i] $chunk") }         return body     } @@ -130,7 +127,7 @@ class GoogleVoiceClient(private val session: GoogleVoiceSession) {             throw GoogleVoiceAuthException("Google Voice auth rejected (${response.status})")         }         if (!response.isSuccess) {-            Log.error(TAG, "$path failed HTTP ${response.status}: ${response.body.take(LOG_SNIPPET)}")+            Log.error(TAG, "$path failed HTTP ${response.status}")             throw IOException("Google Voice ${path} failed: HTTP ${response.status}")         }     }@@ -140,8 +137,6 @@ class GoogleVoiceClient(private val session: GoogleVoiceSession) {         private const val TAG = "GoogleVoiceRaw"         private const val HTTP_UNAUTHORIZED = 401         private const val HTTP_FORBIDDEN = 403-        private const val LOG_CHUNK = 3500-        private const val LOG_SNIPPET = 500         private const val TOKEN_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"         private const val BASE = "https://clients6.google.com/voice/v1/voiceclient/" 
communicate/src/main/java/com/vayunmathur/communicate/data/signal/registration/RegistrationHttpClient.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/signal/registration/RegistrationHttpClient.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/signal/registration/RegistrationHttpClient.ktindex db293f6c23..66b583a4e7 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/signal/registration/RegistrationHttpClient.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/signal/registration/RegistrationHttpClient.kt@@ -415,8 +415,7 @@ class RegistrationHttpClient(private val context: Context) {                 resp.body)         }         if (!resp.isSuccess) {-            // Log the full server body so a 422/400 names the rejected field in logcat on the next retest.-            Log.error(TAG, "submitRegistration HTTP ${resp.status}: ${resp.body.take(LOG_BODY_MAX_CHARS)}")+            Log.error(TAG, "submitRegistration HTTP ${resp.status}")             return RegisterResult("error", null, null, "HTTP ${resp.status}", null, resp.body)         }         return finalizeRegister(resp.body, auth)@@ -583,8 +582,6 @@ class RegistrationHttpClient(private val context: Context) {         private const val HTTP_RATE_LIMITED = 429         /** How much of an error response body is quoted in an exception message. */         private const val ERROR_BODY_MAX_CHARS = 500-        /** How much of an error response body is written to the log for diagnosis. */-        private const val LOG_BODY_MAX_CHARS = 1000         private const val UUID_SIZE = 16         private const val VERIFICATION_SESSION_PATH = "/v1/verification/session"         private const val VERIFICATION_CODE_PATH = "/v1/verification/session/%s/code"
communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/registration/RegistrationHttpClient.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/registration/RegistrationHttpClient.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/registration/RegistrationHttpClient.ktindex d503c93186..67bea3eed9 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/registration/RegistrationHttpClient.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/whatsapp/registration/RegistrationHttpClient.kt@@ -110,8 +110,7 @@ class RegistrationHttpClient(         val j = parse(body)         Log.error(             TAG,-            "W2 code raw=${body.take(LOG_BODY_SNIPPET)} " +-                "reason=${j.optStringOrNull("reason")} param=${j.optStringOrNull("param")}")+            "W2 code reason=${j.optStringOrNull("reason")} param=${j.optStringOrNull("param")}")         return CodeResult(             status = j.optString("status", "error"),             method = j.optStringOrNull("method"),@@ -158,13 +157,6 @@ class RegistrationHttpClient(      /** POST `/v2/exist` โ€” probe whether the number is already registered on this key material. */     suspend fun checkExist(cc: String, number: String): ExistResult {-        // DEBUG: log token variants so we can compare to the offline reference (no SMS sent).-        runCatching {-            Log.status(TAG, "debug token national=$number -> ${RegistrationAttestation.computeToken(context, number)}")-            Log.status(-                TAG,-                "debug token full=$cc$number -> ${RegistrationAttestation.computeToken(context, "$cc$number")}")-        }         val auth = WhatsAppAuthData.load(context)         val p = RegParams()         p.a01("cc", cc)@@ -179,8 +171,7 @@ class RegistrationHttpClient(         val j = parse(body)         Log.error(             TAG,-            "W2 exist raw=${body.take(LOG_BODY_SNIPPET)} " +-                "reason=${j.optStringOrNull("reason")} param=${j.optStringOrNull("param")}")+            "W2 exist reason=${j.optStringOrNull("reason")} param=${j.optStringOrNull("param")}")         return ExistResult(             j.optString("status", "error"),             j.optStringOrNull("reason"),@@ -387,7 +378,7 @@ class RegistrationHttpClient(         }         val reason = j.optStringOrNull("reason")         val param = j.optStringOrNull("param")-        if (status != "ok") Log.error(TAG, "W2 register raw=${body.take(LOG_BODY_SNIPPET)} reason=$reason param=$param")+        if (status != "ok") Log.error(TAG, "W2 register reason=$reason param=$param")         return RegisterResult(             status = status,             newJid = newJid ?: login?.let { "[email protected]" },@@ -543,7 +534,7 @@ class RegistrationHttpClient(                 body = body,                 useSystemTrust = true,             )-            Log.status(TAG, "/v2/$path -> ${resp.status}: ${resp.body.take(LOG_RESP_SNIPPET)}")+            Log.status(TAG, "/v2/$path -> ${resp.status}")             resp.body         } catch (expected: Throwable) {             Log.error(TAG, "/v2/$path request failed", expected)@@ -597,8 +588,6 @@ class RegistrationHttpClient(          */         private const val SEND_INTEGRITY_SIGNALS = false         private const val MS_PER_SECOND = 1000L-        private const val LOG_BODY_SNIPPET = 2000-        private const val LOG_RESP_SNIPPET = 400         private const val MCC_LENGTH = 3     } 
library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.ktindex c184ecc8f6..d91449e494 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt@@ -45,8 +45,9 @@ import java.io.File  *   readable 1:1 scale, and drops any viewport tag the sender embedded. See  *   [HtmlTextDocument.FIT_TO_WIDTH_CSS].  */-// javaScriptEnabled is an explicit caller opt-in (default documented as unsafe-// for untrusted mail, which passes false); WebView JS is never enabled silently.+// javaScriptEnabled defaults to false: scripts are an explicit caller opt-in,+// so untrusted content (mail, imported files) never runs a sender's script+// unless a caller deliberately passes true for trusted local content. @SuppressLint("SetJavaScriptEnabled") @Composable fun HtmlText(@@ -56,7 +57,7 @@ fun HtmlText(     hideQuotes: Boolean = false,     cidMap: Map<String, File> = emptyMap(),     openLinksExternally: Boolean = true,-    javaScriptEnabled: Boolean = true,+    javaScriptEnabled: Boolean = false,     blockRemoteContent: Boolean = false,     scrollInternally: Boolean = false,     fitContentToWidth: Boolean = false,
maps/src/main/java/com/vayunmathur/maps/MainActivity.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/MainActivity.kt b/maps/src/main/java/com/vayunmathur/maps/MainActivity.ktindex ba6bc1a20a..c891e01602 100644--- a/maps/src/main/java/com/vayunmathur/maps/MainActivity.kt+++ b/maps/src/main/java/com/vayunmathur/maps/MainActivity.kt@@ -192,10 +192,10 @@ class MainActivity : MaActivity() {         val data = intent.dataString ?: return         val link = MapLinkParser.parse(data)         if (link == null) {-            Log.status(TAG, "ACTION_VIEW ignored (unparseable): $data")+            Log.status(TAG, "ACTION_VIEW ignored (unparseable)")             return         }-        Log.status(TAG, "ACTION_VIEW routed data=$data -> $link")+        Log.status(TAG, "ACTION_VIEW routed -> $link")         if (link.navigate) navigateTo(link) else openPlace(link)     } 
securemail/src/main/res/xml/data_extraction_rules.xml
diff --git a/securemail/src/main/res/xml/data_extraction_rules.xml b/securemail/src/main/res/xml/data_extraction_rules.xmlindex 81a97e0f26..f6bf706912 100644--- a/securemail/src/main/res/xml/data_extraction_rules.xml+++ b/securemail/src/main/res/xml/data_extraction_rules.xml@@ -1,17 +1,23 @@ <?xml version="1.0" encoding="utf-8"?>+<!-- Deny-all. Overrides the permissive include-everything default in the shared+     :library module. Secure mail holds an encrypted mail vault, account+     credentials and keystore-wrapped key material; none of it is safe to copy+     off the device, and keystore-bound state would not be restorable on a new+     device in any case. Mirrors the deny-all peer pattern (e.g. passwords/,+     communicate/). --> <data-extraction-rules>     <cloud-backup>-        <include domain="root" path="." />-        <include domain="file" path="." />-        <include domain="database" path="." />-        <include domain="sharedpref" path="." />-        <include domain="external" path="." />+        <exclude domain="root" path="." />+        <exclude domain="file" path="." />+        <exclude domain="database" path="." />+        <exclude domain="sharedpref" path="." />+        <exclude domain="external" path="." />     </cloud-backup>     <device-transfer>-        <include domain="root" path="." />-        <include domain="file" path="." />-        <include domain="database" path="." />-        <include domain="sharedpref" path="." />-        <include domain="external" path="." />+        <exclude domain="root" path="." />+        <exclude domain="file" path="." />+        <exclude domain="database" path="." />+        <exclude domain="sharedpref" path="." />+        <exclude domain="external" path="." />     </device-transfer> </data-extraction-rules>
taxi/src/main/java/com/vayunmathur/taxi/network/lyft/LyftPaymentsClient.kt
diff --git a/taxi/src/main/java/com/vayunmathur/taxi/network/lyft/LyftPaymentsClient.kt b/taxi/src/main/java/com/vayunmathur/taxi/network/lyft/LyftPaymentsClient.ktindex 2186d39de1..3b44db8a19 100644--- a/taxi/src/main/java/com/vayunmathur/taxi/network/lyft/LyftPaymentsClient.kt+++ b/taxi/src/main/java/com/vayunmathur/taxi/network/lyft/LyftPaymentsClient.kt@@ -66,9 +66,7 @@ internal class LyftPaymentsClient(private val session: LyftApiSession) {         )         Log.debug(TAG, "PUT /charge-accounts-multi-provider -> ${resp.status}")         if (!resp.isSuccess) {-            // 422s here are opaque without the server's reason โ€” log the full exchange so the-            // exact validation error (field name / compliance / challenge) is visible.-            Log.status(TAG, "set-default failed ${resp.status}: req=$body resp=${resp.text}")+            Log.status(TAG, "set-default failed ${resp.status}")             return PaymentActionResult.Failed(session.httpError(resp))         }         // The response is a ChargeAccountsResponse; return the refreshed list when it parses.@@ -152,7 +150,7 @@ internal class LyftPaymentsClient(private val session: LyftApiSession) {         }.getOrElse { return AddCardResult.Failed("Create card request failed: ${it.message}") }         Log.debug(TAG, "POST /charge-accounts-multi-provider (create) -> ${resp.status}")         if (!resp.isSuccess) {-            Log.status(TAG, "add-card failed ${resp.status}: req=$body resp=${resp.text}")+            Log.status(TAG, "add-card failed ${resp.status}")             return AddCardResult.Failed(session.httpError(resp))         }         // Response is a ChargeAccountsResponse; return the refreshed list when it parses.
weather/src/main/AndroidManifest.xml
diff --git a/weather/src/main/AndroidManifest.xml b/weather/src/main/AndroidManifest.xmlindex d320de2db0..98a26fd0c9 100644--- a/weather/src/main/AndroidManifest.xml+++ b/weather/src/main/AndroidManifest.xml@@ -13,6 +13,10 @@     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> +    <permission+        android:name="com.vayunmathur.weather.permissions.ACCESS_WEATHER"+        android:protectionLevel="signature" />+     <queries>         <package android:name="com.vayunmathur.clock" />         <package android:name="com.vayunmathur.calendar" />@@ -51,12 +55,14 @@         <activity             android:name=".intents.GetWeatherIntent"             android:exported="true"-            android:theme="@android:style/Theme.NoDisplay" />+            android:theme="@android:style/Theme.NoDisplay"+            android:permission="com.vayunmathur.weather.permissions.ACCESS_WEATHER" />          <activity             android:name=".intents.GetWeatherByNameIntent"             android:exported="true"-            android:theme="@android:style/Theme.NoDisplay" />+            android:theme="@android:style/Theme.NoDisplay"+            android:permission="com.vayunmathur.weather.permissions.ACCESS_WEATHER" />          <!-- Car hosts (Android Auto / MA Auto) bind to this service by its              CarAppService intent-filter; the host is validated in code via