Improving Cloud Security with DevSecOps: Best Practices for Azure

Arshad R
10 min readSep 10, 2023

Introduction:

The adoption of Cloud computing has come with its set of security challenges and risks. Here are some eye-opening cloud security statistics and breach examples from 2018 to 2023 :

  • A misconfigured AWS S3 bucket exposed the personal information of over 100 million Capital One customers in 2019.
  • Supply chain attacks targeting cloud infrastructure increased by over 650% in 2021 compared to 2020 according to Accurics.
  • Researchers identified over 200 misconfigured S3 buckets in 2022 exposing 1 billion customer records including bank account details and COVID-19 health reports.
  • A 2022 IBM report found 60% of organizations experienced a cloud data breach in the past two years, primarily due to cloud misconfigurations.
  • A 2023 Anomali threat report found that 83% of all web application attacks targeted cloud environments, with Azure and AWS being top targets.
  • Unprotected cloud databases contributed to 93% of all records breached in 2022 according to Tenable’s 2023 Cyber Exposure Report.
  • Between 2018 and 2022, ransomware attacks on cloud infrastructure increased by over 300% as per IDC.

As organizations continue to adopt cloud-native architectures and migrate workloads to the cloud, it’s critical to embed security practices into the DevOps workflow to mitigate the likelihood of some of the breach examples highlighted above. Implementing cloud-native DevSecOps enables development, security, and operations teams to collaborate closely and build security into applications from the start.

There are many benefits to implementing cloud-native DevSecOps.

  • First, it can help to improve the overall security of your cloud environment. By integrating security throughout the development lifecycle, you can identify and mitigate security risks early on.
  • Second, cloud-native DevSecOps can help to save time and money. By automating security checks and implementing security best practices, you can free up your team to focus on other tasks.
  • Third, cloud-native DevSecOps can help to improve compliance. By following industry standards and best practices, you can demonstrate that you are taking security seriously.

In this post, I’ll share some best practices and considerations for implementing cloud-native DevSecOps in Azure based on my experience as a cloud security consultant. A cloud-native approach with DevSecOps allows you to fully leverage Azure’s security capabilities while accelerating application delivery.

Best Practices and considerations for implementing DevSecOps in Azure

Leverage Azure Policy & Blueprints:

Begin your journey by setting up guardrails for your development and operations teams. Azure Policy helps in defining and enforcing good hygiene on your resources, ensuring that they adhere to corporate standards and best practices. Azure Blueprints, when combined with policies, offer a repeatable set of Azure resources, ensuring that environment setups are consistent and compliant.

Use Azure DevOps for CICD pipelines:

Leveraging Azure DevOps is a great way to enable DevSecOps in Azure. With Azure DevOps, you can define CI/CD pipelines that incorporate security scanning and testing into the build process. Useful Azure DevOps capabilities include:

  • Integration with Azure Key Vault to securely manage secrets like passwords, keys, and certificates
  • Azure Repos for secure source code management using Git
  • Azure Pipelines to automate build, test, and deployment steps
  • Security testing tasks like static application security testing (SAST), dynamic application security testing (DAST), container scanning, and more
  • Role-based access control to manage permissions across DevOps teams

By defining CI/CD pipelines in Azure DevOps that include security checks, you can fail builds that don’t meet security standards and ensure you release secure code into production.

Adopt a “shift left” security approach:

Shifting security activities to earlier in the development lifecycle is key for DevSecOps. This means security is not a separate step done right before production. Instead, engineers and security teams collaborate closely to embed security across the entire process.

Key ways to shift security left in Azure include:

  • Integrate security scanning and testing tools into CI/CD pipelines
  • Leverage Infrastructure as Code (IaC) techniques like Bicep or Terraform to define and provision Azure resources in a secure and repeatable way
  • Use static application security testing (SAST) tools like Checkmarx or Synopsys tools to scan source code for vulnerabilities
  • Perform dynamic application security testing (DAST) on running apps with tools like OWASP ZAP or Fortify WebInspect
  • Scan container images for vulnerabilities with tools like Twistlock or Aqua
  • Frequently remediate any findings from scans to fix issues early on
  • Taking a collaborative approach where security is involved through the entire pipeline enables end-to-end security and reduces risk.

Implement least privilege access:

To strengthen the security posture on Azure, it’s essential to grant users and applications the least privileged access they need to perform their tasks. This principle limits exposure and prevents lateral movement in case of a breach.

Ways to implement least privilege include:

  • Leverage Azure role-based access control (RBAC) to only grant necessary permissions
  • Restrict VM access to approved source IP ranges or virtual networks
  • Use service principals with minimum required permissions for automation/scripts to access Azure resources
  • Grant managed identity access to resources rather than broad subscription access
  • Use Azure Key Vault to securely store secrets and keys, limiting access only to services that need them
  • Rotate credentials and keys regularly to reduce exposure
  • Continuously assessing permissions and limiting access enables a more secure cloud environment.

Perform threat modeling:

Threat modeling is a technique DevSecOps teams can use to systematically evaluate potential security threats and design mitigations. This helps identify high-risk areas in architecture, code, or deployment configurations. Threat modeling typically involves:

  • Mapping out architecture components like apps, resources, trust boundaries, data flows, endpoints, etc.
  • Identifying potential threats like data exfiltration, DoS attacks, account compromise, etc.
  • Prioritizing threats and defining steps to mitigate high risks
  • Validating mitigations actually reduces priority risks

Azure includes threat modeling tools that streamline this process as part of its Security Center and Defender offerings. Building threat modeling into DevSecOps workflows allows systematic uncovering and addressing risks early in development.

Understand the DevOps Threat Matrix:

High-profile attacks originating from DevOps environments have had significant impacts, such as the SolarWinds Orion software attack and the Codecov breach. Microsoft conducted research on techniques adversaries use to attack DevOps environments. The research categorized these techniques into related tactics and mapped them into a threat matrix. The DevOps threat matrix is designed to help defenders understand potential attacker actions. The matrix uses the MITRE ATT&CK framework as a base and focuses on DevOps-specific attack methods.

  1. Initial Access: Techniques for gaining access to DevOps resources like repositories, pipelines, and dependencies.
  2. Execution: Techniques to gain execution access on pipeline resources.
  3. Persistence: Techniques to maintain access to a victim environment.
  4. Privilege Escalation: Techniques to elevate privileges within the victim’s environment.
  5. Credential Access: Techniques to steal credentials.
  6. Lateral Movement: Techniques to move through different resources.
  7. Defense Evasion: Techniques to bypass defenses in a DevOps environment.
  8. Impact: Techniques to exploit access to CI/CD resources for malicious purposes.
  9. Exfiltration: Techniques to exfiltrate sensitive data from the victim environment.
DevOps Threat Matrix

The threat matrix can help defenders understand the attack surface associated with DevOps environments including those in the Azure environment. Understanding the matrix can help to identify weak spots in infrastructure and strengthen defenses.

Enable continuous security monitoring:

Ongoing security monitoring is essential for maintaining a strong cloud security posture. Azure provides several capabilities to enable continuous monitoring including:

  • Azure Defender for Cloud for unified visibility into security across hybrid workloads
  • Azure Defender for advanced threat protection across workloads and data
  • Azure Sentinel for intelligent security orchestration and automated response
  • Azure Monitor for infrastructure and application monitoring
  • Log integration with Azure Sentinel and third-party SIEMs
  • Regular vulnerability scanning for VMs, containers, web apps, databases, etc.
  • File integrity monitoring to detect unexpected changes to critical files

By leveraging these tools, organizations can gain continuous visibility into their Azure environments, rapidly detect threats, and automate responses. This reduces attack dwell time and security team workloads.

Optimize the use of synchronous and asynchronous tests:

Within a DevSecOps pipeline, some security tests are best run synchronously while others are better automated asynchronously.

Synchronous tests run as part of the main pipeline workflow and block deployment if failed. These validate critical requirements and prevent the release of insecure builds. Examples include:

  • Unit and integration tests to validate functionality
  • Source code scans for vulnerabilities using SAST
  • Infrastructure as Code analysis to detect misconfigurations
  • Smoke/sanity testing to verify build integrity

Asynchronous tests run separately from the pipeline workflow after builds are released. These provide ongoing monitoring but don’t block releases. Examples include:

  • DAST vulnerability scanning for running applications
  • Fuzz testing to continuously detect code weaknesses
  • Security monitoring tools to alert on anomalous activity
  • Chaos engineering experiments to test incident response

Optimizing the use of synchronous and asynchronous tests allows rapid validation of core security requirements while enabling ongoing monitoring. This provides fast feedback while continually improving the security baseline.

Leverage automation for security governance:

Automating continuous compliance and security governance is a key DevSecOps capability. Azure offers several tools to help automate governance including:

  • Azure Policy for enforcing security standards on resources using “guardrails”. This helps prevent misconfigurations and block non-compliant resources.
  • Azure Blueprints for defining and deploying collections of policy, templates, and other artifacts to standardize deployments.
  • Cloud Adoption Framework provides structure and best practices for cloud governance.
  • Services like Chef InSpec, Puppet, and Ansible can automatically audit and enforce configurations.
  • Microsoft Intune can manage endpoint security policies and configurations at scale.

By integrating governance tools into CI/CD pipelines, organizations can automatically enforce security standards on every build. Policy as code approaches codify governance best practices and configurations. Automating security governance reduces risk, maintains standards, and frees up security teams.

Implement security chaos engineering:

