{{announcement.body}}
{{announcement.title}}

Avoiding Vulnerabilities in Software Development

DZone 's Guide to

Avoiding Vulnerabilities in Software Development

In this article, you’ll learn about some of the most common software vulnerabilities and how to avoid these issues.

· Security Zone ·
Free Resource

With data breaches on the rise, creating and maintaining secure software is vital to every organization. Although not all attacks can be anticipated or prevented, many can be avoided by eliminating vulnerabilities in software. In this article, you’ll learn about some of the most common software vulnerabilities and how to avoid these issues. You’ll also learn some general best practices for ensuring that your software and data remain secure.

Addressing Common Software Vulnerabilities 

The vulnerabilities below are just a few of those identified in MITRE’s 2019 CWE Top 25 Most Dangerous Software Errors list. Many of these issues continue to be included in software despite being widely known and used by attackers.

Buffer Overflow

Buffer overflow occurs when your program tries to read or write to a buffer area that is out of bounds. It can lead to overwriting or appending data in your existing code. Buffer overflows can enable attackers to execute code, alter program flow, read sensitive data, or crash your system.

You might also like: 5 Important Software Vulnerabilities

Examples of buffer overflow vulnerabilities include: 

  • Accepting inputs of an unrestricted length
  • Allowing read operations on an array from an invalid index

The inclusion of buffer overflow vulnerabilities typically occurs in the architecture and design, implementation, or operation phases. These vulnerabilities most commonly occur in C, C++, and Assembly programs, but can occur in any language that lacks memory management support.

Vulnerability Prevention Measures for Buffer Overflow

When possible, choose a language that prevents or reduces the risk of this vulnerability, such as Java or Perl. Do not disable overflow protection if that is an option, such as in C#. Additionally, remember that even “immune” languages can create errors when interfacing with vulnerable native code in an environment.

To prevent exploitation of buffer overflow vulnerabilities, you can use compilers that include features or extensions for restricting inputs. For example, Visual Studio, or StackGuard. You can also use tools that randomly arrange program components in memory. This makes addresses harder to identify or predict, making it difficult for attackers to exploit specific components.

When creating code, ensure that you are correctly assigning buffer space. Also, use methods and functions that enable you to restrict input sizes.

Improper Input Validation

Improper input validation occurs when user inputs aren’t validated upon acceptance or are insufficiently validated. Improper validation can enable attackers to execute malicious code, alter program flow, access sensitive data, or abuse resource allocations.

Examples of improper validation include: 

  • Assuming that attackers cannot access hidden form fields

  • Only validating inputs for length and not content

The inclusion of improper validation typically occurs in the architecture and design and implementation phases. It can occur with any language or system that accepts external data.

Vulnerability Prevention Measures for Improper Input Validation

You should apply “zero trust” principles to any users and assume that all inputs are harmful until proven safe. Use whitelisting to ensure that inputs include only acceptable formats and contents. 

When validating inputs, evaluate length, type, syntax, and conformance to logic (i.e. input makes semantic sense). There are a variety of tools you can use to ensure sufficient validation, such as the OWASP ESAPI Validation API and RegEx. Use these tools to verify all sources of input, including environment variables, queries, files, databases, and API calls.

Make sure to perform checks on both the client and server-side. Client-side validation can be bypassed so you need to double-check. If client-side validation is bypassed, catching inputs server-side can help you identify attacker manipulation. Validate inputs after any necessary combination or conversion.

Information Exposure

Information exposure occurs when data is intentionally or unintentionally provided to potential attackers. Data can contain sensitive information or provide an attacker with information about the software or environment that can be exploited in an attack.

Examples of information exposure include: 

  • Errors revealing the full path of a file or program

  • Error messages exposing the existence of a user in a database

The inclusion of information exposure vulnerabilities typically occurs in the architecture and design or implementation phases of development. These vulnerabilities can occur with any language.

Vulnerability Prevention Measures for Information Exposure

To prevent exposure of information, you should design your program architecture to contain sensitive information to areas with explicit trust boundaries. Make sure to secure and restrict connections between “safe” areas and endpoints using access controls.

To minimize the potential for exploitation, verify that error messages and user warnings do not contain more information than necessary. You should also restrict sensitive information from URLs and communication headers. For example, obscure full path names or API keys.

Improper Privileges or Authentication

Improper privilege or authentication occurs when user privileges and credentials are not properly assigned, tracked, modified, or verified. These vulnerabilities can enable attackers to abuse privileges, perform restricted tasks, or access restricted data.

Examples of improper privileges or authentication include:

  • Temporary privilege escalations that aren’t reversed.

  • Restriction of privileges through blacklisting instead of whitelisting.

  • Allowing lower privilege levels to affect higher privilege accounts, such as resetting admin passwords.

  • Unrestricted log-in attempts or session limits.

Privilege or authentication vulnerabilities are typically introduced during the architecture and design, implementation, or operation phases of development. These vulnerabilities can occur with any language.

Vulnerability Prevention Measures for Improper Privileges or Authentication

You should apply the principle of least privilege to all users and services interacting with your software and systems. Restrict user and entity capabilities by applying access controls throughout your program and environment. You should restrict permissions to only those resources a user or service required.

When possible, separate high-level privileges into multiple roles. Separation helps to limit “power users” and reduces an attacker’s ability to abuse access. You can also apply multi-factor authentication methods to prevent attackers from bypassing systems or gaining easy access.

Best Practices for Reducing General Vulnerabilities

In addition to taking exploit-specific measures, there are practices you should adopt to reduce your vulnerabilities overall. You can start with the following practices.

Learn From Threat Intelligence Sources

Monitor and apply information from vulnerability databases and independent oversight groups such as OWASP or NIST. These sources can provide you with information on vulnerabilities as exploits are discovered. These sources often include information on how to resolve or mitigate issues that currently exist. You can apply this information to ensure that your systems and components are properly patched.

Include Dependencies Carefully

Make sure to use vetted and trusted libraries and frameworks only when needed. Vulnerabilities in these tools are transmitted to your software and can provide attackers with back-door access. When using libraries and frameworks, make sure that you understand what functionality is available and that you are aware of any known exploits or vulnerabilities.

Perform Vulnerability Assessments

Do not assume that your program is secure even if you follow any and all known best practices. You need to test code statically and during runtime to ensure that vulnerabilities aren’t missed. Incorporating automatic testing tools into your development environments can help you catch vulnerabilities early on. These tools can help you ensure that testing isn’t skipped due to time constraints or overlooked due to human error.

Conclusion

Software vulnerabilities may seem inevitable but most can be eliminated or at least reduced. By being aware of how vulnerabilities are introduced, you can adapt your practices and testing to catch issues before product release.

Hopefully, this article helped you understand some of the most common vulnerabilities. By applying the practices and methods covered here, you can reduce the opportunity for attackers to exploit these issues in your software.

Further Reading

How Devs Can Improve Security (Part One)

How to Maintain Security During Development

Topics:
software development ,vulnerabilities ,software vulnerabilities ,security

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}