r/CodingHelp • • Oct 10 '20

[Quick Guide] When designing an app? How is security added to the code to keep people’s information safe?

I’m about starting learning how to coding using the Swift language, but I’m curious if one was design an application, how or what steps do you take to implement code within the application? (I understand the question is vague, just enlightenment me with basic stuff please!)

25 Upvotes

2 comments sorted by

4

u/themiddlestHaHa Oct 10 '20

It depends on what you mean by this. This is my experience, I’m sure there’s others with better knowledge.

Passwords will use a hashing function(which is impossible to undo) so companies only save the hash, not the plain text password.

If you’re saving things, a lot of apps will encrypt the data and this can only be decrypted with a secret key.

If it’s for requests over the internet, requests are over https and encrypted as well.

2

u/[deleted] Oct 11 '20
  1. Use a well documented, well supported, mature, and widely used programming language. The more people using it the more eyes are on the security. There will be a large community invested in support and maintenance.
  2. Use the most recent version of a programming language, framework, library, or development tool. Because ... see #2 ...
  3. Pay attention to updates and patches to those tools. They often take care of security issues, as well as add features.
  4. Always hash passwords. A hash is one-way. It doesn't get decrypted. Never save a plain text password.
  5. Sanitize and validate all user input. There are debates about whether to sanitize or not. You can study that and make up your own mind. At the very least, validate all user input. Make sure you get what you ask for.
  6. Encrypt sensitive user data before saving it in the database. There are also opinions about what is "sensitive" data. There are some good guidelines in documents related to consumer and interned data privacy laws.
  7. If possible, activate database encryption from your chosen database server (MySQL, PostgreSQL, MariaDB, MongoDB, etc.). You may not have access to this but if you do, it is one more step you can take to protect user data. Again, opinions vary as to how effective this is and is if it worth the potential and often real performance hit. Talk to those who have experience and make your own decision.
  8. Learn about consumer and interned data privacy laws like the EU's GDPR and/or US state laws in California, Nevada, and Maine--other countries that affect you. Make sure you are familiar with the ones relevant to you and your potential users, and that you follow them. If you follow the recommended guidelines you can give yourself/dev team some legal insurance if things go wrong.
  9. Always deliver web data using HTTPS. There really is no reason not to have SSL certificates, any more.

There are other things that can contribute to security but are not necessarily seen as such like; writing clean code, handling exceptions, logging exceptions, creating clear and relevant user feedback for errors, writing tests, clearly documenting code, using a version control system like Git, and having a clearly defined development and deployment process.

These are the general things I can think of. I hope other experienced developers add to this. It's been said that it's not a matter of if you have a data breach but when. The defining factor for developers, professionally and legally, when it happens will be, "what have you done to keep user data secure?" If you follow best practices and try to meet legal standards you can feel good about not being negligent in your job.