Skip to content

Avoid exposing Git credentials in subprocess command-line arguments #402

Description

@bcho

Description

Cachew currently passes repository-scoped authorization credentials to Git using command-line configuration:

git -c credential.helper=<helper containing credential> ...

The credential is embedded as a literal in the helper definition, which exposes it in Git's process arguments. Command-line arguments may be visible through process inspection tools, /proc/<pid>/cmdline, diagnostic tooling, or process telemetry.

PR #321 also identified that credentials are embedded in the helper command, but addressed token refresh during long-running subprocesses. It was closed in favor of #322, which addressed token lifetime and LFS timeouts without removing credentials from process arguments.

Proposed change

Pass credential-bearing Git configuration through Git's environment-based configuration mechanism instead:

GIT_CONFIG_COUNT=<n>
GIT_CONFIG_KEY_<n>=http.<repository-scope>.extraHeader
GIT_CONFIG_VALUE_<n>=Authorization: <credential>

The implementation should:

  • Preserve existing GIT_CONFIG_COUNT, GIT_CONFIG_KEY_*, and GIT_CONFIG_VALUE_* entries.
  • Append the credential configuration at the next available index.
  • Reject malformed, negative, or overflowing GIT_CONFIG_COUNT values.
  • Continue validating the authorization value and repository URL scope.
  • Restrict this change to credential-bearing configuration; ordinary non-sensitive Git configuration can remain in command-line arguments.
  • Ensure credentials do not appear in the generated Git subprocess arguments.

Security impact

This reduces accidental credential disclosure through process listings and command-line capture. The credential remains in the child process environment, as required by Git, so access to process environments should still be restricted appropriately.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions