freerasp-react-native 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +62 -39
  2. package/android/build.gradle +7 -3
  3. package/android/gradle.properties +1 -1
  4. package/android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt +4 -0
  5. package/example/android/app/build.gradle +9 -1
  6. package/example/android/build.gradle +1 -1
  7. package/example/src/App.tsx +5 -5
  8. package/example/src/checks.ts +3 -4
  9. package/ios/FreeraspReactNative.swift +11 -8
  10. package/ios/TalsecRuntime.xcframework/Info.plist +5 -5
  11. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  12. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +122 -47
  13. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Info.plist +0 -0
  14. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.abi.json +5248 -0
  15. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.private.swiftinterface +54 -0
  16. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  17. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios.swiftinterface +3 -1
  18. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/Modules/module.modulemap +2 -2
  19. package/ios/TalsecRuntime.xcframework/ios-arm64/TalsecRuntime.framework/TalsecRuntime +0 -0
  20. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/CurlWrapper.h +1 -1
  21. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Headers/TalsecRuntime-Swift.h +234 -94
  22. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Info.plist +0 -0
  23. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.abi.json +5213 -0
  24. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +54 -0
  25. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  26. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3 -1
  27. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.abi.json +5213 -0
  28. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +54 -0
  29. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  30. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/TalsecRuntime.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +3 -1
  31. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/Modules/module.modulemap +2 -2
  32. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/TalsecRuntime +0 -0
  33. package/ios/TalsecRuntime.xcframework/ios-arm64_x86_64-simulator/TalsecRuntime.framework/_CodeSignature/CodeResources +63 -19
  34. package/lib/commonjs/index.js +3 -0
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/module/index.js +4 -1
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/typescript/index.d.ts +1 -1
  39. package/lib/typescript/index.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/src/index.tsx +5 -1
  42. package/example/ios/Podfile.lock +0 -590
