Fixed
Status Update
Comments
su...@google.com <su...@google.com> #2
We’ve shared this with our product and engineering teams and will continue to provide updates as more information becomes available.
ag...@gmail.com <ag...@gmail.com> #3
Thanks.
ro...@gmail.com <ro...@gmail.com> #4
Please stop hindering the usefulness of Android. Logcat output is in no way any kind of security risk. If you want to control every single aspect of what a user can do with their device tell the engineering team to go work for Apple if this is the kind of thinking the engineering team thinks is a "good" thing.
ar...@gmail.com <ar...@gmail.com> #5
Hi! Is there any update on this issue?
The OP pointed out a few serious problems and already proposed solutions, so I just wanted to make sure that Google is looking into it.
jj...@meanvalue.com <jj...@meanvalue.com> #6
This affects me as well and I have been patiently waiting for an update. Any word?
ra...@google.com <ra...@google.com>
ra...@google.com <ra...@google.com> #7
The issue has been fixed and it will be available in a future build.
ag...@gmail.com <ag...@gmail.com> #8
Thanks
Description
As per https://issuetracker.google.com/issues/232206670 , Android 13 shows an allow access dialog when an app that has
READ_LOGS
permission runslogcat
command for whether to grant it access or not.The two issues raised in the above issuetracker and mentioned below were actually apparently fixed in AOSP on May 2, 2022 before the above linked issue was opened on May 18, 2022 but the latest android builds at the time didn't have the fixes and were available the month after in
June
. Likely that's why no one from google responded specifically for them.logcat
commands are run, then multiple prompts would be shown for each command. Fixed ind1122015
Allow %s to access allow device logs?
message is being shown before the dialog is shown and is not dismissed if user clicks outside dialog or dialog times out. Fixed in2b6a2340
Current Design
The current design now as per following commits is detailed below.
d1122015
6a694788
For which apps the allow access dialog will be shown?
The allow access dialog will only be shown for the top foreground apps that have and access will be automatically be denied for apps running in background, even if the apps have a foreground service. Note that an app can get
ActivityManager.PROCESS_STATE_TOP
PROCESS_STATE_TOP
from background by showing an invisible dialog before running thelogcat
command if they have draw over apps permission.Why was this behaviour changed even though it was initially allowed for foreground service apps to request access as per ? An app that has a foreground service is still considered visible to the user. Even other privileged permissions like location, camera and microphone are allowed as per https://developer.android.com/guide/components/foreground-services#bg-access-restrictions for apps that have foreground services.
b4f8ed9b
What are the timeouts for allow access dialog?
There are two timeouts.
The a timeout of when it receives a new request from an app and it starts
LogcatManagerService
setsPENDING_CONFIRMATION_TIMEOUT_MILLIS
LogAccessDialogActivity
to show the allow access dialog. The timeout value is400s
/6.6min
for production builds and70s
for debug builds. If user does not accept or deny the access in the dialog orLogAccessDialogActivity
fails to send a response, access is automatically denied when timeout expires. Any new requests from the same app before dialog is clicked/dismissed or timeout expires are added to a pending requests queue and are collectively given approved/denied response and only a single dialog is shown for all of them.The its own timeout to when showing the allow access dialog. The timeout value is
LogAccessDialogActivity
also setsDIALOG_TIME_OUT
300s
/5min
for production builds and60s
for debug builds. This timeout will expire beforeLogcatManagerService
one does and will usually take precedence. When timeout expires, dialog will be dismissed and access denied for all pending requests.What are the timeouts for approvals and denials?
The a timeout of when it approves or denies access. The timeout value is
LogcatManagerService
setsSTATUS_EXPIRATION_TIMEOUT_MILLIS
60s
for all builds.What this means is that once an app is approved or denied access either via dialog buttons, dismissal or the two timeouts, for the next
60s
, the same response will be given for all new requests from the same app. So if access for denied, then the app, even despite being on the top, will not be able to show allow access dialog again for the next60s
to get access. If it was allowed access, it will be able to start newlogcat
processes for the next60s
and will automatically be allowed access.Bugs
There are a few bugs in the current design.
Dialog does not deny access on home button press until timeout passes
The added following
2b6a2340
But it does not consider home button. Since , user won't be able to get back to dialog if home button is pressed. The activity does show in recents menu if recents button is pressed, although it would be better to just consider it dismissed.
LogAccessDialogActivity
hasexcludeFromRecents=true
When home button is pressed, is not called to dismiss the dialog and neither is dialog's activity lifecycle , which is not overridden. This will also happen if two apps having
LogAccessDialogActivity.onDestroy()
OnDismissListener
to finish the activity. OnlyonStop()
is normally called as perPROCESS_STATE_TOP
like in split screen (or previously/in-future-hopefully havingPROCESS_STATE_FOREGROUND_SERVICE
) triggering a new dialog which closes previous.What this result in is app having to wait for
300s
/5min
for theDIALOG_TIME_OUT
to expire before getting denied access for currently runninglogcat
processes (which will stay hung) and then another60s
for the app to be able to show the dialog again to get access.Dialog is not being dismissed when activity destroyed for configuration change
The dialog is not being dismissed before activity is destroyed for configuration change like rotation, a change deliberately made in , which then raises the
bd9cf8f9
WindowLeaked
exception. The dialog will be recreated again anyways since activity will be recreated again with a call toonCreate()
, so no point in not dismissing the dialog. I assume the change was made becausefinish()
would be called byOnDismissListener
and dialog wouldn't show again after rotation. That should be fixable by settingOnDismissListener
tonull
if configuration change is being made or updateOnDismissListener
to not finish the activity for that case.Solutions
To solve the above two bugs, access should be denied in
onStop()
if user hasn't clicked and dialog dismissed as well instead of inonDestroy()
. Moreover,MSG_DISMISS_DIALOG
handler messages should ideally be removed when user clicks the dialog, which aren't currently being removed anywhere. The dialog should always be dismissed as well, even for configuration changes.Handler messages in LogcatManagerService are wrongly implemented
The by calling
MSG_PENDING_TIMEOUT
messages are not removed inLogcatManagerService.scheduleStatusExpiry()
mHandler.removeMessages(<what>, client)
.The reason is that the calls remove messages based on .
Handler.removeMessages()
p.obj == object
instead ofequals()
check, i.e bothclient
objects must have the same instance/reference and not just the same values. Someone else also got similar issues forlong
valuesThe
LogcatManagerService.getClientForRequest()
is responsibly for creating a newLogAccessClient
object when called byonLogAccessRequested()
(and alsoonLogAccessFinished()
). This client object is used byprocessNewLogAccessRequest()
to send the initialMSG_PENDING_TIMEOUT
message.When also checks
LogAccessDialogActivity
callsLogcatManagerServiceInternal.approveAccessForClient()
orLogcatManagerServiceInternal.declineAccessForClient()
, a newclient
object is created, which is then sent viaMSG_APPROVE_LOG_ACCESS
andMSG_DECLINE_LOG_ACCESS
and then received byLogAccessRequestHandler.handleMessage()
and then ultimately received byscheduleStatusExpiry()
. Since thisclient
object does not have the same instance as the one used to send the initialMSG_PENDING_TIMEOUT
message, the initial message never gets removed and is always sent. This doesn't always cause an ill effect becauseonPendingTimeoutExpired()
logAccessStatus.mStatus == STATUS_PENDING
before declining access, but it does cause a denial in background in some cases as noted below. It would be easier to check issues by adding log messages inhandleMessage()
and related calls.logcat
command and immediately approve access and note time, since this is whenMSG_PENDING_TIMEOUT
is initially sent.60s
of noted time on development builds,MSG_LOG_ACCESS_STATUS_EXPIRED
will be received.logcat
command again and dialog should show again, but don't approve or deny and just wait.70s
of noted time,MSG_PENDING_TIMEOUT
will be delivered and it will deny access for all pending requests due to call ofonAccessDeclinedForClient()
.Solutions
To solve the above bug, one way could be to use an
ArrayMap<String, LogAccessClient> mLogAccessClients
to storeLogAccessClient
instances with the keyuid + ":" + packageName
. A new instance should only be created inonLogAccessRequested()
if one does not exist with a call togetExistingOrNewClientForRequest()
. All other methods should callgetExistingClient*()
to get existing client from theArrayMap
instead of generating a new one. The client can then be removed frommLogAccessClients
inonAccessStatusExpired()
along with its status frommLogAccessStatus
. If access is allowed till next reboot,mLogAccessClients
andmLogAccessStatus
would grow to the size of all apps allowed access, but it would normally only be a few, so shouldn't be a problem.Discussion
With the currently implemented "design decisions" and usability issues, an app not being able to request access from background even with a foreground service, being denied access automatically if dialog was accidentally denied/dismissed for the next shizuku , only one app needs to be granted wireless adb access at boot and it can then give access to others. The tasker app in its recent beta has already added support to use
60s
(or currently many minutes due to bug), having to request access whenever app process is killed and restarted instead of once per boot, like due to OOM or OEM aggressive killing which would specially be a concern on low memory devices... All these things will just push users to give apps access toadb
on every reboot orroot
access forlogcat
commands to function with ease, which is obviously much worse from a security point of view since those accesses have much higher privileges. With apps likev6.1.3-beta
adb
orroot
forlogcat
commands because of issues with current design.I can support the decision that a dialog should be shown before granting access, but users should definitely have an option to grant access once per boot, even if its not enabled by default. There could be secure setting for the
STATUS_EXPIRATION_TIMEOUT_MILLIS
for allowed access timeout. An app with just theREAD_LOGS
permission won't be able to modify the setting and a user can manually set a value of-1
to allow access till next boot or positive value for some defined timeout other than60s
. Can also add a button in the dialog itself that will allow access till next reboot per app, which would obviously be better since user will get to decide which app gets till next boot access and which one only for a specified seconds.There should ideally be a setting for the
STATUS_EXPIRATION_TIMEOUT_MILLIS
for denied access timeout, so that users who don't want to wait60s
before being shown a dialog can do so.Xposed Module
To solve the design issues and the bugs, I have created the xposed module for rooted users that can be run with and that hooks into
XLogcatManager
Magisk
LSPosed
LogcatManagerService
andLogAccessDialogActivity
methods. This will also allow rooted users to not have to grantadb
orroot
access to apps that shouldn't require it just to read logs.Current features are listed below. Further configuration options can be added in future when I get time.
60s
.60s
timeout to reshow dialog if access was (accidentally) denied by user.XLogcatManagerService.java
XLogAccessDialogActivity.java
Device Info
Software
OS_VERSION:
5.15.41-android13-8-00205-gf1bf82c3dacd-ab8747247
SDK_INT:
33
RELEASE:
13
ID:
TPB4.220624.004
DISPLAY:
sdk_gphone64_x86_64-userdebug 13 TPB4.220624.004 8808248 dev-keys
INCREMENTAL:
8808248
SECURITY_PATCH:
2022-07-05
IS_DEBUGGABLE:
1
IS_EMULATOR:
1
IS_TREBLE_ENABLED:
true
TYPE:
userdebug
TAGS:
dev-keys
Hardware
MANUFACTURER:
Google
BRAND:
google
MODEL:
sdk_gphone64_x86_64
PRODUCT:
sdk_gphone64_x86_64
BOARD:
goldfish_x86_64
HARDWARE:
ranchu
DEVICE:
emu64xa
SUPPORTED_ABIS:
x86_64, arm64-v8a