Skip to content

Commit 995a83d

Browse files
authored
Merge pull request #19 from talsec/add_obfuscationIssues_check
Add obfuscation issues check
2 parents 9367326 + acf917c commit 995a83d

File tree

14 files changed

+125
-654
lines changed

14 files changed

+125
-654
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ android.iml
4444
#
4545
example/ios/Pods
4646

47+
# lock file
48+
example/ios/Podfile.lock
49+
4750
# Ruby
4851
example/vendor/
4952

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# freeRASP 3.0.0
2+
3+
### Android
4+
5+
- ❗ BREAKING CHANGE: Raised minimum supported Android version to 6.0 (API level 23)
6+
- ✔️ Removed deprecated BouncyCastle dependency that could cause [errors in the build phase](https://github.com/talsec/Free-RASP-ReactNative/issues/13)
7+
- ✔️ Fixed issue that could cause NullPointerException
8+
- 🆕 Added new `obfuscationIssues` check, which is triggered when freeRASP doesn't detect any obfuscation of the source code
9+
10+
### iOS
11+
12+
- ⚠️ `passcodeChange` check has been deprecated
13+
- 🛠️ Refactored the code base
14+
115
# freeRASP 2.0.3
216

317
### iOS

README.md

Lines changed: 61 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,19 @@ or
9494

9595
### Android
9696

97-
_All dependencies of freeRASP for Android are resolved automatically._
97+
freeRASP for Android requires a minimum **SDK** level of **23**. React Native projects, by default, support even lower levels of minimum SDK. This creates an inconsistency we must solve by updating the minimum SDK level of the application:
98+
99+
1. From the root of your project, go to **android > build.gradle**.
100+
1. In **buildscript**, update **minSdkVersion** to at least **23** (Android 6.0) or higher.
101+
102+
```groovy
103+
buildscript {
104+
ext {
105+
minSdkVersion 23
106+
...
107+
}
108+
}
109+
```
98110

99111
### iOS
100112

@@ -222,9 +234,9 @@ const actions = {
222234
deviceID: () => {
223235
console.log('deviceID');
224236
},
225-
// iOS only
226-
passcodeChange: () => {
227-
console.log('passcodeChange');
237+
// Android only
238+
obfuscationIssues: () => {
239+
console.log('obfuscationIssues');
228240
},
229241
};
230242

@@ -273,23 +285,15 @@ _You can override this default behavior by extending the `actions` object with `
273285

274286
## Step 5: Additional note about obfuscation
275287

276-
The freeRASP contains public API, so the integration process is as simple as possible. Unfortunately, this public API also creates opportunities for the attacker to use publicly available information to interrupt freeRASP operations or modify your custom reaction implementation in threat callbacks. In order for freeRASP to be as effective as possible, it is highly recommended to apply obfuscation to the final package/application, making the public API more difficult to find and also partially randomized for each application so it cannot be automatically abused by generic hooking scripts.
288+
The freeRASP contains public API, so the integration process is as simple as possible. Unfortunately, this public API also creates opportunities for the attacker to use publicly available information to interrupt freeRASP operations or modify your custom reaction implementation in threat callbacks. In order to provide as much protection as possible, freeRASP obfuscates its source code. However, if all other code is not obfuscated, one can easily deduct that the obfuscated code belongs to a security library. We, therefore, encourage you to apply code obfuscation to your app, making the public API more difficult to find and also partially randomized for each application so it cannot be automatically abused by generic hooking scripts.
277289

278-
### Android
290+
Probably the easiest way to obfuscate your app is via code minification, a technique that reduces the size of the compiled code by removing unnecessary characters, whitespace, and renaming variables and functions to shorter names. It can be configured for Android devices in **android/app/build.gradle** like so:
279291

280-
The majority of Android projects support code shrinking and obfuscation without any additional need for setup. The owner of the project can define the set of rules that are usually automatically used when the application is built in the release mode. For more information, please visit the official documentation
281-
282-
- https://developer.android.com/studio/build/shrink-code
283-
- https://www.guardsquare.com/manual/configuration/usage
284-
285-
You can make sure, that the obfuscation is enabled by checking the value of **minifyEnabled** property in your **module's build.gradle** file.
286-
287-
```gradle
292+
```groovy
288293
android {
289-
...
290-
291294
buildTypes {
292295
release {
296+
...
293297
minifyEnabled true
294298
shrinkResources true
295299
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -298,6 +302,15 @@ android {
298302
}
299303
```
300304

305+
Please note that some other modules in your app may rely on reflection, therefore it may be necessary to add corresponding keep rules into proguard-rules.pro file.
306+
307+
If there is a problem with the obfuscation, freeRASP will notify you about it via `obfuscationIssues` callback.
308+
309+
You can read more about Android obfuscation in the official documentation:
310+
311+
- https://developer.android.com/studio/build/shrink-code
312+
- https://www.guardsquare.com/manual/configuration/usage
313+
301314
## Step 6: User Data Policies
302315

303316
See the generic info about freeRASP data collection [here](https://github.com/talsec/Free-RASP-Community/tree/master#data-collection-processing-and-gdpr-compliance).
@@ -400,25 +413,25 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
400413
<td colspan=5><strong>Runtime App Self Protection (RASP, app shielding)</strong></td>
401414
</tr>
402415
<tr>
403-
<td>Advanced root/jailbreak protections</td>
416+
<td>Advanced root/jailbreak protections (including Magisk)</td>
404417
<td>basic</td>
405418
<td>advanced</td>
406419
</tr>
407420
<tr>
408-
<td>Runtime reverse engineering controls
421+
<td>Runtime reverse engineering controls
409422
<ul>
410-
<li>Debug</li>
411-
<li>Emulator</li>
412-
<li>Hooking protections (e.g. Frida)</li>
423+
<li>Debugger</li>
424+
<li>Emulator / Simulator</li>
425+
<li>Hooking and reversing frameworks (e.g. Frida, Magisk, XPosed, Cydia Substrate and more)</li>
413426
</ul>
414427
</td>
415428
<td>basic</td>
416429
<td>advanced</td>
417430
</tr>
418431
<tr>
419-
<td>Runtime integrity controls
432+
<td>Runtime integrity controls
420433
<ul>
421-
<li>Tamper protection</li>
434+
<li>Tampering protection</li>
422435
<li>Repackaging / Cloning protection</li>
423436
<li>Device binding protection</li>
424437
<li>Unofficial store detection</li>
@@ -428,20 +441,22 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
428441
<td>advanced</td>
429442
</tr>
430443
<tr>
431-
<td>Device OS security status check
444+
<td>Device OS security status check
432445
<ul>
433446
<li>HW security module control</li>
434447
<li>Screen lock control</li>
448+
<li>Google Play Services enabled/disabled</li>
449+
<li>Last security patch update</li>
435450
</ul>
436451
</td>
437452
<td>yes</td>
438453
<td>yes</td>
439454
</tr>
440455
<tr>
441-
<td>UI protection
456+
<td>UI protection
442457
<ul>
443458
<li>Overlay protection</li>
444-
<li>Accessibility services protection</li>
459+
<li>Accessibility services misuse protection</li>
445460
</ul>
446461
</td>
447462
<td>no</td>
@@ -451,12 +466,11 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
451466
<td colspan=5><strong>Hardening suite</strong></td>
452467
</tr>
453468
<tr>
454-
<td>Security hardening suite
455-
<ul>
456-
<li>Customer Data Encryption (local storage)</li>
469+
<td>Security hardening suite
470+
<ul>
457471
<li>End-to-end encryption</li>
458472
<li>Strings protection (e.g. API keys)</li>
459-
<li>Dynamic certificate pinning</li>
473+
<li>Dynamic TLS certificate pinning</li>
460474
</ul>
461475
</td>
462476
<td>no</td>
@@ -471,33 +485,41 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
471485
<td>yes</td>
472486
</tr>
473487
<tr>
474-
<td colspan=5><strong>Monitoring</strong></td>
488+
<td colspan=5><strong>Security events data collection, Auditing and Monitoring tools</strong></td>
475489
</tr>
476490
<tr>
477-
<td>AppSec regular email reporting</td>
491+
<td>Threat events data collection from SDK</td>
492+
<td>yes</td>
493+
<td>configurable</td>
494+
</tr>
495+
<tr>
496+
<td>AppSec regular email reporting service</td>
478497
<td>yes (up to 100k devices)</td>
479498
<td>yes</td>
480499
</tr>
481500
<tr>
482-
<td>Data insights and auditing portal</td>
501+
<td>UI portal for Logging, Data analytics and auditing</td>
483502
<td>no</td>
484503
<td>yes</td>
485504
</tr>
505+
<tr>
506+
<td colspan=5><strong>Support and Maintenance</strong></td>
507+
</tr>
486508
<tr>
487-
<td>Embed code to integrate with portal</td>
488-
<td>no</td>
509+
<td>SLA</td>
510+
<td>Not committed</td>
489511
<td>yes</td>
490512
</tr>
491513
<tr>
492-
<td>API data access</td>
493-
<td>no</td>
514+
<td>Maintenance updates</td>
515+
<td>Not committed</td>
494516
<td>yes</td>
495517
</tr>
496518
<tr>
497-
<td colspan=5><strong>Fair usage policy</strong></td>
519+
<td colspan=5><strong>Fair usage policy</strong></td>
498520
</tr>
499521
<tr>
500-
<td>Mentioning of the App name and logo in the marketing communications of Talsec (e.g. "Trusted by" section of the Talsec web or in the social media).</td>
522+
<td>Mentioning of the App name and logo in the marketing communications of Talsec (e.g. "Trusted by" section on the web).</td>
501523
<td>over 100k downloads</td>
502524
<td>no</td>
503525
</tr>

android/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@ def getExtOrIntegerDefault(name) {
3333
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["FreeraspReactNative_" + name]).toInteger()
3434
}
3535

36+
def getIntegerDefault(name) {
37+
return (project.properties["FreeraspReactNative_" + name]).toInteger()
38+
}
39+
3640
android {
3741
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
3842

3943
defaultConfig {
40-
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
44+
minSdkVersion getIntegerDefault("minSdkVersion")
4145
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
4246
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
4347
}
4448
buildTypes {
4549
release {
46-
minifyEnabled false
50+
minifyEnabled true
4751
}
4852
}
4953

@@ -78,7 +82,7 @@ dependencies {
7882
//noinspection GradleDynamicVersion
7983
implementation "com.facebook.react:react-native"
8084
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
81-
implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-ReactNative:7.0.0"
85+
implementation "com.aheaditec.talsec.security:TalsecSecurity-Community-ReactNative:8.0.1"
8286
}
8387

8488
if (isNewArchitectureEnabled()) {

android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FreeraspReactNative_kotlinVersion=1.7.0
2-
FreeraspReactNative_minSdkVersion=21
2+
FreeraspReactNative_minSdkVersion=23
33
FreeraspReactNative_targetSdkVersion=31
44
FreeraspReactNative_compileSdkVersion=31
55
FreeraspReactNative_ndkversion=21.4.7075529

android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class FreeraspReactNativeModule(val reactContext: ReactApplicationContext) :
7979
sendOngoingPluginResult("deviceBinding", null)
8080
}
8181

82+
override fun onObfuscationIssuesDetected() {
83+
sendOngoingPluginResult("obfuscationIssues", null)
84+
}
85+
8286
override fun deviceStateChangeDetected(threatType: String) {
8387
sendOngoingPluginResult(threatType, null)
8488
}

example/android/app/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def enableSeparateBuildPerCPUArchitecture = false
9797
/**
9898
* Run Proguard to shrink the Java bytecode in release builds.
9999
*/
100-
def enableProguardInReleaseBuilds = false
100+
def enableProguardInReleaseBuilds = true
101101

102102
/**
103103
* The preferred build flavor of JavaScriptCore.
@@ -226,7 +226,15 @@ android {
226226
// Caution! In production, you need to generate your own keystore file.
227227
// see https://reactnative.dev/docs/signed-apk-android.
228228
signingConfig signingConfigs.debug
229+
// Enables code shrinking, obfuscation, and optimization for only
230+
// your project's release build type. Make sure to use a build
231+
// variant with `debuggable false`.
229232
minifyEnabled enableProguardInReleaseBuilds
233+
// Enables resource shrinking, which is performed by the
234+
// Android Gradle plugin.
235+
shrinkResources true
236+
// Includes the default ProGuard rules files that are packaged with
237+
// the Android Gradle plugin.
230238
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
231239
}
232240
}

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
buildscript {
44
ext {
55
buildToolsVersion = "31.0.0"
6-
minSdkVersion = 21
6+
minSdkVersion = 23
77
compileSdkVersion = 31
88
targetSdkVersion = 31
99

0 commit comments

Comments
 (0)