Skip to main content

Research

Preventing Workload Identity Theft in GitLab CI Runners

Secure workload identity practices for GitLab CI runners and CI pipeline gate design

Pentrova Research Pentrova Research
6 min read

Reading mode

What is Workload Identity?#

Workload identity refers to the authentication and authorization of workloads, such as applications and services, in a CI/CD pipeline. It is essential to implement secure workload identity practices to prevent identity theft and ensure secure authentication and authorization. Workload identity is a critical aspect of CI/CD security, as explained in the OWASP Cheat Sheet Series.

How Workload Identity Federation Works#

Workload identity federation is a mechanism that allows workloads to authenticate and authorize with external services without managing long-lived secrets directly. It uses OpenID Connect (OIDC) or to federate identities between the CI/CD platform and the external service. This allows workloads to access external services without having to manage credentials or secrets, reducing the risk of identity theft and unauthorized access. Workload identity federation works by establishing a trust relationship between the CI/CD platform and the external service, allowing the workload to authenticate and authorize with the external service using a short-lived token or credential. This token or credential is typically obtained through an OIDC or flow, and is used to authenticate and authorize the workload with the external service. By using workload identity federation, organizations can simplify their CI/CD pipelines, reduce the risk of identity theft, and improve security. Additionally, workload identity federation can also help improve compliance with regulatory requirements, such as those related to data protection and access control. Overall, workload identity federation is an important security mechanism that can help organizations secure their CI/CD pipelines and prevent identity theft.

Trust Boundary and Configuration#

The trust boundary is a critical aspect of workload identity federation, as it defines the scope of trust between the CI/CD platform and the external service. Configuring the trust boundary and implementing workload identity federation requires careful consideration of the security risks and threats associated with compromised runners. The IETF draft on workload identity practices provides guidance on configuring the trust boundary.

Comparison of Identity Federation Approaches#

The following table compares different identity federation approaches, including OpenID Connect (OIDC) and :

ApproachAdvantagesDisadvantages
OpenID Connect (OIDC)Provides authentication and authorization, widely adoptedCan be complex to implement
Provides authorization, widely adoptedDoes not provide authentication
Bottom line: OpenID Connect (OIDC) is a widely adopted approach that provides both authentication and authorization, while provides authorization only.

Security Risks and Threats#

Compromised runners pose significant security risks and threats, including the potential for identity theft and unauthorized access to sensitive data. When a runner is compromised, an attacker can gain access to the runner’s credentials and use them to authenticate and authorize with external services. This can lead to a range of malicious activities, including data theft, tampering, and unauthorized access to sensitive systems. To mitigate these risks, it is essential to implement secure workload identity practices, such as configuring the trust boundary, implementing workload identity federation, and protecting secrets and credentials. Regularly reviewing and updating configurations to ensure they are secure and aligned with best practices is also crucial. Additionally, monitoring for suspicious activity and having incident response plans in place can help detect and respond to potential security incidents. By taking these steps, organizations can reduce the risk of identity theft and ensure secure authentication and authorization in their CI/CD pipelines. Furthermore, implementing secure workload identity practices can also help prevent lateral movement in the event of a breach, reducing the overall attack surface and minimizing the potential damage.

How to Implement Secure Workload Identity in GitLab CI Runners#

Implementing secure workload identity in GitLab CI runners involves several steps. First, configure the trust boundary to define the scope of trust between the CI/CD platform and the external service. This includes defining the external services that the workload is allowed to access, as well as the credentials or secrets that are required to authenticate and authorize with those services. Next, implement workload identity federation using OpenID Connect (OIDC) or . This involves configuring the CI/CD platform to use OIDC or to federate identities with the external service, and obtaining a short-lived token or credential that can be used to authenticate and authorize the workload. Protecting secrets and credentials is also crucial, and can be achieved by using environment variables and secure storage. Additionally, regularly reviewing and updating configurations to ensure they are secure and aligned with best practices is essential. By following these steps, organizations can implement secure workload identity in their GitLab CI runners, reducing the risk of identity theft and unauthorized access to sensitive data. It is also important to have a process in place for regularly reviewing and updating configurations, as well as for responding to potential security incidents. This can include having a incident response plan in place, as well as conducting regular security audits and risk assessments. Furthermore, using tools such as GitLab’s built-in security features, such as GitLab CI/CD variables and secure files, can also help improve the security of workload identity in GitLab CI runners.

Verification and Monitoring#

Verifying and monitoring workload identity configurations is essential to prevent identity theft and ensure secure authentication and authorization. Regularly reviewing and updating configurations to ensure they are secure and aligned with best practices is crucial. This includes verifying that the trust boundary is correctly configured, that workload identity federation is properly implemented, and that secrets and credentials are protected. Monitoring for suspicious activity, such as unexpected authentication or authorization requests, can also help detect potential security incidents. Additionally, implementing logging and auditing mechanisms can provide visibility into workload identity-related activities, making it easier to detect and respond to security incidents. By continuously verifying and monitoring workload identity configurations, organizations can ensure that their CI/CD pipelines are secure and that identity theft is prevented. It is also important to have a process in place for regularly reviewing and updating configurations, as well as for responding to potential security incidents. This can include having a incident response plan in place, as well as conducting regular security audits and risk assessments.

FAQ#

What is the difference between OpenID Connect and ?#

OpenID Connect (OIDC) provides authentication and authorization, while provides authorization only.

How can I protect secrets and credentials in my CI/CD pipeline?#

Protect secrets and credentials by using environment variables and secure storage, as explained in the OWASP Cheat Sheet Series.

What are the security risks associated with compromised runners?#

Compromised runners pose significant security risks and threats, including the potential for identity theft and unauthorized access to sensitive data, as explained in GitHub’s documentation on compromised runners.

Written by

Pentrova Research Pentrova Research

Pentrova Research writes about offensive security, LLM-driven pentest chains, and how to ship exploit-grade evidence into engineering pipelines.

Cross-Role Authorization Testing

Catch BOLA flaws that return HTTP 200 OK

Traditional scanners miss logic flaws in valid JSON responses. Pentrova maps multi-tenant object access across roles to prove BOLA before merge.

Test API Authorization →

Keep reading

Site search

↑↓ navigateEnter openEsc close