You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
drift_check: GitHub token embedded in clone URL can surface in error output and process list #105
scripts/drift_check/snapshot.py authenticates remote clones by embedding the token in the clone URL. When a clone fails, the error message contains the full git argv, and cli.py prints it to stderr.
GitHub Actions masks the token only when it is a registered secret. Local runs, other CI systems, or tokens passed by other means print it in plain text. The token is also visible in the process list for the length of the clone. This is the fleet-wide drift checker, so it runs regularly against many repos.
This is a hardening item for maintainers who run the checker. It does not give outside parties any capability.
Evidence
scripts/drift_check/snapshot.py:320 builds the clone URL with the token as URL userinfo.
scripts/drift_check/snapshot.py around line 291: _run_git raises RemoteSnapshotError(f"git {' '.join(args)} failed (rc=...)..."), which includes that URL.
Reproduced locally with a dummy token against a repo that doesn't exist: the dummy value appeared verbatim in the error.
Related: _run_git and report/issue.py::_default_gh_runner call subprocess.run with no timeout=, so a hung network clone blocks the job until the Actions job timeout.
shutil.rmtree(tmp, ignore_errors=True) (around snapshot.py:330) can leave temp clones behind on Windows because git pack files are read-only.
Suggested approach
Pass credentials outside the URL: GIT_CONFIG_COUNT / GIT_CONFIG_KEY_0=http.https://github.com/.extraheader / GIT_CONFIG_VALUE_0 in the subprocess env, or a credential helper.
As defense in depth, redact the token from any error string in _run_git.
Add timeout= to the git and gh subprocess calls.
Use an onexc handler that clears the read-only bit before deleting.
Add a unit test asserting RemoteSnapshotError text never contains the token.
Done when
The token never appears in argv or error output, and a test proves it.
Activity