The Secure Coding Best Practices [Cheat Sheet]

Unlock quick recommendations to fortify your code against vulnerabilities. This quick-reference guide is packed with actionable insights to help developers avoid common security pitfalls and build resilient applications.

Software Supply Chain Security Explained

Software supply chain security describes the set of processes that ensure the integrity, authenticity, and security of software components throughout their lifecycle.

8 minutes read

What is software supply chain security?

Software supply chain security describes the set of processes that ensure the integrity, authenticity, and security of software components throughout their lifecycle. Picture a production line where raw materials are transformed into a finished product, and imagine that one of those raw materials is tainted. The result? The end product is compromised. That same principle applies to software.

A compromised software supply chain can have profound consequences. With cyber threats becoming increasingly sophisticated, even a minor vulnerability can lead to devastating breaches. For businesses, this can translate to financial losses, legal repercussions, and a damaged reputation. For end users, the fallout can range from privacy violations to financial fraud.

But what makes up this software supply chain? Let's examine its components to understand the inherent challenges in securing each.

Components of the software supply chain that need to be secured

  • Source code: Often written in high-level languages like Python, Java, or C++, the source code forms the foundation of any software. To ensure its integrity, use techniques like cryptographic hashing, which can detect any unauthorized alterations.

  • Dependencies and libraries: Consider these the building blocks that developers use to enhance functionality without reinventing the wheel. For instance, a developer might use OpenSSL, a widely used library, for implementing SSL/TLS protocols. However, as seen in the Heartbleed Bug incident, even popular libraries need to be checked to be protected from threats.

  • Build and compilation processes: These processes are akin to an assembly line in manufacturing. Tools like Jenkins or Travis CI automate build and compilation tasks, converting source code into executable binaries. It’s crucial to keep these tools free from vulnerabilities to prevent potential security breaches and ensure the integrity of the build process.

  • Distribution and deployment: Consider distribution and deployment as the means of delivery. Docker, as an example, lets developers encapsulate applications in containers, guaranteeing consistent environments. But if the Docker image repository gets breached, it can result in extensive problems.

  • Updates and patches: Just as cars need periodic servicing, software requires updates. Updates and patches fix known issues or vulnerabilities. However, if an attacker pushes a malicious update, the results can be catastrophic.

Threats and risks to the software supply chain

Thanks to its intricate processes and multifaceted components, the software supply chain is a prime target for threat actors. Understanding the breadth and depth of potential threats is the first step in developing defenses. Here are the most pressing threats that can compromise your software supply chain:

1. Malicious code injections and backdoors

These covert techniques allow attackers to embed malicious functionalities within legitimate software. A prime example is the SolarWinds attack, where attackers managed to insert malicious code into the software's update mechanism, leading to wide-scale data breaches that affected organizations around the world.

2. Compromised third-party libraries and dependencies

Relying on third-party components is a double-edged sword. While they expedite development, third-party libraries and dependencies can also introduce vulnerabilities. A stark example of this is the Log4Shell vulnerability, which was disclosed in 2021. It affected the widely used Log4j logging library and had a profound impact on countless systems globally, highlighting the importance of vigilance and timely updates when managing third-party dependencies.

3. Man-in-the-middle attacks during software distribution

Man-in-the-middle (MitM) attacks involve intercepting software distribution and altering them before they reach the end user. The compromise of the ASUS Live Update Utility serves as a chilling reminder. In that attack, threat actors managed to intervene and made ASUS distribute malicious code to its users instead of legitimate updates.

4. Insider threats and compromised developer accounts

Sometimes, a threat originates within an organization. Malicious actors, dissatisfied employees, or even unintentional mistakes can lead to significant breaches. The Codecov incident is one example of this threat vector. The breach was executed by advanced attackers who took advantage of an error in Codecov's Docker image construction. They altered a script, enabling them to transmit the environment variables from Codecov's CI to an external server.

5. Outdated components with known vulnerabilities

