Skip to content

fixing CI security issue#380

Merged
okjintao merged 1 commit intomainfrom
cifix032026
Mar 25, 2026
Merged

fixing CI security issue#380
okjintao merged 1 commit intomainfrom
cifix032026

Conversation

@qtipbera
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Validate GitHub Actions workflow to reduce CI security risk when running on pull_request_target, and to ensure linting runs against the PR’s checked-out content rather than the base repository checkout.

Changes:

  • Restricts workflow GITHUB_TOKEN permissions to contents: read.
  • Checks out the PR head repository into a separate ./head directory (instead of the workspace root).
  • Updates the Biome lint step to target ./head.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 56 to +60
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
path: ./head
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

When checking out the PR head in a pull_request_target workflow, use the immutable github.event.pull_request.head.sha instead of head.ref to avoid TOCTOU issues (the branch can move between trigger and checkout). Also set persist-credentials: false on this checkout so the GITHUB_TOKEN isn’t written into ./head/.git/config, which reduces the risk of later steps inadvertently leaking it.

Copilot uses AI. Check for mistakes.

- name: Lint Check
run: pnpx @biomejs/biome@2.0.0 ci
run: pnpx @biomejs/biome@2.0.0 ci ./head
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

biome ci ./head will still auto-discover config starting from the current working directory, so it will use the base repo’s biome.json even if the PR modifies ./head/biome.json. If you want config changes in the PR to be validated as part of this check (without changing CWD), pass Biome a config path (e.g., --config-path ./head or --config-path ./head/biome.json).

Suggested change
run: pnpx @biomejs/biome@2.0.0 ci ./head
run: pnpx @biomejs/biome@2.0.0 ci ./head --config-path ./head

Copilot uses AI. Check for mistakes.
@qtipbera
Copy link
Contributor Author

@okjintao an out-of-scope bug bounty submission flagged this. There's moderate security risk here and this PR should patch the issue.

@okjintao okjintao merged commit 8f49701 into main Mar 25, 2026
9 checks passed
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.

4 participants