repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
inputmethodservice-ime-abuse.mdMarkdown99 lines4.8 KiBsource raw download

title: "Android IME / InputMethodService Abuse (Malicious Keyboards)" section: "Mobile" sectionSlug: "mobile-pentesting" sourcePath: "src/mobile-pentesting/android-app-pentesting/inputmethodservice-ime-abuse.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/mobile-pentesting/android-app-pentesting/inputmethodservice-ime-abuse.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Android IME / InputMethodService Abuse (Malicious Keyboards)#

Overview#

Android allows third-party keyboards through InputMethodService (IME). Once a user enables a keyboard and selects it as the current input method, it participates in text entry across apps and can observe or influence much of the text sent through its input connection. Password fields can request reduced learning/suggestions, but applications must not treat an enabled third-party IME as a trusted boundary.[1][2]

This is why some Android banking trojans bundle or enable a custom keyboard: the malicious IME can receive keystrokes from target apps that never embed a WebView, including banking, chat, and wallet applications.[4]

[!NOTE] android.permission.BIND_INPUT_METHOD is declared on the IME service so only the system can bind to it. Declaring it does not grant the app blanket access by itself; the key step is getting the victim to enable and select the keyboard in Settings.[1]

Manifest declaration#

A keyboard is exposed via a service with the android.view.InputMethod intent action and an IME configuration XML:

<!-- AndroidManifest.xml -->
<service
    android:name=".SpyKeyboard"
    android:permission="android.permission.BIND_INPUT_METHOD"
    android:exported="false">

    <intent-filter>
        <action android:name="android.view.InputMethod" />
    </intent-filter>

    <meta-data
        android:name="android.view.im"
        android:resource="@xml/spy_ime" />
</service>

Hunting tip: a non-keyboard-looking app that declares an InputMethodService is a strong red flag.

Where the data comes from#

At runtime an IME learns:

Minimal (non-functional) sketch of the high-signal hook point:

public class SpyKeyboard extends InputMethodService {
  @Override public void onStartInput(EditorInfo attribute, boolean restarting) {
    // attribute.packageName identifies the foreground app receiving input
  }
}

Common enablement & collection workflow (observed in the wild)#

How to detect / triage#

On-device checks#

adb shell dumpsys input_method
adb shell ime list -a
adb shell ime help

Static triage of an APK#

Mitigations#

References#