package/README.md CHANGED
@@ -23,6 +23,7 @@ freeRASP for React Native is a mobile in-app protection and security monitoring
23
23
  - [Alternative: Initialize freeRASP in a Class component](#alternative-initialize-freerasp-in-a-class-component)
24
24
  - [Step 5: Additional note about obfuscation](#step-5-additional-note-about-obfuscation)
25
25
  - [Step 6: User Data Policies](#step-6-user-data-policies)
26
+ - [Troubleshooting](#troubleshooting)
26
27
  - [Security Report](#security-report)
27
28
  - [Commercial versions (RASP+ and more)](#bar_chart-commercial-versions-rasp-and-more)
28
29
  - [Plans Comparison](#plans-comparison)
@@ -93,7 +94,19 @@ or
93
94
 
94
95
  ### Android
95
96
 
96
- _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
+ ```
97
110
 
98
111
  ### iOS
99
112
 
@@ -221,9 +234,9 @@ const actions = {
221
234
  deviceID: () => {
222
235
  console.log('deviceID');
223
236
  },
224
- // iOS only
225
- passcodeChange: () => {
226
- console.log('passcodeChange');
237
+ // Android only
238
+ obfuscationIssues: () => {
239
+ console.log('obfuscationIssues');
227
240
  },
228
241
  };
229
242
 
@@ -272,23 +285,15 @@ _You can override this default behavior by extending the `actions` object with `
272
285
 
273
286
  ## Step 5: Additional note about obfuscation
274
287
 
275
- 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.
276
289
 
277
- ### 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:
278
291
 
279
- 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
280
-
281
- - https://developer.android.com/studio/build/shrink-code
282
- - https://www.guardsquare.com/manual/configuration/usage
283
-
284
- You can make sure, that the obfuscation is enabled by checking the value of **minifyEnabled** property in your **module's build.gradle** file.
285
-
286
- ```gradle
292
+ ```groovy
287
293
  android {
288
- ...
289
-
290
294
  buildTypes {
291
295
  release {
296
+ ...
292
297
  minifyEnabled true
293
298
  shrinkResources true
294
299
  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -297,6 +302,15 @@ android {
297
302
  }
298
303
  ```
299
304
 
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
+
300
314
  ## Step 6: User Data Policies
301
315
 
302
316
  See the generic info about freeRASP data collection [here](https://github.com/talsec/Free-RASP-Community/tree/master#data-collection-processing-and-gdpr-compliance).
@@ -399,25 +413,25 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
399
413
  <td colspan=5><strong>Runtime App Self Protection (RASP, app shielding)</strong></td>
400
414
  </tr>
401
415
  <tr>
402
- <td>Advanced root/jailbreak protections</td>
416
+ <td>Advanced root/jailbreak protections (including Magisk)</td>
403
417
  <td>basic</td>
404
418
  <td>advanced</td>
405
419
  </tr>
406
420
  <tr>
407
- <td>Runtime reverse engineering controls
421
+ <td>Runtime reverse engineering controls
408
422
  <ul>
409
- <li>Debug</li>
410
- <li>Emulator</li>
411
- <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>
412
426
  </ul>
413
427
  </td>
414
428
  <td>basic</td>
415
429
  <td>advanced</td>
416
430
  </tr>
417
431
  <tr>
418
- <td>Runtime integrity controls
432
+ <td>Runtime integrity controls
419
433
  <ul>
420
- <li>Tamper protection</li>
434
+ <li>Tampering protection</li>
421
435
  <li>Repackaging / Cloning protection</li>
422
436
  <li>Device binding protection</li>
423
437
  <li>Unofficial store detection</li>
@@ -427,20 +441,22 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
427
441
  <td>advanced</td>
428
442
  </tr>
429
443
  <tr>
430
- <td>Device OS security status check
444
+ <td>Device OS security status check
431
445
  <ul>
432
446
  <li>HW security module control</li>
433
447
  <li>Screen lock control</li>
448
+ <li>Google Play Services enabled/disabled</li>
449
+ <li>Last security patch update</li>
434
450
  </ul>
435
451
  </td>
436
452
  <td>yes</td>
437
453
  <td>yes</td>
438
454
  </tr>
439
455
  <tr>
440
- <td>UI protection
456
+ <td>UI protection
441
457
  <ul>
442
458
  <li>Overlay protection</li>
443
- <li>Accessibility services protection</li>
459
+ <li>Accessibility services misuse protection</li>
444
460
  </ul>
445
461
  </td>
446
462
  <td>no</td>
@@ -450,12 +466,11 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
450
466
  <td colspan=5><strong>Hardening suite</strong></td>
451
467
  </tr>
452
468
  <tr>
453
- <td>Security hardening suite
454
- <ul>
455
- <li>Customer Data Encryption (local storage)</li>
469
+ <td>Security hardening suite
470
+ <ul>
456
471
  <li>End-to-end encryption</li>
457
472
  <li>Strings protection (e.g. API keys)</li>
458
- <li>Dynamic certificate pinning</li>
473
+ <li>Dynamic TLS certificate pinning</li>
459
474
  </ul>
460
475
  </td>
461
476
  <td>no</td>
@@ -470,33 +485,41 @@ freeRASP is freemium software i.e. there is a Fair Usage Policy (FUP) that impos
470
485
  <td>yes</td>
471
486
  </tr>
472
487
  <tr>
473
- <td colspan=5><strong>Monitoring</strong></td>
488
+ <td colspan=5><strong>Security events data collection, Auditing and Monitoring tools</strong></td>
474
489
  </tr>
475
490
  <tr>
476
- <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>
477
497
  <td>yes (up to 100k devices)</td>
478
498
  <td>yes</td>
479
499
  </tr>
480
500
  <tr>
481
- <td>Data insights and auditing portal</td>
501
+ <td>UI portal for Logging, Data analytics and auditing</td>
482
502
  <td>no</td>
483
503
  <td>yes</td>
484
504
  </tr>
505
+ <tr>
506
+ <td colspan=5><strong>Support and Maintenance</strong></td>
507
+ </tr>
485
508
  <tr>
486
- <td>Embed code to integrate with portal</td>
487
- <td>no</td>
509
+ <td>SLA</td>
510
+ <td>Not committed</td>
488
511
  <td>yes</td>
489
512
  </tr>
490
513
  <tr>
491
- <td>API data access</td>
492
- <td>no</td>
514
+ <td>Maintenance updates</td>
515
+ <td>Not committed</td>
493
516
  <td>yes</td>
494
517
  </tr>
495
518
  <tr>
496
- <td colspan=5><strong>Fair usage policy</strong></td>
519
+ <td colspan=5><strong>Fair usage policy</strong></td>
497
520
  </tr>
498
521
  <tr>
499
- <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>
500
523
  <td>over 100k downloads</td>
501
524
  <td>no</td>
502
525
  </tr>
@@ -33,17 +33,21 @@ def getExtOrIntegerDefault(name) {
33
33
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["FreeraspReactNative_" + name]).toInteger()
34
34
  }
35
35
 
36
+ def getIntegerDefault(name) {
37
+ return (project.properties["FreeraspReactNative_" + name]).toInteger()
38
+ }
39
+
36
40
  android {
37
41
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
38
42
 
39
43
  defaultConfig {
40
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
44
+ minSdkVersion getIntegerDefault("minSdkVersion")
41
45
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
42
46
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
43
47
  }
44
48
  buildTypes {
45
49
  release {
46
- minifyEnabled false
50
+ minifyEnabled true
47
51
  }
48
52
  }
49
53
 
@@ -78,7 +82,7 @@ dependencies {
78
82
  //noinspection GradleDynamicVersion
79
83
  implementation "com.facebook.react:react-native"
80
84
  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"
82
86
  }
83
87
 
84
88
  if (isNewArchitectureEnabled()) {
@@ -1,5 +1,5 @@
1
1
  FreeraspReactNative_kotlinVersion=1.7.0
2
- FreeraspReactNative_minSdkVersion=21
2
+ FreeraspReactNative_minSdkVersion=23
3
3
  FreeraspReactNative_targetSdkVersion=31
4
4
  FreeraspReactNative_compileSdkVersion=31
5
5
  FreeraspReactNative_ndkversion=21.4.7075529
@@ -79,6 +79,10 @@ class FreeraspReactNativeModule(val reactContext: ReactApplicationContext) :
79
79
  sendOngoingPluginResult("deviceBinding", null)
80
80
  }
81
81
 
82
+ override fun onObfuscationIssuesDetected() {
83
+ sendOngoingPluginResult("obfuscationIssues", null)
84
+ }
85
+
82
86
  override fun deviceStateChangeDetected(threatType: String) {
83
87
  sendOngoingPluginResult(threatType, null)
84
88
  }
@@ -97,7 +97,7 @@ def enableSeparateBuildPerCPUArchitecture = false
97
97
  /**
98
98
  * Run Proguard to shrink the Java bytecode in release builds.
99
99
  */
100
- def enableProguardInReleaseBuilds = false
100
+ def enableProguardInReleaseBuilds = true
101
101
 
102
102
  /**
103
103
  * The preferred build flavor of JavaScriptCore.
@@ -226,7 +226,15 @@ android {
226
226
  // Caution! In production, you need to generate your own keystore file.
227
227
  // see https://reactnative.dev/docs/signed-apk-android.
228
228
  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`.
229
232
  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.
230
238
  proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
231
239
  }
232
240
  }
@@ -3,7 +3,7 @@
3
3
  buildscript {
4
4
  ext {
5
5
  buildToolsVersion = "31.0.0"
6
- minSdkVersion = 21
6
+ minSdkVersion = 23
7
7
  compileSdkVersion = 31
8
8
  targetSdkVersion = 31
9
9
 
@@ -3,12 +3,12 @@ import * as React from 'react';
3
3
  import { Platform } from 'react-native';
4
4
  import { useFreeRasp } from 'freerasp-react-native';
5
5
  import { DemoApp } from './DemoApp';
6
- import { commonChecks, iosChecks } from './checks';
6
+ import { commonChecks, iosChecks, androidChecks } from './checks';
7
7
 
8
8
  const App = () => {
9
9
  const [appChecks, setAppChecks] = React.useState([
10
10
  ...commonChecks,
11
- ...(Platform.OS === 'ios' ? iosChecks : []),
11
+ ...(Platform.OS === 'ios' ? iosChecks : androidChecks),
12
12
  ]);
13
13
 
14
14
  const config = {
@@ -116,11 +116,11 @@ const App = () => {
116
116
  )
117
117
  );
118
118
  },
119
- // iOS only
120
- passcodeChange: () => {
119
+ // Android only
120
+ obfuscationIssues: () => {
121
121
  setAppChecks((currentState) =>
122
122
  currentState.map((threat) =>
123
- threat.name === 'Passcode Change'
123
+ threat.name === 'Obfuscation Issues'
124
124
  ? { ...threat, status: 'nok' }
125
125
  : threat
126
126
  )
@@ -10,7 +10,6 @@ export const commonChecks = [
10
10
  { name: 'Passcode', status: 'ok' },
11
11
  ];
12
12
 
13
- export const iosChecks = [
14
- { name: 'Device ID', status: 'ok' },
15
- { name: 'Passcode Change', status: 'ok' },
16
- ];
13
+ export const iosChecks = [{ name: 'Device ID', status: 'ok' }];
14
+
15
+ export const androidChecks = [{ name: 'Obfuscation Issues', status: 'ok' }];
@@ -48,15 +48,18 @@ class FreeraspReactNative: RCTEventEmitter {
48
48
  }
49
49
 
50
50
  extension SecurityThreatCenter: SecurityThreatHandler {
51
+
52
+
53
+ static let threatEventMap: [String: String] = [
54
+ "missingSecureEnclave": "secureHardwareNotAvailable",
55
+ "device binding": "deviceBinding",
56
+ ]
57
+
51
58
  public func threatDetected(_ securityThreat: TalsecRuntime.SecurityThreat) {
52
- // It is better to implement security reactions (e.g. killing the app) here.
53
- switch securityThreat.rawValue {
54
- case "missingSecureEnclave":
55
- FreeraspReactNative.shared!.sendEvent(withName: "secureHardwareNotAvailable", body: "secureHardwareNotAvailable")
56
- case "device binding":
57
- FreeraspReactNative.shared!.sendEvent(withName: "deviceBinding", body: "deviceBinding")
58
- default:
59
- FreeraspReactNative.shared!.sendEvent(withName: securityThreat.rawValue, body: securityThreat.rawValue)
59
+ let threatName = SecurityThreatCenter.threatEventMap[securityThreat.rawValue] ?? securityThreat.rawValue
60
+ if (threatName == "passcodeChange") {
61
+ return
60
62
  }
63
+ FreeraspReactNative.shared!.sendEvent(withName: threatName, body: threatName)
61
64
  }
62
65
  }
@@ -6,30 +6,30 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_x86_64-simulator</string>
9
+ <string>ios-arm64</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>TalsecRuntime.framework</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
- <string>x86_64</string>
16
15
  </array>
17
16
  <key>SupportedPlatform</key>
18
17
  <string>ios</string>
19
- <key>SupportedPlatformVariant</key>
20
- <string>simulator</string>
21
18
  </dict>
22
19
  <dict>
23
20
  <key>LibraryIdentifier</key>
24
- <string>ios-arm64</string>
21
+ <string>ios-arm64_x86_64-simulator</string>
25
22
  <key>LibraryPath</key>
26
23
  <string>TalsecRuntime.framework</string>
27
24
  <key>SupportedArchitectures</key>
28
25
  <array>
29
26
  <string>arm64</string>
27
+ <string>x86_64</string>
30
28
  </array>
31
29
  <key>SupportedPlatform</key>
32
30
  <string>ios</string>
31
+ <key>SupportedPlatformVariant</key>
32
+ <string>simulator</string>
33
33
  </dict>
34
34
  </array>
35
35
  <key>CFBundlePackageType</key>
@@ -16,7 +16,7 @@
16
16
  #include <unistd.h>
17
17
  #include <string.h>
18
18
 
19
- struct MAJceCaWrKur {
19
+ struct rELTKeUlNBtW {
20
20
  char *memory;
21
21
  size_t size;
22
22
  CURLcode ret;