# How to Stop IONIC Reverse Engineering

**URL:** <https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841>\
**Category:** ionic-v3\
**Created:** [July 19, 2017, 11:56pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841 "2017-07-19T23:56:30Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Microsmsm](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/microsmsm/32/104305_2.png) [@Microsmsm](https://forum.ionicframework.com/u/Microsmsm)\
**Post date:** [July 19, 2017, 11:56pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/1 "2017-07-19T23:56:30Z")

</div>

Some bad guys may try to reverse engineer your app, change the package name and publish the app with their own package name so I wrote this function which may help to stop that … your feedback is very welcomed.

> **[How To prevent IONIC app from Reverse Engineering](https://codepen.io/Microsmsm/pen/rwEgVz?editors=0010)**
>
> ...

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [July 20, 2017, 12:06am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/2 "2017-07-20T00:06:02Z")

</div>

I see zero value here. Anybody motivated to do what you are suggesting would certainly be capable of NOPing out this function and any calls to it.

---

<div class="post-metadata">

**Author:** ![Microsmsm](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/microsmsm/32/104305_2.png) [@Microsmsm](https://forum.ionicframework.com/u/Microsmsm)\
**Post date:** [July 20, 2017, 12:19am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/3 "2017-07-20T00:19:28Z")

</div>

we are trying to make his job harder AFAIK no perfect solution to prevent Reverse Engineering but with my technique and some uglifying methods so he can’t remove it from code easily … will that do the trick?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [July 20, 2017, 3:20am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/4 "2017-07-20T03:20:06Z")

</div>

> [@Microsmsm](#):
>
> some uglifying methods so he can’t remove it from code easily

I still think this is a fool’s errand. If somebody infringes on your copyright, there are legal remedies. Attempts at technical methods are pointless.

---

<div class="post-metadata">

**Author:** ![leob](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/leob/32/14245_2.png) [@leob](https://forum.ionicframework.com/u/leob)\
**Post date:** [July 20, 2017, 1:07pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/5 "2017-07-20T13:07:36Z")

</div>

Apart from being rather easy to circumvent, this looks like a solution to a problem that doesn’t exist. I’ve never heard about this being a serious real-world problem.

It reminds me of those startups that go all apeshit about secrecy and patents and non-disclosure agreements and whatnot, because they’re afraid that “somebody’s going to steal my idea”. It’s a theoretical problem, it doesn’t happen.

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [July 20, 2017, 1:28pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/6 "2017-07-20T13:28:25Z")

</div>

And if it does it is a legal problem, not a technological one as @rapropos already mentioned.

---

<div class="post-metadata">

**Author:** ![jonathanrojas20](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jonathanrojas20](https://forum.ionicframework.com/u/jonathanrojas20)\
**Post date:** [September 7, 2020, 1:42pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/7 "2020-09-07T13:42:20Z")

</div>

I support this topic. I work inside the Finance world and in order to comply in terms of PCI DSS and lot of other certifications we need to make this kind of strategies

---

<div class="post-metadata">

**Author:** ![mikrochipkid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikrochipkid/32/116956_2.png) [@mikrochipkid](https://forum.ionicframework.com/u/mikrochipkid)\
**Post date:** [September 7, 2020, 3:04pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/8 "2020-09-07T15:04:29Z")

</div>

This is considered over engineering. chances someone will steal your app are very slim, no one will want to go through the headache of reverse engineering an app.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 7, 2020, 6:42pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/9 "2020-09-07T18:42:55Z")

</div>

> [@jonathanrojas20](#):
>
> I support this topic.

Popularity doesn’t change the laws of information theory. When you release a computer program for other people to run on devices outside your control, anything that is included in that release bundle must be considered public.

If your on-device app needs secrets to function, they must be generated and distributed out-of-band. That means something like a KDF to turn a user-generated passphrase into an encryption key, or storing all sensitive data on network servers that _are_ under your control. Never burn secrets into your app binary. If the app can get at it to function properly, somebody with an emulator or a rooted phone can get at it similarly.

People can try to argue that hybrid apps like Ionic are inherently less secure than something that compiles down to bytecode, but having spent a good deal of my teenage years busting copy protection on 6502 machine language, I don’t think it’s a very compelling argument.

> [@jonathanrojas20](#):
>
> in order to comply in terms of PCI DSS and lot of other certifications we need to make this kind of strategies

Store stuff that needs to be stored securely on servers that you don’t allow arbitrary physical access to.

---

<div class="post-metadata">

**Author:** ![jonathanrojas20](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jonathanrojas20](https://forum.ionicframework.com/u/jonathanrojas20)\
**Post date:** [September 28, 2020, 1:56am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/10 "2020-09-28T01:56:58Z")

</div>

Sorry @rapropos thanks for your comments. Do you understand that in order to be **compliant** with different regulations, like PCI DSS V1.3, Banks and Fintechs need to prevent apps to be reverse engineered? I just got a rejection from our security department because an ionic hybrid app was able to be reverse-engineered. I know is very difficult nowadays to grab an apk from the market and perform this activity, but there are some regulations that make the developers look for some security techniques. I’m also worried that the Ionic team hasn’t implemented this as default. Please see: [https://owasp.org/www-project-mobile-top-10/2016-risks/m9-reverse-engineering](https://owasp.org/www-project-mobile-top-10/2016-risks/m9-reverse-engineering)

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 28, 2020, 4:02am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/11 "2020-09-28T04:02:37Z")

</div>

> [@jonathanrojas20](#):
>
> Do you understand that in order to be **compliant** with different regulations, like PCI DSS V1.3, Banks and Fintechs need to prevent apps to be reverse engineered?

Then I think those regulations are misguided. Reverse engineering should be considered a given. I always assume that any hypothetical blackhat I am dealing with has the complete source code to any app I write, and I design so that that is not a problem.

> [@jonathanrojas20](#):
>
> I just got a rejection from our security department because an ionic hybrid app was able to be reverse-engineered.

If there are no secrets within the app binary, there is nothing to steal.

> [@jonathanrojas20](#):
>
> Please see: [M9: Reverse Engineering | OWASP Foundation](https://owasp.org/www-project-mobile-top-10/2016-risks/m9-reverse-engineering)

I see three hypothetical attack scenarios that are not the fault of reverse engineering, they’re the fault of lazy design that embeds secrets in app binaries:

> As a result of the string table analysis, the attacker discovers a hardcoded connectivity string that contains authentication credentials to a backend database

Madness. Authentication credentials to a backend database have no business being included in distributed apps. They belong in middleware that is hosted on servers under your control.

> the attacker discovers Jailbreak detection code

The attacker can discover jailbreak detection code by stepping through the app with a debugger, and there is absolutely nothing any obfuscator can do to obfuscate that. If the computer can run it, I can read it. The best you can do is to try to collude with OS and hardware makers to disable running of modified and unsigned apps, but you can’t stop me with hardware and an OS that I control.

I’m not sure what to do with scenario #3, because it just seems like a tautological boogeyman of “ZOMG they’re in ur base killin ur doodz”. Again, if you design your systems so that they’re secure even if all the source code is publicly available, you have nothing to fear from anybody decompiling your binaries.

---

<div class="post-metadata">

**Author:** ![armandovillalta](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@armandovillalta](https://forum.ionicframework.com/u/armandovillalta)\
**Post date:** [September 28, 2020, 7:21am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/12 "2020-09-28T07:21:02Z")

</div>

@rapropos  
I agree with you in every point! Also think about something in real life like lets say money:

Lets say you earned a 100k cash after a project you spend a of time and effort on it and finally gave returns. Let say the client gave you the money in their office in cash for some reason.

You want to store the money in a safe spot. You could take it home but wont put it in front door(ram memory). Someone my steal it. Of course you can store inside your home and storage it i.e. down your bed(local memory) but someone with some dedication or someone who has been watching you can and probably will try to break in your home to steal your money. So where can we take it now? You could hide it somewhere but many things could go wrong.(usb,dongles…). So probably you will end up storing it in a bank so it can be safe in there and you can use it later( your servers, your control).

So in resume:  
1- app non-sensitive logic can go public ( how buttons are displayed, page styles, local cookies for user current preferences…)

2- app sensitive data go in servers ALWAYS (secret keys, user profiles, credit cards, bank accounts…)

3-Connect your app with your server through an api or similar. This way you can ensure a good user experience and at the same time a safe and trusted service.

PS: it is your backend responsibility to validate every data that come into it just like the bank. Fake money can arrive so they gotta check it before it entering the system

---

<div class="post-metadata">

**Author:** ![suryathrideep](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@suryathrideep](https://forum.ionicframework.com/u/suryathrideep)\
**Post date:** [September 30, 2020, 6:50am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/13 "2020-09-30T06:50:52Z")

</div>

i just want to protect my code because the code contains the decrytion keys and salt and encryption code. there is no server used in application

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [September 30, 2020, 6:40pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/14 "2020-09-30T18:40:19Z")

</div>

> [@suryathrideep](#):
>
> the code contains the decrytion keys and salt and encryption code

tl;dr: don’t do that.

> [@suryathrideep](#):
>
> i just want to protect my code because

Regardless of what code “protection” you attempt to employ here, in order for the program to function properly,

- there must be _some_ code that is valid JavaScript that unravels every single last layer of “protection” eventually and gets to the point where the decryption key is readable in plain text, and
- every single piece of information required to get there has to be included in the app binary

Perhaps it’s a good idea to note at this point that this isn’t a limitation of Ionic, or Angular, or hybrid web apps, or web apps in general, or JavaScript, or interpreted languages. It’s true of any program that runs on hardware you don’t control, and why I reserve such vitriol for the snake-oil salesmen that peddle “protection” schemes. It’s not just that they _don’t_ work. They **can’t** work.

Part of the contract that allows your app to run on my phone is that you have to write it in a way my phone can decode, completely. If my phone can decode it, so can I.

> [@suryathrideep](#):
>
> there is no server used in application

Apologies if you’ve explained this already, but I don’t believe I know what kind of information your app is attempting to encrypt or decrypt, or where it’s intended to be distributed, so I can’t speak to whether adding a server would make sense. One option that might would be to rely on the user to generate secrets.

Example workflow:

- prompt user to enter passphrase
- use KDF like scrypt, PBKDF2, bcrypt, or Argon (all have JavaScript implementations freely available) to mogrify the passphrase into something suitable for use as an AES key
- use that to encrypt and decrypt

Or, if you don’t need broad web browser support, and are therefore OK with this part of the app only working on-device, you could use [Ionic Native NativeStorage](https://ionicframework.com/docs/native/native-storage). The underlying cordova plugin relies on OS-specific ways to store data protected by the phone’s lockscreen.

If you are _distributing_ data, the conversation changes a bit, but I would think that unlikely, considering the fact that you’ve said there is no server involved at all.

---

<div class="post-metadata">

**Author:** ![suryathrideep](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@suryathrideep](https://forum.ionicframework.com/u/suryathrideep)\
**Post date:** [October 14, 2020, 10:21am UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/15 "2020-10-14T10:21:01Z")

</div>

> **[ionic-team/ionic-app-scripts](https://github.com/ionic-team/ionic-app-scripts)**
>
> App Build Scripts for Ionic Projects. Contribute to ionic-team/ionic-app-scripts development by creating an account on GitHub.

how to use this app-scripts in latest ionic framework or any alternative. because it have code mangle, minifying config.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 8:53pm UTC](https://forum.ionicframework.com/t/how-to-stop-ionic-reverse-engineering/98841/16 "2021-07-19T20:53:59Z")

</div>


