- Obfuscate code helps.
- JS Bundles - https://github.com/vesselsoft/metro-minify-obfuscator
- Android -
Proguard
/R8
- iOS - I dont know any that is open-source and works, before deprecation,
BITCODE
was used. However there is a commercial one callediXGuard
. - JS are still easier to
decompile
/deobfuscate
thannative
, so ideally, if you can, the more you implement in thenative
side, the better. That's why one of the recommendations below is to use a single point of implementation, withRust
orC++
.
Jailbreak
/rooted
/emulator
checks, close app if detected.- Runtime App Self Protection
(RASP)
- https://github.com/bamlab/react-native-app-security - Mix of checks
- Require
app updates
, as to not support older versions. Having checks in place. OTA
could help provide fasterhotfixes
in case some security issue are discovered or bad impl are done. But for now it's on theJS
side only.- https://github.com/gronxb/hot-updater - This tool seem to be working to be more than that.
Lint
/Types
are recommendedLint
are recommended due to it's checks which can help prevent security issues.Types
are recommended withTypescript
, with proper configuration, you can enforce additional good practices, therefore having less bugs, so leading to less security issues.- All should be enforced in both
dev
environment andCI
.
Tests
are recommended at least in crucial parts of the app, and backend.- Good tests will check for things that should not be possible, so, it can help prevent security issues.
- https://jestjs.io/ -
Jest
are still the recommended choice inReact Native
due to better support with other libraries. Other equivalent libraries are not that well supported or not at all. - https://callstack.github.io/react-native-testing-library/ -
Component
andIntegration
tests. - https://wix.github.io/Detox/ for
E2E
tests.
- File integrity checks
- Js bundle
- Native android / ios
- https://github.com/pagopa/io-react-native-integrity
- https://rnfirebase.io/app-check/usage
- If using firebase on app. It may have quotas for verifications. I suppose it could be cached, once per install.
- Alternatively you can generate
SHA512 checksums
yourself manually through the CI for bothnative
andjsbundles
. But it takes more work. And probably would require some other implementationnatively
and injs
.
- Disable any sort of
debugging
. - To store
auth tokens
and others.- https://github.com/oblador/react-native-keychain
- If some things are not possible with
keychain
, there is https://github.com/mrousavy/react-native-mmkv as alternative if used withencryption
.
- Do all things in the
backend
. TheApp / Web
should be only for displaying data and taking action on it for the most part.- You can make use of
Paseto
(auth token) in the backend. - By using
Paseto
, you can have two things, a less vulnerable alternative toJWT
for authentication, and verification of the payload with it'sprivate
/public
key, similarly asHMAC Signature
intent, helps ensure the integrity of the data being transported. - Make use of
refresh token
andaccess token
pattern, whererefresh token
only serves to refresh theaccess token
which should have duration of minutes, andaccess token
to request content only. - Use
argon2
for password hashing.
- You can make use of
Device Binding
, you could send specific information from the smartphone like a combined stringuniqueDeviceId
+deviceManufacturer
+model
and tie theauth token
to it. That way, it cannot be used in another device.SSL Pinning
- though there isPublic Key Pinning
, and it might be a better option.- https://github.com/frw/react-native-ssl-public-key-pinning
- There are things that point to being easy to
bypass pinning
, though with checks and actions in place forjailbreak, rooted, emulators and hooks
(but not only), can help reduce or even completely prevent the possibility of this. - There is
2-Way SSL
/Mutual TLS (mTLS)
as alternative that I read as being able to prevent bypass, but there is no implementation yet that support both platforms, at least that I know of.
Biometrics
could help make it more difficult.- Even
hardware keys
/passkeys
, but this would be something optional like2FA
is in some cases. - For
encryption
work, I would say to do in the backend, but otherwise, there is https://github.com/margelo/react-native-quick-crypto - No
logging
on release.- https://babeljs.io/docs/babel-plugin-transform-remove-console
- This means no
console
based nor any other logginglib
usage.
- You can opt to use multiple login types (
MFA - Multi Factor Auth
), nopassword
might be safer, so there isOTP
auth as option, be throughemail
,SMS
or some othermessaging tool
to receive the code.2FA
can be an additional security option.HOTP
orTOTP
.
Input Sanitization / Validation
- https://github.com/colinhacks/zod
- https://github.com/cure53/DOMPurify for
HTML
in case you use Webview. But preferably, opt-out.
- Keep
RN
anddependencies
updated.- Use only the best options (most used) available and keep to a minimum.
- Have something in place to auto-upgrade the packages and do code upgrades if major changes are needed.
- Disable
recording
/screenshot
in the app. - Have
app signature
verification set.- While the firebase options above is a similar way to check, it's not the same.
- Currently, this might require some manual work on the native side. As well as managing generated certs.
- Always combine with backend checks where possible, not only on the client-side, since that can be bypassed.
- Never use
deep links
for sensitive data. - No sensitive
env vars
in the frontend/app.- But there is a safer option than
react-native-config
andreact-native-dotenv
, that can helpenv vars
that is not possible to have the setup in thebackend
- https://github.com/numandev1/react-native-keys- Currently
react-native-keys
still has ways to go to be free of vulnerabilities. But at this point it's the safer option.
- Currently
- But there is a safer option than
- Have
CI
dependencyvulnerabilities
verification checks withsnyk
or some other tool. - Develop
native
functionality in a single point rather than inJava/Kotlin
andObjC/Swift
, this way it can help prevent bugs and even security issues.- I would recommend in
Rust
- But if you prefer, there is
C++
as alternative - https://github.com/mrousavy/nitro
- I would recommend in
- For the backend, if starting something new, I would recommend
Rust
orDenoJS
which are based in rust, both are likely to have less vulnerabilities. Just my opinion though.- Your data is a
secure
as you made yourbackend
to be. In all ends of it.- OS always keep to a minimum in
packages
, always updated. - There are
hardened
kernels and many things that can be done to increase security in the OS part. - API preferably
containerized
. - Everything
isolated
andharder
to access, withstrict
configurations, and so on. And not just what you or someone else know, but researched and updatedconfig
to latest and safest approaches. - Ideally ALL should be
automated
, to have predictable actions done to theserver
, as to prevent things done by someone, where someone else would not know about it. Everythingstored in a repo
/commited
, of course.
- OS always keep to a minimum in
- If not starting new, and there is a legacy system that requires scaling and need a rewrite,
Rust
can be a great alternative too.
- Your data is a
- There are other things, that can also help, but those are more specific things like configurations, those you should search by yourself.
- One example being related to android
apk signing
, onlyv4
being free of known vulnerabilities.
- One example being related to android
Like everything else, it's all your responsibility
to confirm whether your implementation are working by adding checks
/ doing security analysis
.
Some additionals suggestion by Gemini 2.5 - https://pastebin.com/raw/uyaeKjsr