4

I am trying to create a NodeJS server that runs locally on the clients machine. I have all the credentials to access the db in a config file and have created an exe file using pkg module so that my client can run the exe file and have the server running on their machine.

I do not want my client to get hold of the credentials but the source code of the exe file contains the credentials. How can I safeguard the database credentials?

Narm
  • 10,677
  • 5
  • 41
  • 54
abhirham
  • 151
  • 2
  • 12
  • Best place would be something like a keystore in Java. There must be something for node too, although, if it is on the client side, it is NEVER really secured: your client will always be able to find it/reverse-engineer it. Quick search for `keystore node`: https://www.npmjs.com/package/key-store looks like it will do the job right? – sjahan May 03 '19 at 15:20
  • Have you looked into using encryption packages like the one mentioned in [this post](https://stackoverflow.com/questions/5951302/node-js-code-protection)? – Narm May 03 '19 at 15:32
  • You could obscure them by encoding them and de-encode on startup (in the old days folk used to use base64, but you could use any coding/encryption). It really depends on what you evaluate the risks and consequences of discovery to be as to how much to invest in protecting against it. – user2771365 May 03 '19 at 15:35
  • You cannot guarantee safety. You can obfuscate it but it still can be reverse engineered, also credentials still can sniffed from network traffic. If DB shouldn't be connected directly, don't expose it. – Estus Flask May 03 '19 at 17:00
  • Use an Oracle Wallet. This will need to be managed separately from the EXE and you'll need Oracle Net configuration. See https://oracle.github.io/node-oracledb/doc/api.html#extauth – Christopher Jones May 09 '19 at 23:35

1 Answers1

0

Store your credentials encrypted and have your program directly (or indirectly through a compiled program to further hide your logic) decrypt them on startup

Prodigle
  • 1,757
  • 12
  • 23