Skip to content

fix(ci): remediate dangerous pull request triggers - #132

Merged
yvonnedevlinrh merged 1 commit into
unbound-force:mainfrom
yvonnedevlinrh:opsx/fix-zizmor-dangerous-triggers
Oct 12, 2026
Merged

yvonnedevlinrh merged 1 commit into
unbound-force:mainfrom
yvonnedevlinrh:opsx/fix-zizmor-dangerous-triggers

Conversation

@yvonnedevlinrh

@yvonnedevlinrh yvonnedevlinrh commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #127

Removes privileged dependency-review execution by moving it from pull_request_target to pull_request.

Adds safe handling for restricted GitHub tokens: report-comment writes skip with an actionable notice, while denied approval writes fail closed and require manual review. Documents the Fullsend trust boundary and scopes its unavoidable zizmor exception to dangerous-triggers in fullsend.yaml.

How to Test

go test -race -count=1 ./internal/workflowtest
make check
make coverage && make check-coverage

CI should also run MegaLinter, zizmor, and actionlint.

How to Demo

Open a Dependabot pull request targeting main:

  1. Confirm the dependency workflow runs on pull_request.
  2. Confirm it does not check out pull-request code.
  3. Confirm a restricted-token report write emits a notice and safely skips.
  4. Confirm a restricted-token approval write fails closed without approving the pull request.

Key Files Changed

  • .github/workflows/ci_dependencies.yml: use unprivileged pull-request execution and handle denied write APIs.
  • .github/zizmor.yml: add the issue-security(ci): remediate or narrowly justify zizmor dangerous-triggers findings #127-authorized Fullsend exception.
  • internal/workflowtest/ci_dependencies_test.go: cover trigger, exception scope, and restricted-token paths.
  • docs/ci-workflow-security.md: document both workflow trust boundaries.
  • openspec/changes/fix-zizmor-dangerous-triggers/: proposal, design, specification, and completed tasks.
  • AGENTS.md: require scanner-environment verification before treating local govulncheck output as a repository regression.

This PR was generated by /uf.finale (AI-assisted).

@yvonnedevlinrh
yvonnedevlinrh requested a review from a team as a code owner October 8, 2026 17:10
@yvonnedevlinrh yvonnedevlinrh self-assigned this Oct 8, 2026
@yvonnedevlinrh
yvonnedevlinrh force-pushed the opsx/fix-zizmor-dangerous-triggers branch 2 times, most recently from 6e34af9 to eebfc15 Compare October 9, 2026 13:15
@yvonnedevlinrh

Copy link
Copy Markdown
Contributor Author

This follows ComplyTime's established dependency-workflow model, rather than reintroducing pull_request_target.

Why the split is safe:

  • The workflow runs on pull_request, so fork-originated PRs receive restricted tokens and do not receive repository secrets.
  • Default permissions are read-only. pull-requests: write is granted only to the two Dependabot-specific writeback jobs.
  • Those jobs require github.event.pull_request.user.login == 'dependabot[bot]' and do not check out or execute pull-request code.
  • The reusable reviewers are pinned, read-only workflows. Their checkout of the Dependabot head uses persist-credentials: false and is limited to Git metadata/diff analysis; it does not run project scripts, tests, hooks, or PR workflow files.
  • Write failures are handled deliberately: comments report and skip when GitHub restricts the token; approval fails closed, so a restricted token cannot accidentally approve a PR.
  • The dangerous-triggers exception is narrowly scoped to this documented Dependabot automation.

The trust boundary is intentional: contributors who can open branches in this repository are trusted collaborators. For untrusted contributors, pull_request keeps the token restricted; pull_request_target would instead expose a privileged base-context token and is therefore avoided.

This matches the upstream ComplyTime template at org-infra@bd3718a.

@yvonnedevlinrh
yvonnedevlinrh force-pushed the opsx/fix-zizmor-dangerous-triggers branch from eebfc15 to d359ac1 Compare October 12, 2026 12:38

@marcusburghardt marcusburghardt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: #132 — fix(ci): remediate dangerous pull request triggers

Verdict: APPROVE

The pull_request_target → pull_request migration is correctly implemented end-to-end: trigger change, all event-name guards, static-signal validation, concurrency group key, and structural tests that lock in regressions are all consistent. Restricted-token handling fails closed for approvals and skips safely for comments, with both paths covered by new tests. The Fullsend zizmor exception is the minimum possible scope (one rule, one file) and is byte-for-byte verified by a test citing the authorization issue.

Two LOW findings noted as inline comments — neither blocks merge.

This review was generated by /uf.review-pr (AI-assisted).

}
core.notice('Automated approval skipped: this pull-request token cannot write reviews. A maintainer must approve the Dependabot update manually.');
core.setFailed('Manual review required: token cannot approve this Dependabot pull request.');
throw new Error('Token cannot approve this Dependabot pull request.');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Triple failure signal in restricted-token catch block

core.setFailed() (line 316) already marks the job as failed. The subsequent throw new Error(...) causes actions/github-script to call core.setFailed again with the thrown error message, producing two redundant failure annotations in the job summary. Fail-closed behavior is preserved — this is cosmetic only.

Consider removing either the throw or the core.setFailed call to avoid duplicate annotations. The core.setFailed alone is sufficient to fail the job and surface the message.

].join('\n'),
});
} catch (error) {
const restrictedTokenError = error?.status === 403

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] restrictedTokenError defined inconsistently across comment and approval paths

In the comment script (line 142), restrictedTokenError is a function: const restrictedTokenError = (error) => .... Here in the approval script, it's an inline boolean: const restrictedTokenError = error?.status === 403 && .... Both detect the same condition correctly, but the inconsistency increases maintenance surface — a future editor updating one must remember the other uses a different pattern.

Consider extracting a shared helper or using the same pattern in both scripts.

- Run dependency review without privileged pull-request execution
- Scope and document the Fullsend zizmor exception
- Cover restricted-token write degradation in workflow policy tests

Assisted-by: gpt-5.6-terra
Generated with AI assistance (gpt-5.6-terra)
@yvonnedevlinrh
yvonnedevlinrh force-pushed the opsx/fix-zizmor-dangerous-triggers branch from d359ac1 to 8e66020 Compare October 12, 2026 13:49
@yvonnedevlinrh
yvonnedevlinrh merged commit da9f83e into unbound-force:main Oct 12, 2026
12 of 20 checks passed
@yvonnedevlinrh
yvonnedevlinrh deleted the opsx/fix-zizmor-dangerous-triggers branch October 12, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(ci): remediate or narrowly justify zizmor dangerous-triggers findings

2 participants