Skip to content

fix(github-auth): add sudo availability check before use#3072

Merged
louisgv merged 1 commit intomainfrom
fix/issue-3069
Mar 28, 2026
Merged

fix(github-auth): add sudo availability check before use#3072
louisgv merged 1 commit intomainfrom
fix/issue-3069

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Mar 28, 2026

Why: Script silently fails with cryptic errors in rootless containers or restricted environments without sudo; now fails fast with a clear error message.

Fixes #3069

Changes:

  • Added command -v sudo check in _install_gh_apt() before assigning SUDO variable
  • Added command -v sudo check in _install_gh_dnf() before assigning SUDO variable
  • Exits with clear error message if non-root and sudo unavailable

-- refactor/security-auditor

In rootless containers or environments without sudo, the script
previously failed with cryptic errors. Now fails fast with a clear
error message when non-root and sudo is unavailable.

Fixes #3069

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

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

Security Review

Verdict: APPROVED
Commit: aad1191

Summary

This PR adds sudo availability checks before attempting to use sudo in _install_gh_apt() and _install_gh_dnf(). The changes are a defensive improvement that prevents cryptic failures in environments where sudo is not available.

Security Analysis

No command injection risk - SUDO variable is set to either empty string or literal "sudo"
Fail-safe behavior - Script errors cleanly if sudo unavailable rather than proceeding unsafely
No privilege escalation - Check prevents attempting sudo when it doesn't exist
Input validation - No user input flows into the SUDO variable
Consistent with existing controls - File already has proper token validation, path traversal protection, SHA256 verification

Compatibility

curl|bash safe - Uses POSIX-compliant command -v sudo, no relative paths
macOS bash 3.x compatible - No bash 4+ features, standard if/then/else structure

Tests

  • bash -n: PASS (syntax check clean)
  • bun test: N/A (no specific test file for github-auth.sh, general test suite has dependency issues in worktree but unrelated to this change)
  • curl|bash: OK (no relative paths, proper error handling)
  • macOS compat: OK (no bash 4+ features)

Findings

No security issues found. This is a low-risk defensive improvement.


-- security/pr-reviewer

@louisgv louisgv added the security-approved Security review approved label Mar 28, 2026
@louisgv louisgv merged commit 4db068d into main Mar 28, 2026
6 checks passed
@louisgv louisgv deleted the fix/issue-3069 branch March 28, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-approved Security review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Missing sudo privilege check in github-auth.sh

2 participants