[DNM] fix(security): backport v0.48.0 fixes to v0.42.x#2761
Conversation
Validate GitHub App webhook payloads before minting tokens and avoid trusting a forged enterprise host header. Also include the upstream App token scoping and remote-resource deep-copy fixes needed for the same supported release stream. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Download the branch-compatible golangci-lint binary into tmp and use it from make lint-go. Pin GOTOOLCHAIN for local make targets and PAC Go steps so linting does not drift with the host Go installation. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Signed-off-by: Shubham Bhardwaj <shubbhar@redhat.com>
There was a problem hiding this comment.
Code Review
This pull request introduces several security and robustness improvements, including validating GitHub App webhook signatures and enterprise hosts before minting tokens, and deep-copying cached remote pipelines and tasks to prevent cross-run mutation leaks. It also updates various dependencies, pins the golangci-lint version in the Makefile, and migrates test requests to use context-aware constructors. The review feedback highlights three critical issues: a potential nil pointer dereference in pkg/resolve/remote.go when calling .DeepCopy() on an unchecked pipeline, an invalid golangci-lint version (v2.12.2) in the Makefile that will cause download failures, and a potential nil pointer dereference in pkg/provider/github/parse_payload.go if the retrieved Kubernetes secret's data is nil.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // if PipelineRef is used then, first resolve pipeline and replace all taskRef{Finally/Task} of Pipeline, then put inlinePipeline in PipelineRun | ||
| if pipelinerun.Spec.PipelineRef != nil && pipelinerun.Spec.PipelineRef.Resolver == "" { | ||
| pipelineResolved := fetchedResourcesForPipelineRun.Pipeline | ||
| pipelineResolved := fetchedResourcesForPipelineRun.Pipeline.DeepCopy() |
There was a problem hiding this comment.
Calling .DeepCopy() on fetchedResourcesForPipelineRun.Pipeline without a nil check can lead to a nil pointer dereference panic if the pipeline fails to resolve or is not found. Ensure that fetchedResourcesForPipelineRun.Pipeline is not nil before copying.
if fetchedResourcesForPipelineRun.Pipeline == nil {
return nil, fmt.Errorf("pipeline %s not found", pipelinerun.Spec.PipelineRef.Name)
}
pipelineResolved := fetchedResourcesForPipelineRun.Pipeline.DeepCopy()| TARGET_NAMESPACE=pipelines-as-code | ||
| HUGO_VERSION=0.96.0 | ||
| GOLANGCI_LINT=golangci-lint | ||
| GOLANGCI_LINT_VERSION ?= v2.12.2 |
There was a problem hiding this comment.
| if err != nil { | ||
| return "", err | ||
| } | ||
| return strings.TrimSpace(string(secret.Data[controllerWebhookSecretKey])), nil |
There was a problem hiding this comment.
If secret.Data is nil (which can happen if the Kubernetes Secret has no data fields), indexing it with secret.Data[controllerWebhookSecretKey] will cause a nil pointer dereference panic. A defensive check should be added to ensure secret.Data is not nil before accessing its keys. Additionally, use bytes.TrimSpace to trim whitespace from the secret data, following the project's convention.
| return strings.TrimSpace(string(secret.Data[controllerWebhookSecretKey])), nil | |
| if secret.Data == nil { | |
| return "", fmt.Errorf("secret %s has no data", run.Info.Controller.Secret) | |
| } | |
| return string(bytes.TrimSpace(secret.Data[controllerWebhookSecretKey])), nil |
References
- Webhook payloads should be trimmed of whitespace using
bytes.TrimSpacebefore being processed, as this is the established convention in the project.
📝 Description of the Change
[DNM] Backport of the security fixes released in v0.48.0 to release-v0.42.x.
This PR backports the public security hardening from v0.48.0:
?secret=values are not written to stdout.How this backport was done:
release-v0.42.xin a dedicated worktree.make lint-gouse the same known-good linter binary fromtmp/.go-jose/v3,go-jose/v4, andtektoncd/pipeline.👨🏻 Linked Jira
N/A
🔗 Linked GitHub Issue
N/A
🧪 Testing Strategy
Validation run locally:
make testmake lint-gogo test ./pkg/adapterafter the incoming webhook log redaction backportgit diff --checkThe normal pre-push hooks completed successfully for this branch when pushed.
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.