Using outdated software components is akin to leaving your door unlocked with valuables on display. The Equifax breach, resulting from an overlooked vulnerability in Apache Struts, highlights the severe repercussions of not updating promptly. It serves as a stark reminder of the importance of regular software maintenance and patching.

6. Compromised registry packages in containerized environments 

For environments utilizing containers, the security of registry packages must be carefully managed, as these can be prime targets for attackers seeking to inject malicious code into the software supply chain.

7. Supply-chain vendor compromises

Often, organizations rely on third-party vendors for various software development and deployment tasks. If one of these vendors is compromised, it can have a cascading effect, affecting all associated organizations.

8. Lack of encryption in data transmission

Transmitting software updates or patches without encryption can allow attackers to intercept and modify the software, introducing malicious code. This not only compromises the integrity of the software but also puts users at risk of downloading and installing versions that have been tampered with.

9. Flawed software design

Sometimes, the software's design can introduce vulnerabilities. Inadequate threat modeling or neglecting security during the design phase can lead to systemic issues that are hard to rectify later.

10. Insecure APIs

Application programming interfaces (APIs) allow different software components to communicate. If these APIs are insecure, they can serve as gateways for attackers, resulting in data leaks or unwanted access.

A real-life example of a software supply chain attack

The Hell's Keychain attack on IBM Cloud Databases for PostgreSQL is an immediate reminder of the vulnerabilities inherent in software supply chains. In August 2022, Wiz Research discovered this supply-chain vulnerability, a combination of overly permissive network access to internal build servers and three exposed secrets. This potent mix could potentially grant unauthorized access to IBM Cloud's internal build servers, allowing manipulation of its software artifacts. 

Although these findings did not pose an immediate threat to IBM Cloud’s customers, they were still deemed severe. If a malicious actor had obtained these credentials, they could have pulled and explored hundreds of images belonging to IBM Cloud’s managed database services. These container images often hold proprietary source code, binary artifacts, and potentially sensitive secrets that could compromise other resources. IBM Cloud swiftly patched the vulnerability, ensuring customer security. This incident, detailed in Wiz's comprehensive report, underscores the importance of proactive vulnerability research and the need for robust software supply chain security measures.

Best practices for mitigating supply chain risks

To secure the software supply chain, it's crucial to not only understand potential threats but to also adopt best practices that mitigate these risks. Breaking down the software supply chain into three primary streams—first-party, open-source, and third-party software artifacts—allows for more targeted strategies. Let's delve deeper into the top ten actionable best practices that your organization can adopt:

1. Create a software bill of materials (SBOM) with security considerations

An SBOM should be an integral and regularly updated part of every software project, generated using automated tools within the software development lifecycle. It's essential to document all components, libraries, and dependencies, and to review the SBOM periodically for vulnerabilities. Additionally, when evaluating third-party software, consider the NIST recommendations to ensure suppliers meet security standards. Questions to evaluate may include:

  • Does the supplier have ties with any foreign governments?

  • Can the supplier provide a sourcing list for their hardware and software components?

  • Are there safeguards for sensitive program information that could be compromised through the supply chain?

  • Are there secure procedures for maintenance and upgrades post-deployment?

  • Is there a system in place for recording and tracking risk mitigation throughout the product's life cycle?

  • Does the supplier adhere to secure software development standards, such as the Microsoft Security Development Lifecycle?

For detailed guidance, refer to the NIST Special Publication 800-161r1. Implementing tools like Wiz's agentless SBOM scanning can help to streamline this process.

2. Leverage DevOps and DevSecOps

Transition from traditional development practices to a DevOps or DevSecOps model. This involves integrating security checks at every phase of the software development lifecycle. Incorporating tools such as SonarQube or Checkmarx into the CI/CD pipeline facilitates automated security assessments, guaranteeing swift detection and resolution of vulnerabilities.

3. Complete regular Audits

Schedule periodic security audits for your software projects, and utilize tools like OWASP Dependency-Check to scan software components and identify potential vulnerabilities. Following the audit, rank and then tackle the detected vulnerabilities according to their level of severity.

4. Implement multi-factor authentication and enforce least-privilege access

