Skip to content

Is the source really protected with building apps with Electron? #2570

Closed

Description

@ashking

Hey guys,

This is not entirely a bug.

I was wondering; are the apps built with Electron protects the source? I tried JxCore and it does not protect source. How about electron?

Cheers

Activity

  1. zcbenz commented on Aug 24, 2015

    @zcbenz
    Contributor

    No, it is very easy to get your source code even when you packaged them in asar archive, the V8 JavaScript engine is never designed to hide source code. NW.js does succeed to hide one file of the source code completely, but with the price of significant performance downgrade.

    So if you really to want to protect your source code, you have to write them in C++ and make a native Node module.

  2. etiktin commented on Aug 24, 2015

    @etiktin
    Contributor

    There are some options, but the level of protection they provide is limited by the reasons @zcbenz mentioned:

    • You could implement some decryption logic on your own, in a C++ node addon, but it will probably still be breakable (e.g. debug the program and copy the source after decryption but before eval).
    • There's also EncloseJS, that claims to compile your code for node.js/io.js, so it might work with Electron.
    • nw.js, which is a similar project, has support for v8 snapshots which provide some kind of protection (see details here).

    Note that all of this methods, will incur some performance penalty.

  3. fritx commented on Jul 27, 2016

    @fritx
    Contributor

    @etiktin I'm running into this too.
    Is it possible to just apply node.js code in C++ addon directly?

  4. etiktin commented on Jul 27, 2016

    @etiktin
    Contributor

    @fritx, Node has a module called vm which can eval code. I guess you could find a way to call it or it's underlining C++ API from your addon and use that to load your code.
    Keep in mind that the user could still manage to open the developer tools and see the loaded script. Even if you manage to block that using a custom Electron build and the addon checking to see that your Electron build wasn't tampered with, the user could still see your code as a string in memory.

  5. fizzvr commented on Aug 17, 2016

    @fizzvr

    Sounds good protect the source! 🔑

  6. alexisfrjp commented on Feb 2, 2017

    @alexisfrjp

    Then I have a question, how closed code electron apps such as GitKraken, Whatsapp or Slack can hide the code ?

  7. Hum4n01d commented on Feb 3, 2017

    @Hum4n01d

    @Alexis57 I have the same question; maybe it’s just that inspect element is disabled or something

  8. alexisfrjp commented on Feb 3, 2017

    @alexisfrjp

    Or maybe the main code comes from a C/C++ library and then they use electron just for the GUI, don't know...

  9. nabtron commented on Mar 1, 2017

    @nabtron

    Would like to know how whatsapp and slack protect their source code too

  10. boeserwolf commented on Mar 22, 2017

    @boeserwolf

    AFAIK it's simply unprotected. You can extract their app.asar and access the source code. For sensitive parts of the application you usually write custom addons in a compiled language like C/C++, as suggested above.

  11. nabtron commented on Mar 22, 2017

    @nabtron

    How can we compile c++ code in it?

  12. boeserwolf commented on Mar 22, 2017

    @boeserwolf
  13. nabtron commented on Mar 22, 2017

    @nabtron

    @boeserwolf thanks! :)

  14. vasyl-shumskyi commented on Jun 29, 2017

    @vasyl-shumskyi

    Subscribed

  15. 52 remaining items

  16. charlesr1971 commented on Dec 3, 2021

    @charlesr1971

    If you use Angular Electron, the Angular part is converted into Vanilla JavaScript and obfuscated, automatically. It is pretty much unreadable. :)

  17. m4heshd commented on Dec 3, 2021

    @m4heshd

    @charlesr1971 Meanwhile obfuscation is an option, it's not very effective. Obfuscated code is easily traceable simply using an IDE. Speaking from experience because I constantly write mods for applications and by this point, it has become quite effortless. Heavy obfuscation however, including string encryption is very effective. But the performance hit becomes unbearable. Especially for HTML UIs since it's already very clunky. Comparing this to compiled code, it's a no-brainer that the latter is way more advantages on every aspect. Also you don't need to have Angular. Setting up obfuscation with Webpack is extremely easy.

    const WebpackObfuscator = require('webpack-obfuscator');
    
    // webpack plugins array
    plugins: [
        new WebpackObfuscator()
    ]

    Even a beginner dev knows that the decompilation is inevitable but I think what we all looking for here is merely some protection against layman end users. I don't want my code to be exposed just because some bored YouTuber learned how to extract an asar file. And binary files provide that while not losing any performance too. In some scenarios improving the performance too. NW.js is a great example for that.

  18. charlesr1971 commented on Dec 3, 2021

    @charlesr1971

    NW.js is a great example for that.

    I had a look at NW.js, but I don’t quite understand what it does? It says that it allows one to use node modules in the DOM?

    But how does it protect our source code? I am using Angular with Electron. Can I integrate NW.js with this environment?

  19. charlesr1971 commented on Dec 3, 2021

    @charlesr1971

    @m4heshd Because of this code protection issue, I am thinking about putting my application online. I want to place ipcMain on the server and ipcRenderer will be the client.
    My question is, does the invoke method, which links ipcRenderer with ipcMain, use XHR?
    So, could I continue to use this protocol to connect client with server.
    Although, I have a lot of server side development experience, I haven’t used NodeJs, much. Coldfusion [cfml] is my language of choice.
    However, I don’t want to rewrite all of my ipcMain code, so I would like to use it as my server side application.

    Could you suggest how I can convert my Electron app into client server model? Thanks 🙏

  20. m4heshd commented on Dec 3, 2021

    @m4heshd

    But how does it protect our source code?

    Read this documentation. Electron does have something similar called "V8 snapshots" which is a part of V8 engine but it's not exactly similar. It's extremely difficult to adapt to, no useful documentation and could result in development and production state of the app behaving very differently.

    Can I integrate NW.js with this environment?

    Yes you can but beware that NW.js lacks the massive and active support system Electron has. Hence the less popularity. It has to do with not having a proper, up-to-date build suite, having to deal with the pain of building native modules with nw-gyp and more stuff like that.

    I want to place ipcMain on the server and ipcRenderer will be the client.

    Technically, you cannot "IPC" over the internet. For that kind of communication, you have to implement some kind of a REST API specific for your application.

    does the invoke method, which links ipcRenderer with ipcMain, use XHR?

    No. It's a completely different, native implementation included with Chromium.

    Could you suggest how I can convert my Electron app into client server model?

    I'm sorry I can't help you with that because it completely depends on your application's structure and process.

  21. annymosse commented on Dec 4, 2021

    @annymosse

    Could you suggest how I can convert my Electron app into client server model? Thanks pray

    @charlesr1971 you should migrate your heavy code (source which you want to protect) into a server
    and connect with it through RestAPI or GraphQl or render your html from it if you wish too, or you could use native modules and load your modules from your electron (however it's not too much useful since the hacker/cracker still have your source code)and can use your modules too

  22. charlesr1971 commented on Dec 4, 2021

    @charlesr1971

    @annymosse How is a hacker going to get hold of the NodeJs code on my server? Yes. The hacker can inspect the Anguler client side code, but that is useless without the NodeJs part.
    Converting this to a client server model is definitely the way to go.
    The Electron engineers really need to implement code protection. This issue is a real disappointment. :(

  23. annymosse commented on Dec 4, 2021

    @annymosse

    How is a hacker going to get hold of the NodeJs code on my server?

    I didn't say hacker can get your code at server side, however it can if you have a bad security structure.
    Electron team can't make the silver bullet, after all there's no way to eliminate the crackers (reverse engineering) even avast, Kaspersky antivirus couldn't be safe, so the solution is to keep your code between your hands at server side and provide API then invest your money to keep your servers safe against the hackers instead the crackers.
    If you need as "almost of us" need extra shields to keep your source code secure and perform well against these curious newbie users is to use native add-ons through N-Api & CPP,C or Rust; then obfuscate the rest "lightweight" part of your code.
    For my own prospectives I prefer to see Electron more modular , FTP(S) stand alone module, WS(S) module,.... By this way the developer can load only the required modules and ship it's heavy important part as a native part belong to electron itself and the cracker can't make a single solution to crack all electron project since they're different, and the the project will be much more light and performing so well, and for the team at first time it will be a huge hard path to walk through, however at the end the project can stand alive forever as a modules instead a single huge hard project, and they can maintain it easily and can get more contributers even the chromium team might switch into electron structure because it's more cleaner and lighter.

  24. annymosse commented on Dec 4, 2021

    @annymosse

    How is a hacker going to get hold of the NodeJs code on my server?

    I didn't say hacker can get your code at server side, however it can if you have a bad security structure.
    Electron team can't make the silver bullet, after all there's no way to eliminate the crackers (reverse engineering) even avast, Kaspersky antivirus couldn't be safe, so the solution is to keep your code between your hands at server side and provide API then invest your money to keep your servers safe against the hackers instead the crackers.
    If you need as "almost of us" need extra shields to keep your source code secure and perform well against these curious newbie users is to use native add-ons through N-Api & CPP,C or Rust; then obfuscate the rest "lightweight" part of your code.
    For my own prospectives I prefer to see Electron more modular , FTP(S) stand alone module, WS(S) module,.... By this way the developer can load only the required modules and ship it's heavy important part as a native part belong to electron itself and the cracker can't make a single solution to crack all electron project since they're different, and the the project will be much more light and performing so well, and for the team at first time it will be a huge hard path to walk through, however at the end the project can stand alive forever as a modules instead a single huge hard project, and they can maintain it easily and can get more contributers even the chromium team might switch into electron structure because it's more cleaner and lighter.

  25. charlesr1971 commented on Dec 4, 2021

    @charlesr1971

    @annymosse Well. NW.js seem to be able to achieve full protection. Why can’t Electron implement something like this? The only reason, I won’t use nw.js, is that we have to convert all node modules to binary etc. But, this process could be automated.

  26. m4heshd commented on Dec 4, 2021

    @m4heshd

    @charlesr1971 As I've said earlier, decompilation and deobfuscation is inevitable. There's no actual way of completely protecting client side code. Only the means of making it harder to do so. I'll simply put it as this. If your CPU can read the instructions, so can the user. That's all there's to it. Only way to have it protected is to have as much of the functionality at server-side as possible. But users could still have access to your backend APIs. So API abuse is also something to be worried about.

    But I agree with you on Electron needing something similar to what NW.js have achieved. It would be such a great addition to Electron but as the devs mentioned multiple times earlier, don't hold your breath on that.

  27. annymosse commented on Dec 4, 2021

    @annymosse

    NW.js seem to be able to achieve full protection.

    There's no full code protection when your app become at the user end desktop, he/she can crake it and use it for free, if you're looking for a solution you should use node add-ons which much more faster smaller size then these .bin files , it's true that when you compile your js code using nwjc you don't need to use other low level language but you'll keep facing same issue "your software will be craked"

  28. charlesr1971 commented on Dec 4, 2021

    @charlesr1971

    @m4heshd Are you saying it is possible to reverse engineer compiled C++ or Java? I think this is very difficult to do and what is impossible is to reverse it to the original source code, because there is no 1:1 relation between the machine code and the source code..
    So, what I am saying, why can’t the Electron team convert the JS to machine code.

  29. charlesr1971 commented on Dec 4, 2021

    @charlesr1971

    @annymosse I think what I am saying, is electron should try and provide as much protection as any piece of software that is compiled to machine code, within an executable. Obviously, any piece of software can be cracked, if you throw enough resources & expertise, at it. But, most software users, won’t try and reverse engineer machine code.

  30. annymosse commented on Mar 2, 2023

    @annymosse

    and why not Linux?!! i think it's same code-base to all the platforms right??!

    @annymosse

    I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.

    Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.

    There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!

    thank you for your note, It's true that much better we use the correct name for right thing, It's fact Linux (the kernel) became the name of OS which ment to be controlled by GNU, however the alternative of Linux (monolithic) is Hurd (microkernel) which have slow development, and less contributors.
    The successful key still until now the performance and stability and for this reason Electron is much more attracting developers more than other hybrid technologies (NWJs), and the current path of Electron not providing bright future compared to other projects, flutter and some new shiny rust's solutions, rust itself provide security, performance, stability and productivity so the developer can focus on securing it's project much safer without sacrificing the performance and providing modular solution, just consume what do you import, and crackers wont get same structure (libraries, folders, constant files,...), it became much harder to predict which framework, programming language....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions