Skip to content

fix: remove lifecycle hook auto-sync#241

Merged
Maleick merged 1 commit into
mainfrom
bug/propose-fix-for-auto-sync-vulnerability
May 11, 2026
Merged

fix: remove lifecycle hook auto-sync#241
Maleick merged 1 commit into
mainfrom
bug/propose-fix-for-auto-sync-vulnerability

Conversation

@Maleick
Copy link
Copy Markdown
Owner

@Maleick Maleick commented May 11, 2026

Motivation

  • The lifecycle hooks previously ran an automatic git pull origin main from the hook working directory which can mutate the user's workspace and violate the approval/authorship boundary.
  • Silent remote merges can introduce attacker-controlled changes or trigger repo-local Git hooks before any explicit user approval, so the auto-sync is a security and integrity risk.

Description

  • Removed the auto-sync code paths that resolved the repo root and executed git pull origin main from hooks/init.sh, hooks/stop.sh, and hooks/verify-package.sh.
  • Each hook now proceeds directly to its prior responsibilities (session checklist/state handling, stop state update flow, and package dry-run verification) without attempting networked writes to the current workspace.
  • No other behavioral changes were introduced beyond removing the auto-sync blocks.

Testing

  • Ran npm run typecheck and npm run build and both completed successfully.
  • Ran the full test suite with npm test which initially failed before building due to missing dist artifacts but passed after npm run build, resulting in all tests passing.
  • Ran package verification with npm run verify:pack which initially failed when dist files were absent and succeeded after building, and a repository-wide search confirms no remaining autoresearch-sync/git pull code remains in hooks or .opencode-plugin.

Codex Task

Copilot AI review requested due to automatic review settings May 11, 2026 04:12
@Maleick Maleick merged commit 4842165 into main May 11, 2026
2 of 3 checks passed
@Maleick Maleick deleted the bug/propose-fix-for-auto-sync-vulnerability branch May 11, 2026 04:14
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.18.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the lifecycle-hook “auto-sync” behavior that performed an implicit git pull origin main, avoiding unapproved workspace mutation and reducing the security/integrity risk of remote-triggered changes during hook execution.

Changes:

  • Removed the git rev-parse/git log/git pull auto-sync blocks from hooks/init.sh.
  • Removed the same auto-sync logic from hooks/stop.sh.
  • Removed the same auto-sync logic from hooks/verify-package.sh.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
hooks/init.sh Removes hook-time repo auto-sync so init runs without mutating the user workspace.
hooks/stop.sh Removes hook-time repo auto-sync so stop flow avoids networked writes/merges.
hooks/verify-package.sh Removes hook-time repo auto-sync so package verification stays deterministic/offline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/init.sh
Comment on lines 4 to 6

set -e

Comment thread hooks/stop.sh
Comment on lines 4 to 9

set -e

# ── Auto-sync: pull latest plugin code before stop ──
if [ -z "${AUTORESEARCH_NO_SYNC:-}" ]; then
repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)"
if [ -n "$repo_root" ]; then
cd "$repo_root" || exit 1
# Only sync if we have a valid git remote (skip temp/policy-test repos)
if git rev-parse --verify HEAD >/dev/null 2>&1 && git remote get-url origin >/dev/null 2>&1; then
sync_gap="$(git log --oneline HEAD..origin/main 2>/dev/null | wc -l | tr -d ' ' || true)"
if [ -n "$sync_gap" ] && [ "$sync_gap" -gt 0 ] 2>/dev/null; then
echo "[autoresearch-sync] $sync_gap commit(s) behind origin/main — pulling..."
git pull origin main >/dev/null 2>&1 || echo "[autoresearch-sync] WARN: git pull failed, continuing with local code"
fi
fi
fi
fi

STATUS_FILE="${AUTORESEARCH_STATE:-.autoresearch/state.json}"
WORKSPACE_ROOT="$(pwd -P)"

Comment thread hooks/verify-package.sh

TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants