Harden cache-memory git restore by scrubbing persisted .git config/info state - #52944
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
.git config/info state
There was a problem hiding this comment.
Pull request overview
Hardens cache-memory restoration against persisted Git configuration and info state.
Changes:
- Scrubs selected
.git/configand.git/infoentries. - Adds regression coverage for hardened defaults.
Show a summary per file
| File | Description |
|---|---|
actions/setup/sh/setup_cache_memory_git.sh |
Adds restore-time Git metadata scrubbing. |
actions/setup/sh/setup_cache_memory_git_test.sh |
Tests selected reset behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 4
- Review effort level: Balanced
| git config --remove-section include >/dev/null 2>&1 || true | ||
| git config --remove-section includeIf >/dev/null 2>&1 || true | ||
| git config --remove-section credential >/dev/null 2>&1 || true | ||
| git config --remove-section alias >/dev/null 2>&1 || true |
There was a problem hiding this comment.
Fixed in ed8f9e3 by scrubbing remaining command-execution surfaces before checkout/merge: core.attributesFile, filter.*, and merge.*, alongside existing hardening defaults.
| git config --remove-section includeIf >/dev/null 2>&1 || true | ||
| git config --remove-section credential >/dev/null 2>&1 || true |
There was a problem hiding this comment.
Fixed in ed8f9e3 by replacing section-only removal with local key scrubbing by prefix, which removes subsection forms such as includeIf.* and URL-scoped credential.* entries.
|
@copilot This PR has unresolved review feedback that needs action before maintainers can investigate quickly. Please address the unresolved review threads in newest-first order:
Also refresh the branch and run the
|
…nfig surfaces Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed in commit Implemented all requested fixes in newest-first scope:
Validation run:
|
|
@copilot apply same treatment to repo-memory |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in Applied the same hardening to repo-memory setup in |
|
@copilot Quick triage for maintainer-ready follow-up: Please refresh the branch if GitHub allows it, address the remaining maintainer-facing follow-up, and run the Outstanding review items (newest first):
Failed checks from the compact candidate set:
Branch update was requested automatically for this run when GitHub allows it.
|
Addressed. Repo-memory now has the same hardening in
Both passed on current HEAD. |
|
🎉 This pull request is included in a new release. Release: |
cache-memoryrepositories could carry forward untrusted git state across runs, including config and info overrides. This change hardens restore-time setup by clearing persisted risky state before branch checkout/merge operations.Problem focus
.gitconfiguration/data in cache-memory repos (GHSA-gh77-fhfh-2mc5context), specifically stale config/info artifacts surviving restore.Restore-time hardening (
setup_cache_memory_git.sh).git/infooverride files that can alter repository behavior:exclude,attributes,grafts,sparse-checkoutcore.fsmonitor,core.sshCommand,core.hooksPathinclude,includeIf,credential,aliasuser.email=gh-aw@github.comuser.name=gh-awcore.hooksPath=/dev/nullcore.fsmonitor=falseRegression coverage (
setup_cache_memory_git_test.sh)Test 2bto seed malicious/stale.git/configand.git/info/exclude, run setup, and assert the hardened state is enforced.