Thanh Tran

Thanh Tran

Sr. Software Engineer

An application in today’s environment can be affected by a wide range of issues, resulting in serious damage to an individual application or the overall organization. To build a secure and stable application, you must first recognize different attacks that can make the application vulnerable. The order of the following list is based on the risk factor of each application vulnerability and is intended to help you prevent attacks from taking place.

 

1. Injection

The highest vulnerability risk is injection and has been for decades. Almost anything can be injected, such as SQL queries, LDAP, Xpath, NoSQL queries, expression languages, etc. It can occur whenever a user is allowed to input untrusted data via forms, URL, or anything that can be sent back to the application/system. Any new expression or query-like language can be exploited if not implemented correctly.


How to prevent:

  • Any untrusted source of data must be validated on server side.
  • Limit the input data by implementing a whitelist instead of a blacklist — you never know what might be out there that can harm your system.
  • If possible, use safe APIs and parameterized queries. Most frameworks support this process.

 

 

2. Broken Authentication

Broken authentication vulnerabilities occur when session management is not handled properly on the server side. Attackers can reuse a session ID or token to gain access. It can also occur if weak authentication or weak recovery methods are used.


How to prevent:

  • Most advanced frameworks have reliable and secured session management. If you must implement your own, ensure the session ID is randomized and the session is invalidated correctly. Never expose your session ID via URL or any visible location on the screen.
  • Implement a weak-password check.
  • It seems like a good idea to enforce users to change their password once in a while. In reality, however, this does not prevent the problem as users tend to rotate their own passwords for easy memorization. A better way to ensure password security is implementation of a multi-factor authentication.

 

 

3. Sensitive Data Exposure

Sensitive data can be exposed to attackers in many ways. The most common exposures happen when data is transferred in plain text or using weak encryption. The following is an example of data sent over an unsecured network using weak encryption (base64encode):
 GET /api/secured HTTP/1.1
 Authorization: Basic YXVkaXQtd3M6TGV4aXNAMjAxOA==


How to prevent:

  • Ensure data is transferred via a secure layer (e.g. https over http, ssh over telnet, sftp over ftp, etc). Using https might prevent exposing plain text data transferred over the internet. As https is very affordable nowadays, it’s a great option to secure a site. For internal data transfers, however, always use a secured layer as people tend to keep data in plain text for faster transmission time.
  • Stored passwords should use strong adaptive and salted hashing functions.
  • Keep your encryption algorithm up-to-date and make sure to choose a good key size for your secret. Choose your key size wise since there is a tradeoff between key size and performance.

 

 

4. XML External Entities

Attackers can add XXE in place of an XML file and send it back to the server. This can be confused with the injection vulnerability, but it’s actually a privilege abuse method used to exploit many old XML processors. Any XML processor or SOAP based web-services that has DTDs enabled can be the target. Developers should be aware of the injection vulnerability; however, XML External Entities are not commonly seen, thereby significantly increasing the risk of this type of attack.


How to prevent:

  • If possible, try to use a less complex data format such as JSON.
  • Patch/update all XML processor libraries and use SOAP 1.2 or higher.
  • Disable XML External Entity and DTD processing in your XML parser.
  • To prevent a worst-case scenario when enabling that support, make sure to implement a whitelist and have a custom implementation to validate the input.

 

 

5. Broken Access Control

Attackers can have access to unauthorized resources via different means. Most likely, there is a flaw in the implementation to prevent users from accessing unauthorized resources. For example:
 POST /api/person/1/change-password
 {‘password’: ‘new_password}
By changing “1” to a different User ID, the attacker can change the password for any given user (not just himself).


How to prevent:

  • Deny default access to all non-public resources.
  • Always check for user privilege at server side.
  • Disable CORs or minimize its usage.

 

Other vulnerabilities that are commonly seen and exploited are XXS or CSRF. They are not included in the Top 5 list, however, because advanced frameworks nowadays are mostly able to take care of the vulnerabilities through default configurations.

Following best practices in security coding will gain huge value in return, especially in the early stages of development. You never want to run the risk of losing your valuable and sensitive data due to flaws in implementation. Some general thumbs-up rules you should consider are:

  • Subscribe to various forums that share the latest vulnerabilities along with the CVE.
  • Always keep your library up-to-date with the latest patches.
  • Define a security process that makes it fast and easy to develop, test, and deploy applications. Automated processes that leverage tools such as Burbsuite are very beneficial.

  1. Johnson Tom

    November 23, 2018

    very good

Leave a comment