Skip to content

Harden docs-deploy.yml against concurrency DoS, TOCTOU, and injection - #31

Merged
reakaleek merged 1 commit into
mainfrom
plaid-rhodium
Mar 26, 2026
Merged

reakaleek merged 1 commit into
mainfrom
plaid-rhodium

Conversation

@reakaleek

Copy link
Copy Markdown
Member

Summary

  • Concurrency group DoS: Append workflow_run.id to the concurrency group key so fork authors cannot craft branch names that cancel legitimate in-flight deploys
  • Least-privilege permissions: Set top-level permissions: {} — every job already declares its own, so this prevents accidental privilege escalation if new jobs are added
  • TOCTOU checkout race: Check out by SHA (needs.preflight.outputs.head-sha) instead of branch name to eliminate the force-push race window
  • Branch name injection: Replace the .. path-traversal check with an allowlist regex (^[a-zA-Z0-9._/+-]+$) to block shell metacharacters, spaces, and newlines
  • Markdown injection: Escape []()\\ in file paths used in PR comment links to prevent crafted filenames from injecting phishing URLs
  • Document required_contexts: []: Add a comment explaining why this bypass is necessary for preview deployments

Test plan

  • Verify a normal PR still gets a docs preview deployed and commented
  • Verify a push to the default branch still triggers build + link index upload
  • Verify a branch name with special characters (e.g. spaces) is rejected at the validation step
  • Confirm fork PRs from non-members are still skipped
  • Confirm fork PRs from org members/owners still receive previews

🤖 Generated with Claude Code

- Append workflow_run.id to concurrency group to prevent fork authors
  from canceling legitimate deploys via branch name collision
- Set top-level permissions to {} so new jobs get no permissions by default
- Checkout by SHA instead of branch name to close TOCTOU race window
- Replace path-traversal-only check with allowlist regex for branch names
- Escape markdown special chars in PR comment file paths to prevent
  link injection
- Document why required_contexts: [] is necessary for preview deployments

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@reakaleek
reakaleek requested review from a team, Mpdreamz and technige March 26, 2026 11:04
@reakaleek reakaleek added the enhancement New feature or request label Mar 26, 2026

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@reakaleek
reakaleek merged commit 866ff9a into main Mar 26, 2026
1 of 2 checks passed
@reakaleek
reakaleek deleted the plaid-rhodium branch March 26, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants