Skip to content

Commit 39a3350

Browse files
authored
add(vulnerabilities): blog about SLSA in Nais context (#38)
1 parent c16d16a commit 39a3350

File tree

5 files changed

+241
-0
lines changed

5 files changed

+241
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: "Building a secure platform"
3+
description: "Strengthening Supply Chain Security on Nais"
4+
date: 2024-12-08T14:12:01+02:00
5+
draft: false
6+
author: Youssef Bel Mekki
7+
tags: [ slsa, security, supplychain, vulnerabilities ]
8+
language: en
9+
---
10+
11+
![signed.png](./images/signed.png)
12+
13+
The [Nais](https://docs.nais.io/) platform supports over 1,700 applications, ranging from simple web pages to complex
14+
data processing systems, built by more than 250 teams. These teams differ in size and focus—some prioritize security,
15+
while others emphasize speed and agility.
16+
17+
Our goal is to ensure every application on the platform is both secure and reliable. This means giving teams the tools
18+
they need to identify and fix vulnerabilities quickly and efficiently.
19+
20+
## The Nais golden path
21+
22+
There are many ways for a malicious actor to compromise an application, even before the code is committed. From A to H,
23+
there are numerous potential vulnerabilities that we must be aware of and proactively address.
24+
25+
![supply-chain-threats](./images/supply-chain-threats.svg)
26+
[slsa-threats-overview](https://slsa.dev/spec/v1.0/threats-overview)
27+
28+
By collaborating with our AppSec team, we work to identify the most common methods attackers use to compromise code and
29+
implement measures to prevent them.
30+
31+
![supply-chain-modified](./images/supply-chain-modified.png)
32+
33+
### Secure by design
34+
35+
To achieve this, we secure every layer of the platform infrastructure. This includes enforcing security policies across
36+
clusters and namespaces with tools like network policies with egress control, pod security policies, and RBAC. Hardened
37+
container images provide a secure foundation, and tools like [TokenX](https://docs.nais.io/auth/tokenx/),
38+
which facilitates secure token exchange between applications for maintaining strict access control, strengthen
39+
application-level security.
40+
41+
We also introduced [Texas](https://docs.nais.io/auth/explanations/?h=texas#texas), which stands for Token Exchange as a
42+
Service. It simplifies the process of working with OAuth 2.0 and JWTs, handling the complexities of user authentication
43+
and authorization so our teams doesn’t have to, following
44+
`The Nais golden path`.
45+
46+
## From concept to implementation
47+
48+
It all started with an idea from my colleague Tommy: What if we could sign container images before pushing them to a
49+
registry and then scan them for vulnerabilities? The results could be displayed in an intuitive interface, making it
50+
easier for teams to take action. It might not have been exactly like that, but that’s how I remember it.
51+
52+
In June 2021, Google introduced the [SLSA](https://slsa.dev/) (Supply-chain Levels for Software Artifacts) framework.
53+
Inspired by this, we focused on three key goals:
54+
55+
* Automated Image Signing: Automatically sign container images in the CI/CD pipeline.
56+
* Vulnerability Scanning: Scan the Software Bill of Materials ([SBOM](https://www.cisa.gov/sbom)) to detect
57+
vulnerabilities.
58+
* Searchable Vulnerability Visibility: Enable teams to easily find and view vulnerabilities in their applications.
59+
60+
## The journey
61+
62+
### Early challenges and solutions
63+
64+
Our dependency tracking journey began in December 2021. We aimed to automate every step from code commit to deployment,
65+
giving teams detailed insights into their applications' vulnerabilities and dependencies.
66+
67+
This approach gained urgency with the discovery of the Log4Shell vulnerability in November 2021. Initially, we relied on
68+
scripts to locate affected workloads. For example, [Terje](https://github.com/terjesannum/scan-log4j) proposed scanning
69+
container filesystems for vulnerable Log4j
70+
JAR files. While effective, we recognized the need for proactive solutions.
71+
72+
### Tool integration and custom Solutions
73+
74+
We started with a simple goal: detect an application’s programming language, generate an SBOM, and securely sign both
75+
the SBOM and the container image before uploading them to the registry. Signing was challenging,
76+
but [Cosign](https://www.sigstore.dev/) from Sigstore (released in 2021) proved to be a perfect fit due to its
77+
simplicity and reliability.
78+
79+
By October 2021, Trivy introduced SBOM generation for container images. This allowed us to shift focus to other
80+
priorities. We integrated [Trivy](https://trivy.dev/latest/) for both vulnerability scanning and SBOM generation,
81+
accelerating our progress.
82+
83+
To visualize vulnerabilities, we turned to the [OWASP Dependency-Track](https://dependencytrack.org/) project. Using its
84+
REST API, we populated data and built a custom visualization in the Nais Console. This interface focuses on active
85+
workloads in clusters and their vulnerabilities.
86+
87+
### Custom cluster monitoring: Slsa-verde
88+
89+
To further enhance security, we developed slsa-verde, a Kubernetes cluster monitor inspired by the SLSA framework. Its
90+
key responsibilities include:
91+
92+
* Monitoring Workloads: Actively tracks container images used in Kubernetes clusters.
93+
* Verifying Image Attestations: Ensures images are signed by trusted entities.
94+
* Integrating with Dependency-Track: Extracts SBOMs from images, submits them for analysis.
95+
* Data Synchronization: Maintains real-time records of active images and aligns them with Kubernetes applications.
96+
97+
This tool ensures that vulnerability data is accurate, up-to-date, and actionable, helping teams respond quickly to
98+
potential threats.
99+
100+
### Details
101+
102+
![img.png](./images/img.png)
103+
104+
* Nais developers push their code to GitHub.
105+
* A [Nais action](https://github.com/nais/docker-build-push) builds the code, creates an SBOM, and signs the container
106+
image.
107+
* The attestation can be tracked in the [Rekor transparency log](https://docs.sigstore.dev/logging/overview/).
108+
* The container image and SBOM are uploaded to the container registry.
109+
* The workload is deployed to the Nais platform.
110+
* SLSA-verde watches for new workloads in the cluster.
111+
* SLSA-verde verifies the image signature, checks its source, and extracts the SBOM.
112+
* SLSA-verde sends the SBOM to Dependency-Track for analysis.
113+
114+
Developers can view vulnerabilities directly in the Nais Console. The entire process, from pushing code to seeing
115+
vulnerability insights, takes only a few minutes, depending on the size of the image and the actions performed.
116+
117+
## Nais to have
118+
119+
* Visualize historical data to monitor vulnerabilities over time.
120+
121+
122+
* Track data from the commit where the vulnerability was introduced.
123+
* Record when the vulnerability was fixed.
124+
* Measure lead time for resolving vulnerabilities.
125+
* Track when the vulnerability was first deployed.
126+
127+
128+
* Provide alerts and notifications management in the Nais Console.
129+
* Enable filtering of alerts by cluster and severity.
130+
* Deliver alerts to preferred channels (e.g., Slack, email, etc.).
131+
132+
## Next step
133+
134+
Increase awareness among teams about vulnerabilities in their applications with real-time insights.
135+
This is not always so simple due to a large number of applications and teams, in a medium-sized organization.
136+
We are working on improving our communication channels to ensure that teams are aware of the vulnerabilities in their
137+
applications and is proactive in addressing them. To achieve this, we plan to:
138+
139+
* Require all applications to include an SBOM.
140+
* Block deployments of images without an SBOM.
141+
* Provide teams with [more tools](#nais-to-have) to prepare for the next zero-day.
142+
* Enforce stricter deployment restrictions for applications with critical vulnerabilities.
143+
144+
## Conclusion
145+
146+
Building a secure platform that supports over 1,700 applications across 250 teams is a complex and ongoing challenge. At
147+
Nais, we work to ensure every application is secure and reliable by giving teams the tools they need to quickly find and
148+
fix vulnerabilities.
149+
150+
From the start, we’ve focused on securing every layer of our platform. Tools like TokenX and Texas make token exchanges
151+
and authentication easier, while frameworks like SLSA help us automate key processes like image signing, SBOM
152+
generation, and vulnerability scanning to secure the software supply chain.
153+
154+
Using tools like Trivy and OWASP Dependency-Track, we’ve improved visibility into vulnerabilities and dependencies.
155+
Custom solutions like slsa-verde strengthen security by monitoring Kubernetes clusters, verifying images, and keeping
156+
vulnerability data accurate and actionable.
157+
158+
As new threats emerge, we continue to adapt. By working with our AppSec team, we identify common risks and take steps to
159+
prevent them. Next, we plan to require SBOMs for all applications, block deployments without them, and enforce stricter
160+
controls for critical vulnerabilities. We’re also improving communication and real-time alerts to help teams respond
161+
quickly to threats.
162+
163+
Our goal is simple: to create a secure, reliable platform that helps teams build better applications while staying ahead
164+
of potential risks.
Loading
Loading
Loading

0 commit comments

Comments
 (0)