Take Back Your Clipboard Privacy

Posted on:

Android 12 has a few newly added privacy features, including the Clipboard Access Warning. When turned on, it shows a notification every time an app reads your clipboard.

App pasted from your clipboard

If you have turned it on manually, depending on what kinds of app you have, you might realize that:

Why do some apps read my clipboard when they’re not supposed to?

You probably know the fact that many apps read your clipboard without your consent. Well, I definitely know about that, but didn’t pay much attention to it.

With the alert popping up once in a while, however, that changed.

Let’s end this by blocking those pesky apps from accessing your clipboard, once and for all.

Permissions

We’re interested in these two permissions:READ_CLIPBOARD and WRITE_CLIPBOARD, both defaulting to allow

Why would apps be allowed to access your clipboard by default if Android cares about your privacy, you might ask.

The answer is simple: Android’s Clipboard Framework does not differentiate between access initiated by user interaction, and app snooping around without your consent.

The floating menu that appears when you press on a text input, is probably implemented by the app itself.

Wechat's custom floating menu
Does this contribute to anything? Not really.

And if you want to copy & paste in an app like you normally would, you need to grant those permissions. Then the app could do whatever it wants.

Some shitty apps use this for cross-application tracking, which uses your clipboard for communications. This is more disgusting than just reading your clipboard.

Trash in my clipboard

I’ll just not let them write to my clipboard then.

Revoking permissions with adb

I assume that you already have adb installed. Check the official docs for more information.

First, let’s take a look at apps that have the READ_CLIPBOARD permission:

❯ adb shell cmd appops query-op --user 0 READ_CLIPBOARD allow

com.sec.android.app.desktoplauncher
com.google.android.apps.maps
...100 lines

I don’t have many apps installed on this device.

Revoking:

adb shell cmd appops set "com.example.app" READ_CLIPBOARD ignore

Replace the package name with your own.

I played with this one-liner here, which might be helpful if you have a bunch of apps to ban:

echo "Type in one app name on each line, then send EOF(ctrl+D twice)";echo "$(</dev/stdin)" | xargs -I {} adb shell cmd appops set {} READ_CLIPBOARD ignore

And that’s about it.

Note

After revoking READ_CLIPBOARD, you will no longer be able to paste in this app. Although this could be bypassed by using the History function in your IME. This could be really helpful if you still need to paste something occasionally.

Without WRITE_CLIPBOARD, you cannot copy any text. I didn’t find a workaround for this.

the &quot;copied to clipboard&quot; toast
This toast is not by Android, and no, you can’touch my clipboard ever again