Skip to content

Harden cache-memory git restore by scrubbing persisted .git config/info state - #52944

Merged
pelikhan merged 7 commits into
mainfrom
copilot/clear-config-folder-cache
Aug 15, 2026
Merged

Harden cache-memory git restore by scrubbing persisted .git config/info state#52944
pelikhan merged 7 commits into
mainfrom
copilot/clear-config-folder-cache

Conversation

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

cache-memory repositories 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

    • Address persistence of untrusted .git configuration/data in cache-memory repos (GHSA-gh77-fhfh-2mc5 context), specifically stale config/info artifacts surviving restore.
  • Restore-time hardening (setup_cache_memory_git.sh)

    • Remove persisted .git/info override files that can alter repository behavior:
      • exclude, attributes, grafts, sparse-checkout
    • Scrub dangerous persisted config entries/sections while preserving repo metadata:
      • keys: core.fsmonitor, core.sshCommand, core.hooksPath
      • sections: include, includeIf, credential, alias
    • Re-apply known-safe local defaults for this workflow context:
      • user.email=gh-aw@github.com
      • user.name=gh-aw
      • core.hooksPath=/dev/null
      • core.fsmonitor=false
  • Regression coverage (setup_cache_memory_git_test.sh)

    • Add Test 2b to seed malicious/stale .git/config and .git/info/exclude, run setup, and assert the hardened state is enforced.
rm -f .git/info/exclude .git/info/attributes .git/info/grafts .git/info/sparse-checkout
git config --unset-all core.fsmonitor >/dev/null 2>&1 || true
git config --unset-all core.sshCommand >/dev/null 2>&1 || true
git config --unset-all core.hooksPath >/dev/null 2>&1 || true
git config user.email "gh-aw@github.com"
git config user.name "gh-aw"
git config core.hooksPath /dev/null
git config core.fsmonitor false

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.49 AIC · ⌖ 5.77 AIC · ⊞ 8.7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.88 AIC · ⌖ 7.4 AIC · ⊞ 6.3K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 15, 2026 18:28
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Clear cache-memory git repo config/info state on restore Harden cache-memory git restore by scrubbing persisted .git config/info state Aug 15, 2026
Copilot AI requested a review from pelikhan August 15, 2026 18:32
@pelikhan
pelikhan marked this pull request as ready for review August 15, 2026 19:01
Copilot AI balanced review requested due to automatic review settings August 15, 2026 19:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Hardens cache-memory restoration against persisted Git configuration and info state.

Changes:

  • Scrubs selected .git/config and .git/info entries.
  • 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

Comment on lines +194 to +197
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ed8f9e3 by scrubbing remaining command-execution surfaces before checkout/merge: core.attributesFile, filter.*, and merge.*, alongside existing hardening defaults.

Comment on lines +195 to +196
git config --remove-section includeIf >/dev/null 2>&1 || true
git config --remove-section credential >/dev/null 2>&1 || true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread actions/setup/sh/setup_cache_memory_git.sh
Comment thread actions/setup/sh/setup_cache_memory_git_test.sh
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@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 pr-finisher skill after fixes are pushed.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.49 AIC · ⌖ 5.77 AIC · ⊞ 8.7K ·
Comment /souschef to run again

…nfig surfaces

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@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:...

Addressed in commit ed8f9e3.

Implemented all requested fixes in newest-first scope:

  • Expanded regression coverage to seed/assert all scrubbed .git/info and .git/config categories, including subsection forms (includeIf, URL-scoped credential) plus filter/merge command surfaces.
  • Added symlinked .git metadata hardening before any .git operations by detecting symlinked .git/.git/config/.git/info/.git/hooks and reinitializing metadata.
  • Replaced section-only removal with prefix-based local key scrubbing to reliably clear subsection forms.
  • Removed remaining command execution surface via core.attributesFile scrubbing and filter/merge key cleanup.

Validation run:

  • bash actions/setup/sh/setup_cache_memory_git_test.sh
  • make agent-report-progress
  • code_review
  • codeql_checker (no analyzable language changes)

Copilot AI requested a review from gh-aw-bot August 15, 2026 19:41
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot apply same treatment to repo-memory

Copilot AI and others added 2 commits August 15, 2026 19:52
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply same treatment to repo-memory

Done in 0c7c5f09de.

Applied the same hardening to repo-memory setup in actions/setup/sh/clone_repo_memory_branch.sh (scrubbed risky .git/info and command-bearing config surfaces, enforced safe defaults, and guarded symlinked git metadata) and added regression coverage in actions/setup/sh/clone_repo_memory_branch_test.sh.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@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 pr-finisher skill before handing this PR back to maintainers.

Outstanding review items (newest first):

  • maintainer follow-up: apply the same hardening treatment to repo-memory and confirm the new clone path scrubs risky .git config/info state before use.
  • close the loop on any still-open reviewer thread(s) by replying in-thread where appropriate and resolving threads that are already answered by the latest author updates.

Failed checks from the compact candidate set:

  • None listed.

Branch update was requested automatically for this run when GitHub allows it.
Run context: https://github.com/github/gh-aw/actions/runs/31906144084

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.88 AIC · ⌖ 7.4 AIC · ⊞ 6.3K ·
Comment /souschef to run again

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@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 pr-finisher skill before handing ...

Addressed. Repo-memory now has the same hardening in 0c7c5f0 (actions/setup/sh/clone_repo_memory_branch.sh) with regression coverage in actions/setup/sh/clone_repo_memory_branch_test.sh, and branch refresh is in 91d8e05 (merge from main). I also re-ran:

  • bash actions/setup/sh/clone_repo_memory_branch_test.sh
  • bash actions/setup/sh/setup_cache_memory_git_test.sh

Both passed on current HEAD.

@pelikhan
pelikhan merged commit 756a516 into main Aug 15, 2026
26 checks passed
@pelikhan
pelikhan deleted the copilot/clear-config-folder-cache branch August 15, 2026 21:22
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.0

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants