Skip to content

Commit ee9ae46

Browse files
la14-1louisgvclaude
authored
fix: reject control characters in GITHUB_TOKEN validation (#2241)
GITHUB_TOKEN containing newlines, tabs, or carriage returns could corrupt ~/.config/gh/hosts.yml before permissions are set (line 314) and bypass validation in downstream consumers. Defense-in-depth fix following the pattern established in sh/shared/key-request.sh:78. Fixes #2239 Agent: team-lead Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent ba9690e commit ee9ae46

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sh/shared/github-auth.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ ensure_gh_auth() {
289289
return 1
290290
;;
291291
esac
292+
# SECURITY: Reject tokens containing newlines, tabs, or carriage returns
293+
# to prevent credential file corruption and bypass of downstream validation.
294+
if [[ "${GITHUB_TOKEN}" =~ $'\n' ]] || [[ "${GITHUB_TOKEN}" =~ $'\t' ]] || [[ "${GITHUB_TOKEN}" =~ $'\r' ]]; then
295+
log_error "GITHUB_TOKEN contains invalid control characters (newline/tab/CR)"
296+
return 1
297+
fi
292298

293299
# Fast path: skip persistence if gh is already authenticated with
294300
# stored credentials (not just the env var). Temporarily unset

0 commit comments

Comments
 (0)