-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADB 'connect' command may trigger a device to be owned by the user! #971
Comments
@denis99999 your fix make my day! I merged your code into the device component, which resolved the re-connect problem during test automation(we implemented a similar auto-reconnt mechnism in test agent). @sorccu suggest to merge the code into master branch, it will fix a security problem more or less. |
@thinkhy, thanks a lot !!! |
FYI it functions like that on purpose. If you connect to a device that is not being used, but you have an adb key registered, the device automatically becomes yours. This is not a security issue because the user’s adb key is verified during the handshake. If you attempt to connect to a device that is being used by someone else, or you have not registered your adb key, you do not get in. |
Hi @sorccu , is it mean you will not include this fix into the master branch ? |
make sense, but consider the following scenario:
|
The public key is not enough. During the handshake a challenge is represented and it must be signed by the private key of that public key. The result is then verified. If someone takes the adb private key from e.g. a CI server, then yeah they can get in - but if they have that much access they probably could’ve used some other way to get in, too. |
The reconnection issue isn’t great though. We might have to remove this feature just because of that. I’m just saying that it originally had a purpose. |
Ok @sorccu, so do I understand you accept this fix although it does not fix a security issue ? |
I would suggest creating a pull request. Then it would be easier to review. |
Yes @sorccu you are right I will create a pull request when I can, waiting for that let me explain hereafter why I feel it is important to merge this fix to the master branch. I feel actually this issue is both a functional and consistency one, but perhaps in the future it could become a security issue in case of the adding of new high level features as a booking system for instance. Functional issueAs described in my opening remarks, when a user - let us name him Bob - ADB connects to a device, he takes automatically the control of the device permanently, despite the releasing of the device through the UI, the API or an automatic timeout. So, let us imagine Bob forgets to ADB disconnect from the device and then go on vacation, the only solutions for the admin to be sure to release the device are then the following:
So, I feel from a functional point of view that STF should not meet such situation. Consistency issueI talk about consistency because the ADB connect action depends on the prior knowledge of the Moreover, the user has no right to assume that the Another inconsistency actually is that an authenticated ADB connection to a device triggers the owning of the device, but the corresponding ADB disconnection from the device does not release the device. In synthesis, my general feeling is that ADB should be authorized to connect to a device if and only if the STF user (i.e. which has registered the corresponding ADB key), is currently owning the device and has opened the listen port (i.e. using UI or API), otherwise the attempt of connection should fail. In the same way, the releasing of a device through the UI, the API or an automatic timeout, while an ADB connection is currently established, should not only close the connection but also close the listen port so as to forbid a subsequent attempt of connection from ADB. This is why I proposed this fix with the main goal to ensure these strict conditions:
So, for example using API, a typical sequence of actions a user should perform to ADB connect to a device should be:
and, a typical sequence of actions a user should perform to ADB disconnect from a device and release it should be:
To ensure the provider does not open the listen port of each device worker at starting stage, I made an additional change in the connect plugin:
Security issue (perhaps in the future)Actually, as said by @sorccu there is no security issue because the ADB connection is authenticated. Nevertheless, this proposal which forces the prerequisite owning of the device before to access it through ADB could be also a prerequisite to host inside STF some value added features relying on a strict control of the access to the devices. For instance, let us imagine a booking system allowing a user named Bob to reserve the Ok, but what will happen if another user named Lea decides anyway at this date to ADB connect to So, in conclusion, I feel that enforcing the access control to the devices is not only a benefit for STF consistency, it is also probably a prerequisite to leverage the adding of value added features into the amazing STF tool. |
@denis99999 any change to push PR for reviewing ? @sorccu is there unit/integration tests which verify current functionality related original behaviour ? |
Hi @jupe , |
hi @denis99999 |
Hi @amrkamel1 , Yes, internally in our private STF platform ! But very soon (i.e. probably this day or this week) we (i.e. I and @pcrepieux) will update our Orange Open Source repository in order to have a ready to use solution integrating all our value-added features as Android 10 support and Booking/partitioning system. |
Hi @amrkamel1 ,
Hope this helps |
Guys congrats thats awesome job, will add great value to the platform cant wait to test it and use it very happy for these news |
So all what i have to do is just pull group-feature branch, run npm install,rm rethinkdb ,install manually the new STFService.apk ? What else i should do? |
Hi @amrkamel1 , Not exactly, what @pcrepieux said is now the master branch of our Orange SA repository (i.e. https://github.com/Orange-OpenSource/stf/tree/master) is a ready to use solution integrating all our value-added features as Android 10 support and Booking/partitioning system, so you have just to pull this master branch! |
Great got you, about the new STFService.apk should i install it manually on each device or its already going to embedded within the master branch and gonna be installed automatically during preparing process |
Yes, as said previously, you have just to pull the master branch, the new STFService.apk is inside and it is automatically installed onto the devices! |
Great thx |
@denis99999 , @pcrepieux tried with samsung S8 android 9 it works fine, im still able to run the apk manually then connected to STF by running these commands
Any idea why its happening with this particular device |
@amrkamel1, |
@pcrepieux but there is another issue is happening not so major but will be good if its fixed, when you plugged the android device to the usb port some notification pops up "Allow access to phone data " , if you click allow or deny the session will be terminated and the device will be disconnected this wasnt happening as far i remember with the previous version |
The repository has been updated, can you try it to see if it fixes your issue ? |
@denis99999 but encountered issue with xiaomi android 9 it doesn't show any screen monitoring its blank i have reported an issue for that with all details and logs |
@amrkamel1 yes on master branch! |
@denis99999 hi denis thanks for the fix for rotating icon |
@denis99999 @pcrepieux Hi, I see on oneplus models while landscape mode click events are not working, only in portrait mode it works |
@amrkamel1 r u not facing the above issue when in landscape mode. even i tried on pixel also same prob click events not working. |
Will check this scenario and let u know |
@shridharkabbur, @amrkamel1 |
@pcrepieux UPDATE : |
screen rotation should now be properly handled for touch events (fixed in STFService.apk) |
thanks @pcrepieux screen orientation working.. |
@pcrepieux also find device icon in the info tab in not functioned any more |
@amrkamel1 yup you are right its not working. |
Yep, it currently only support single touch events. As you have mentionned it, I just worked on it and got it working on a development branch. Should update it shortly. Stay tuned. |
An apk for testing purpose can be downloaded here |
@pcrepieux |
What is the issue or idea you have?
If the remote debug URL of a device is known while this device is free that is owned by no one, a STF user, that is an authenticated one, may run an
adb connect
command on this URL which triggers the acquisition of control of this device by this user.This behaviour is abnormal and is compounded by the latest version of ADB (
1.0.40 Version 4986621
) which comes with this new feature:resulting to an automatic owning of the device every time the user try to release the device either through the
Stop Using
button or the API or automatic timeout (i.e. which all disconnect the TCP connection), until the user kills theadb server
or runs anadb disconnect
command on this URL.The worst part is that in case of a STF machine restarting, the TCP port of the
Remote debug URL
may change for the considered device, and even can be assigned to another device of the samestf-provider,
leading the automatic connection to be made to the latter, I have seen this behaviour by making tests.Does it only happen on a specific device? Please run
adb devices -l
and paste the corresponding row.no device specific.
Please provide the steps to reproduce the issue.
What is the expected behavior?
At step 2 above, ADB should return an error like :
What is your proposal?
In fact, I felt some problems in the code:
So, for test purpose only, I have made some simple changes in a test branch (i.e. see below), and I have tested it with success, I hope that will help you to bring the complete and final changes into the master branch.
Nevertheless, using the latest version of ADB, a little problem remains as described hereafter:
So, perhaps only authorized ADB connections should be logged ?
Do you see errors or warnings in the
stf local
output? If so, please paste them or the full log here.N/A
Please run
stf doctor
and paste the output here.debian@debian:~/stf-master$ stf doctor
The text was updated successfully, but these errors were encountered: