🤖Android

circle-info

Let your AI assistant (Cursor, Claude, Gemini, Codex) add freeRASP into your app (experimental): AI-Assisted Integration

📝 Prerequisites

freeRASP requires a minimum SDK level of 23. To update the minimum SDK level of the application, follow these steps:

  1. From the root of your project (or module level), go to the build.gradle.

  2. Update minSdkVersion to at least 23 (Android 6.0) or higher.

build.gradle
buildscript {
    ext {
      minSdkVersion 23
    }
}

Add permissions for checks

Some checks require additional permissions in order to work properly. If your app already has these permissions, you don't need to add them again.

Screenshot and Screen Recording Detection

To detect screenshots and screen recordings , add the following permissions to your AndroidManifest.xml file inside the <manifest> root tag:

<uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />
<uses-permission android:name="android.permission.DETECT_SCREEN_RECORDING" />
circle-exclamation

Location Spoofing Detection

To detect location spoofing, add the following permissions to your AndroidManifest.xml file inside the <manifest> root tag:

Unsecure WiFi Detection

To detect unsecure WiFi, add the following permissions to your AndroidManifest.xml file inside the <manifest> root tag:


📦 Add the dependency

Set Talsec's Artifact Registry in your project's settings.gradle (or build.gradle). You should comment out the relevant section in settings.gradle, if you want to use build.gradle, as settings.gradle is preferred:

Config via settings.gradle:

Config via build.gradle:

circle-exclamation

Set dependencies in your :app module's build.gradle:


⚙️ Setup the Configuration for your App

To ensure freeRASP functions correctly, you need to provide the necessary configuration. All required values must be filled in for the plugin to operate properly. Use the following template to configure the plugin. Detailed descriptions of the configuration options are provided on the API page.

  1. To guarantee protection starts immediately, initialize freeRASP inside the onCreate method of your Application subclass. If you don't have a custom Application class, create one extending Application:

  2. Add a new subclass to AndroidManifest.xml, inside <application> tag:

  3. Set up the Configuration for your app with your values, which are explained in more detail in API.

circle-info

Configuration Parameters

  • isProd - a boolean flag that determines whether the freeRASP integration is in the Dev or Release version. If you want to learn more about isProd, visit this wiki section.

  • killOnBypass - a boolean flag that enables the freeRASP in-SDK reaction to kill the application if it detects any unwanted manipulation with the callback mechanisms.

  • watcherMail - By providing your watcherMail, you consent to receive security reports, product updates, and other essential communications from Talsec. Learn more about the role of watcherMail.


👷 Handle detected threats

You can handle the detected threats using listeners. For example, you can log the event, show a window to the user or kill the application. See the Threat detection to learn more details about the performed checks and their importance for app security.

  1. Create a ThreatListener.ThreatDetected object and override the methods you want to handle. You don't need to override all methods; only implement the ones relevant to your app's security policy.

    circle-info
    • If you encounter issues importing ThreatListener.ThreatDetected, please use 'Sync Project with Gradle Files' to resolve them.“

    • For the onMalwareDetected(suspiciousApps: List<SuspiciousAppInfo>) callback, make sure you visit freeMalwareDetectionarrow-up-right, a powerful feature designed to scan for malicious or suspicious apps.

  2. Optionally, you can use a device state listener to get additional information about the device state, like passcode lock and HW-backed Keystore state:

  3. Optionally, you can use the RaspExecutionState listener, to get information about state of check execution:

  4. Modify initialization of ThreatListener:

  5. (Optional) Screen Capture & Recording Protection:

    • You can use freeRASP to detect screenshots (onScreenshotDetected), screen recordings (onScreenRecordingDetected).

    • To actively prevent capture entirely (resulting in a black screen), use Talsec.blockScreenCapture(activity, true). You can verify the blocking status using Talsec.isScreenCaptureBlocked(). For more details, see Screen Capture.

    • Prerequisites: Detection features require Android 14+ (Screenshots) or Android 15+ (Recordings) and specific permissions. Please ensure you have added them as described in the Add permissionsarrow-up-right section.

    • Implementation: We recommend integrating these methods at the Application level using ActivityLifecycleCallbacks to ensure they cover the entire app lifecycle:

circle-info

ScreenProtector You can detect when a screenshot or recording occurs without blocking it, which is useful for auditing or specific security reactions. The ScreenProtector utility automatically handles Android API level checks (Android 14+ for screenshots, Android 15+ for recordings).


🛡️ Start freeRASP

circle-info

We recommend starting Talsec with TalsecMode.BACKGROUND to prevent performance impacts in the application.


🌁 Enable source code obfuscation

You can make sure that the obfuscation is enabled by checking the value of minifyEnabled property in your module's build.gradle file.

Read more about why this is important in the wiki.


🆔 (Optionally) Set External ID

The externalId allows you to send a custom identifier (such as a User ID) to the Talsec Portalarrow-up-right. This identifier will be visible in the Dashboard, enabling you to correlate security incidents with specific users in your system.

circle-info

Requirements

  • Allowed characters: Only alphanumeric characters (a-z, A-Z, 0-9) and the following special characters: +, _, -, /, :, =.

  • If the ID contains any other characters, the method returns ExternalIdResult. Error and the value is not stored.


☢️ (Optionally) Integrate freeMalwareDetection

freeMalwareDetection is a powerful feature designed to enhance the security of your Android application by quickly and efficiently scanning for malicious or suspicious applications (e.g. Android malware) based on various blacklists and security policies.

It helps to detect apps with suspicious package names, hashes, or potentially dangerous permissions.

Visit the freeMalwareDetectionarrow-up-right repository to learn more about this feature! For the integration, refer to the integration guidearrow-up-right for the Android platform.


🖥️ Check Talsec Portal

Check out Data Visualisation Portal and register using your watcherMail to see your data. If you integrated the SDK successfully, the application will be present after a few hours. The visualisations will be active later due to the bucketing mechanism.

circle-exclamation

Last updated