Chaos engineering injects failures like shutdowns or latencies into production systems to test resilience. Security chaos engineering does this for security-related failures like breaches, DDoS attacks, or credential leaks.

  1. Chaos Engineering Techniques: These techniques can be simple yet effective. They might involve distorting the software’s environment, like deleting data packets or consuming all available memory.
  2. Security Flaws Detection: Chaos tools can expose issues like buffer overflows, which can be exploited by attackers. Fuzzing can reveal flaws in parsing logic, potentially preventing backdoor vulnerabilities.
  3. Sophistication in Chaos Engineering: Some tools use “white box” analysis, guiding the process with knowledge of the software. Techniques like grammatical fuzzing and systematic exploration of execution paths are used.
  4. Chaos Engineering Tools: Many tools, both open-source and proprietary, are available. Examples include ChaosMonkey by Netflix, ChaosToolkit, and Litmus. These tools can introduce chaos at various levels, from the infrastructure to the application layer.
  5. Integration with DevOps: Chaos engineering is becoming a standard part of the development cycle. It’s being integrated into CI/CD pipelines, and many tools are designed to work across different platforms and clouds.
Security Chaos Engineering use cases for Cloud Security

Benefits include:

Integrating chaos experiments into DevSecOps pipelines forces teams to improve detection, response, and recovery capabilities against security failures.

  • Identifying vulnerabilities in detection and response capabilities
  • Improving incident response plans and procedures
  • Increasing resilience against real-world attacks

Prioritize security training:

Enabling developers and operations teams to implement secure solutions is crucial for DevSecOps. Organizations should prioritize ongoing security training to skill up teams on topics like:

- Adopting a “security first” mindset for application design and cloud architecture

- Writing secure code and understanding vulnerabilities like XSS, SQLi, XXE etc.

- Properly implementing identity and access management including authentication and authorization

- Using encryption correctly for data at rest and in transit

- Performing threat modeling to identify software risks

- Understanding and mitigating cloud security risks like misconfigurations or breaches

- Responding to security incidents like breaches or data leaks

Building strong security knowledge across teams is key for DevSecOps. Training helps eliminate knowledge gaps that can lead to mistakes and ultimately security incidents.

Leverage generative AI capabilities:

Generative AI models like GitHub’s Copilot can assist developers in writing more secure code. These models generate code suggestions based on millions of code examples and natural language prompts. Benefits for DevSecOps include:

  • Auto-generating secure code snippets and boilerplate logic to implement authentication, access controls, encryption, input validation, etc. This frees developers to focus on business logic rather than common security needs.
  • Providing context-aware recommendations to fix vulnerabilities identified in source code scans. This makes remediation faster and more accurate.
  • Drafting unit tests to validate security requirements and increase test coverage.
  • Generating infrastructure as code templates with built-in security guardrails aligned to organizational standards.
  • Automating the creation of repeatable security compliance checks and controls.
Generate AI use cases for DevSecOps

Integrating generative AI into Azure DevOps pipelines amplifies developer productivity. It allows faster creation of more secure code. As models continuously train on new code, recommendations improve over time.

Leverage Industry frameworks:

Here are some widely recognized industry frameworks and best practices for DevSecOps that can be used for implementing these best practices:

  • NIST 800–204 — Developed by the National Institute of Standards and Technology, it outlines a process model for integrating Information Security Continuous Monitoring (ISCM) into DevOps pipelines.
  • MITRE ATT&CK Framework — Provides a knowledge base of adversary tactics and techniques to assess and improve defenses in software environments. Useful for threat modeling.
  • Microsoft SDL — Microsoft’s Security Development Lifecycle integrates security practices into every phase of development with threat modeling, abuse testing, auditing, and training.
  • OWASP DevSecOps Guide — Provides guidance on incorporating security tools, practices, and mindset into pipelines from OWASP, the open-source web security community.
  • CIS DevSecOps Benchmarks — Configuration guidelines from the Center for Internet Security for securing development platforms and containers for DevSecOps.
  • BSIMM Framework — Data-driven model for software security initiatives based on real-world practices in large organizations. Focuses on metrics and measurements.

Conclusion:

Cloud-native DevSecOps is a valuable approach to improving the security of your cloud environment. By following the best practices outlined in this blog post, you can help to ensure that your cloud environment is secure and compliant. Implementing robust DevSecOps practices in Azure has huge benefits for improving application security and reducing risk. Taking a “shift left” approach, enabling continuous monitoring, reducing permissions, threat modeling, and training helps embed security across the development lifecycle. Leveraging native Azure capabilities like DevOps, Key Vault, and Security Center strengthens the security posture of cloud-native applications. Mature cloud native DevSecOps makes security a shared responsibility between development, security, and operations teams.

Additional Resources and References

--

--

Arshad R

Experienced Security Leader and Practitioner focused on Cloud Security, Cybersecurity and AI/ML Security | Technical Writer | arshriz@gmail.com | Dallas, TX