termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

Handle sensitive information with termux-clipboard-set or another command

Open sudomain opened this issue 5 years ago • 7 comments

Feature description

The Android clipboard is insecure for sensitive data. If one wanted to handle sensitive data in Termux (for instance by using the pass package), they may use termux-clipboard-set as a means of moving the data to another app. It would be great if there was a more secure way of Termux sending sensitive data to other apps, especially since the inclusion of the pass password manager implies Termux can be used with sensitive data.

Possible solution:

Copying: The data can be read from stdin or piped into a new Termux-api command; termux-copy-sensitive and temporarily stored in Termux (not the system clipboard)

Pasting to another app:

  1. the autofill framework. This would required Termux:API to be manually enabled as an accessibility service
  2. Have Termux:API act as a new keyboard/input method with a button to "paste" the data that was previously "copied" using termux-copy-sensitive.

I took both solutions from the README of the repo I previously linked to

Reference implementation I don't use these password managers, but the README also mentions LastPass and 1Password. It says both apps implement the autofill and custom keyboard/input methods

Have you checked if the feature is accessible through the Android API? Yes Do you know of other open-source apps that has a similar feature as the one you want? (Provide links) Found out about one a few days after opening this issue. See below

sudomain avatar Mar 07 '20 18:03 sudomain

regarding the question of:

Do you know of other open-source apps that has a similar feature as the one you want?

KeePassDX is an Android password manager that uses autofill for oreo and higher. It also can act as a keyboard input (called "Magikeyboard") to bypass the system clipboard for sensitive info like passwords

sudomain avatar Mar 14 '20 01:03 sudomain

I use KeePassDX, usually with its custom keyboard/IME.

Grossdm avatar Mar 31 '20 18:03 Grossdm

I do use pass, whilst it does clear the clipboard after any amount of time (default is 30 seconds, mine is 15) making it safer, its not completely secure, I too would love to see auto-fill! since adding one of the features in my turmux-url-opener (it does some sed/awk-fu on the URL to grab its domain, e.g 'github' and if this value is contained in pass ls, it shows an extra entry offering to copy it to the clipboard with pass -c github/youtube/discord etc etc) along with pass-otp I have stopped using GUi password managers, the ONLY thing I miss is auto-fill.

nerd190 avatar Oct 05 '20 13:10 nerd190

Android 13 is now showing termux-clipboard-set data on screen which makes it even less suitable.

For now if a -s flag could be added to use "setText" instead of "setPrimaryClip" I think that would at least suppress the on screen display. I don't see an option in ClipData.

Dmole avatar Sep 20 '22 13:09 Dmole

Android 13 is now showing termux-clipboard-set data on screen which makes it even less suitable.

There should be an option to disable it in Android Settings > Privacy > Show Clipboard Access or related.

Both those calls are internally same and former is deprecated.

https://cs.android.com/android/platform/superproject/+/android-13.0.0_r3:frameworks/base/core/java/android/content/ClipboardManager.java;l=274;bpv=0

agnostic-apollo avatar Sep 20 '22 14:09 agnostic-apollo

Android Settings > Privacy > Show Clipboard Access

No that setting is not working.

https://developer.android.com/reference/android/content/ClipDescription#EXTRA_IS_SENSITIVE

would be the way to make a per use option

termux-clipboard-set -s ":)"

Dmole avatar Sep 20 '22 14:09 Dmole

https://developer.android.com/reference/android/content/ClipDescription#EXTRA_IS_SENSITIVE

Adding this extra does not change clipboard behavior or add additional security to the ClipData. Its purpose is essentially a rendering hint from the source application, asking that the data within be obfuscated or redacted, unless the user has taken action to make it visible.

The option could be added, but not for security.

agnostic-apollo avatar Sep 20 '22 15:09 agnostic-apollo