Skip to content

🔒 Prevent upload during init#14558

Merged
dsyme merged 1 commit intomainfrom
keys
Feb 8, 2026
Merged

🔒 Prevent upload during init#14558
dsyme merged 1 commit intomainfrom
keys

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Feb 8, 2026

Summary

  • Enhanced security for GitHub Actions workflow initialization
  • Removed automatic GitHub token retrieval during secret setup
  • Added safeguards to prevent unintended personal token uploads

Details

The changes focus on improving security during the repository initialization process by:

  • Explicitly checking only environment variables for secrets
  • Removing automatic fallback to GitHub CLI token
  • Setting default confirmation to "No" for secret configuration
  • Adding clear security-focused comments explaining the rationale

The modifications ensure users have more control and awareness when setting up repository secrets, particularly for sensitive tokens like GitHub authentication credentials.

Copilot AI review requested due to automatic review settings February 8, 2026 19:46
@dsyme dsyme changed the title 🔒 Prevent accidental GitHub token upload during init 🔒 Prevent upload during init Feb 8, 2026
Copy link
Contributor

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

Improves security of the interactive init flow by preventing implicit use of the user’s gh auth token when configuring repository secrets, reducing the chance of accidentally uploading a personal token to the repo during initialization.

Changes:

  • Removed parser.GetGitHubToken() fallback for COPILOT_GITHUB_TOKEN during init secret detection and setting.
  • Updated the init confirmation prompt messaging to emphasize that secrets will be uploaded and that the default choice is to skip.
  • Added security-focused inline comments explaining why init should only use explicitly-provided environment variables.
Comments suppressed due to low confidence (1)

pkg/cli/init.go:352

  • This COPILOT_GITHUB_TOKEN switch case re-reads the same environment variable (secretName already equals "COPILOT_GITHUB_TOKEN" here), so it doesn’t provide an actual alternative name. Consider removing the case or mapping to real alternative env var names to keep the “Try alternative names” logic meaningful.
		case "COPILOT_GITHUB_TOKEN":
			// Only check explicit environment variable, do NOT use gh auth token fallback
			// This prevents accidentally uploading user's personal token to the repository
			secretValue = os.Getenv("COPILOT_GITHUB_TOKEN")

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

// The init command should only detect explicitly set environment variables, not scrape
// the user's gh auth token. Using gh auth token for secrets would be a security risk
// as users may not realize their personal token is being uploaded to the repository.
// The trial command handles this differently with explicit warnings.
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The comment says “The trial command handles this differently with explicit warnings,” but the trial flow appears to set COPILOT_GITHUB_TOKEN via parser.GetGitHubToken()/prompts without an explicit warning about uploading a personal gh auth token. Please either add the referenced warning in the trial path or reword/remove this sentence so the security rationale comment stays accurate.

Suggested change
// The trial command handles this differently with explicit warnings.
// If other flows use a gh auth token as a fallback, they must include explicit warnings

Copilot uses AI. Check for mistakes.
Comment on lines 216 to +219
case "COPILOT_GITHUB_TOKEN":
// Use the proper GitHub token helper
secretValue, _ = parser.GetGitHubToken()
// Only check explicit environment variable, do NOT use gh auth token fallback
// This prevents accidentally uploading user's personal token to the repository
secretValue = os.Getenv("COPILOT_GITHUB_TOKEN")
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

This COPILOT_GITHUB_TOKEN branch is redundant: secretValue was already initialized with os.Getenv(spec.Name), and spec.Name is "COPILOT_GITHUB_TOKEN". Consider removing this case (or using it for true alternative env var names) to avoid implying extra lookup logic that doesn’t change behavior.

This issue also appears on line 349 of the same file.

See below for a potential fix:


Copilot uses AI. Check for mistakes.
@dsyme dsyme merged commit 6c3f14a into main Feb 8, 2026
125 checks passed
@dsyme dsyme deleted the keys branch February 8, 2026 19:50
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.

2 participants