plugin/waitapproval: approvers list is unenforced, allowing approvals from unauthorized users

未关闭 适合新手
#7,643 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
ci-cd, security

调研方向

从 pkg/app/pipedv1/plugin/waitapproval/waitapproval.go 开始,其中 executeWaitApproval 调用 checkApproval 时只传了 opts.MinApproverNum —— 审批者列表从未传到它那里。将 opts.Approvers 传入 checkApproval,并跳过任何不在该集合中的 cmd.Commander,当某个被拒绝时记录一条警告;pkg/app/pipedv1/plugin/waitapproval/options.go 已经校验该字段并展示了其结构。查找现有的 waitapproval 插件测试,了解阶段命令是如何模拟的,然后添加一个用例:非审批者的 ApproveStage 命令不会到达 STAGE_SUCCESS。完成意味着来自 approvers 之外用户的审批会被忽略,只有已授权的审批才会计入 minApproverNum。

由索引模型根据 Issue 内容生成。

描述

What happened:

In pkg/app/pipedv1/plugin/waitapproval/options.go, the configuration schema for WAIT_APPROVAL stages defines approvers and explicitly validates that it must be set:

type waitApprovalStageOptions struct {
	Approvers      []string `json:"approvers,omitempty"`
	MinApproverNum int      `json:"minApproverNum,omitempty" default:"1"`
}

func (o waitApprovalStageOptions) validate() error {
	if len(o.Approvers) == 0 {
		return fmt.Errorf("approvers must be set")
	}
...

However, in pkg/app/pipedv1/plugin/waitapproval/waitapproval.go:49-80, opts.Approvers is never passed to or validated inside checkApproval:

func (p *plugin) executeWaitApproval(ctx context.Context, in *sdk.ExecuteStageInput[struct{}]) sdk.StageStatus {
...
	if approved := p.checkApproval(ctx, opts.MinApproverNum, lp, in.Client); approved {
		return sdk.StageStatusSuccess
	}
...
}

func (p *plugin) checkApproval(ctx context.Context, minApproverNum int, lp sdk.StageLogPersister, client StageClient) bool {
...
	for cmd, err := range client.ListStageCommands(ctx, sdk.CommandTypeApproveStage) {
...
		if approvedUsersMap[cmd.Commander] {
			continue
		}
		lp.Infof("Got approval from %q", cmd.Commander)
		approvedUsersMap[cmd.Commander] = true
		if len(approvedUsersMap) >= minApproverNum {
			break
		}
	}

Because cmd.Commander is never checked against opts.Approvers, any user who sends an ApproveStage command is accepted and counted towards minApproverNum. This completely bypasses the configured approver authorization boundary, allowing arbitrary non-approver accounts to approve and release deployment stages.

What you expected to happen:

checkApproval should check that cmd.Commander belongs to opts.Approvers before recording it in approvedUsersMap. Approval commands from users outside opts.Approvers should be rejected or ignored with a warning log, and only approvals from authorized approvers should count towards MinApproverNum.

How to reproduce it:

  1. Configure a WAIT_APPROVAL stage with approvers: ["alice"] and minApproverNum: 1.
  2. Submit an ApproveStage command with Commander: "bob".
  3. The plugin logs Got approval from "bob", counts it towards the quota, and marks the stage as STAGE_SUCCESS.

Environment:

  • piped version: master (commit 5dc13c2), pipedv1
  • control-plane version: master
  • Others: N/A
主要语言
Go
星标
1.4k
派生
403
平均合并
2 天 9 小时
30 天内合并 PR
40

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pipe-cd/pipecd 的其他 Issue

查看 pipe-cd/pipecd 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。