Enabling MFA for all developer accounts, particularly for those with access to essential code repositories like GitHub or Bitbucket, adds an additional layer of security against unauthorized access. Moreover, it is vital to enforce the principle of least privilege in these repositories. This strategy limits the access rights of accounts to the bare minimum necessary for their role, preventing compromised accounts from impacting the entire code base.

5. Foster awareness through training sessions

Organize regular workshops, webinars, and training sessions for development teams. Focus on the latest threats, vulnerabilities, and best practices in software supply chain security. Encourage developers to participate in security forums and stay updated on emerging vulnerabilities.

6. Choose a continuous monitoring solution

Implement real-time monitoring solutions to detect and alert you of any unauthorized changes or access attempts in the software supply chain. Tools like Splunk or ELK Stack can provide insights into system logs and detect anomalies.

7. Manage vendor risk

Before integrating any third-party component or service, conduct a thorough risk assessment. Understand the vendor's security practices, history of vulnerabilities, and their response strategy. Regularly review and update vendor risk assessments.

8. Create an incident response plan

Develop a comprehensive incident response plan tailored to potential software supply chain attacks. This plan should outline the actions to follow if a breach occurs, encompassing communication protocols, immediate countermeasures, and a thorough post-event review.

9. Utilize network segmentation

Segment your network to ensure that development, testing, and production environments are isolated from one another. Network segmentation reduces the risk of a compromise in one environment affecting other environments.

10. Schedule regular backups

Create a schedule for backing up critical software components and configurations and stick to it. It's vital to encrypt backups and keep them in a protected location. Regularly conduct restoration tests from these backups to validate the integrity of the data.

You can significantly enhance your software supply chain security by adopting these best practices and integrating the actionable items outlined above into your workflows. Remember: Proactive measures and continuous vigilance are the cornerstones of robust software supply chain security.

Secure all components of your software supply chain

Because software supply chain security is an evolving landscape, new challenges emerge as technology advances. Keeping your software safe is a collective responsibility, necessitating collaboration between developers, organizations, and even end users. The stakes are high, so it’s critical to find trusted security partners. That’s where Wiz comes in. 

Wiz is the unified cloud security platform to secure your software supply chain from the get-go. With Wiz's Secure Cloud Development solution, organizations gain immediate visibility into all software components, detect supply chain risk, and get remediation guidance.

Wiz's new secure cloud development capabilities include:

  • Code scanning: Wiz can scan your code repositories to detect potential security risks, such as vulnerabilities, misconfigurations, and policy violations.

  • Cloud-to-code tracing: Wiz can automatically trace risks in the cloud back to the code and teams that introduced them. This can help you quickly identify and fix the root cause of problems.

  • SBOM and image integrity: Wiz can generate software bills of materials (SBOMs) to track the components of your software. Wiz can also verify the integrity of your software images to ensure that they have not been tampered with.

  • GitHub connector: Wiz offers a GitHub connector that integrates with your GitHub repositories. This makes it easy to scan your code and track risks from within GitHub.

Secure Every Stage of the SDLC

Learn how Wiz is solving security challenges of Developer and DevSecOps team.

Get a demo 

Continue reading

Unpacking Data Security Policies

Wiz Experts Team

A data security policy is a document outlining an organization's guidelines, rules, and standards for managing and protecting sensitive data assets.

What is Data Risk Management?

Wiz Experts Team

Data risk management involves detecting, assessing, and remediating critical risks associated with data. We're talking about risks like exposure, misconfigurations, leakage, and a general lack of visibility.

8 Essential Cloud Governance Best Practices

Wiz Experts Team

Cloud governance best practices are guidelines and strategies designed to effectively manage and optimize cloud resources, ensure security, and align cloud operations with business objectives. In this post, we'll the discuss the essential best practices that every organization should consider.

What is Data Detection and Response?

Data detection and response (DDR) is a cybersecurity solution that uses real-time data monitoring, analysis, and automated response to protect sensitive data from sophisticated attacks that traditional security measures might miss, such as insider threats, advanced persistent threats (APTs), and supply chain attacks.