Skip to content

Turn off config-driven commands on every git ignore check a hook runs #16959

Closed

Description

@kyle-sexton

Refs #16905, PR #16954.

Observed

Found while fixing the security review of PR #16954 (report of the build session; call sites to re-verify with file:line): hooks run git check-ignore in the edited file's repository without -c core.fsmonitor=false. Reading the index starts the command a repository's core.fsmonitor config names. git's safe.directory check still applies there, so this needs a repository the user owns whose .git/config someone else wrote, such as an extracted archive that contains a .git/.

  • hook::file_is_gitignored in the shared hooks/hook-utils.sh (copied into several plugins; the format hooks appear to call it by default through hook::gitignored_out_of_scope).
  • spd_gitignored in plugins/guardrails/hooks/secret-pattern-detection.sh (its option secret_pattern_detection_skip_gitignored is off by default).

Done when

Activity

  1. added
    host-run
    on Nov 17, 2026
  2. added
    needs-triage
    on Nov 17, 2026
  3. github-actions commented on Nov 17, 2026

    @github-actions
    Contributor

    Size: Medium
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: none
    Blast radius: the shared hooks/hook-utils.sh helper and its copies across plugins, plus plugins/guardrails/hooks/secret-pattern-detection.sh; run by every user whose hooks call git check-ignore.
    Reversible: yes; revert the change to the git call wrappers and the synced copies.
    Open questions: none
    I understood this as follows: hook git check-ignore calls run without -c core.fsmonitor=false, so a repository whose .git/config was written by someone else (for example an extracted archive) could start a command named in its core.fsmonitor setting. You want every such hook git call to go through one shared helper that passes the overrides from PR #16954, a test with a planted core.fsmonitor showing nothing runs, and the shared copies synced. The attack needs a repository the user owns, because safe.directory still applies, so I triaged it as a medium-severity hardening bug rather than a critical exposure. I found no open duplicate and no merged fix. The call sites you list should be re-verified with file:line when the work starts.

    Automated triage. A maintainer reviews it.

  4. added
    area: security
    on Nov 17, 2026
  5. melodic-automation-lanes commented on Nov 17, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: it carries host-run. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  6. kyle-sexton commented on Nov 18, 2026

    @kyle-sexton
    MemberAuthor

    Status, 2026-11-18 (control-hub session, melodic-software/control-hub#11). Merged against this issue: #17104, #17082 and #17260 (the format adapters, markdown-gates.sh and the reap helper now go through hook::git_untrusted, with planted-core.fsmonitor tests). Still open, and the reason this issue stays open: the eight --worktree git-hook entries that hooks start as a separate process (actionlint, bash-format, go-format, javascript-format, markdown-format, powershell-format, python-format, spelling) never load hook-utils.sh, so their git calls run without the overrides. Decided by the hub session (the owner can reverse it): the hook passes the overrides to that child through git's GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n environment variables, built by the one shared helper; Basis: judgment, on the build session's report; it keeps one definition and changes no call site in check-lib.sh. Left as is: worktree-create.sh does not pass core.hooksPath=/dev/null to git worktree add, because running the repository's post-checkout hook there is what running git in a repository the person chose does; it would matter only for a repository whose .git/config someone else wrote. Content filters (filter.<driver>.clean) cannot be turned off with -c, as #17082 recorded.

  7. removed
    host-run
    on Nov 18, 2026
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

    area: securityneeds-triage

    Type

    Fields

    Work status

    confirmed

    Priority

    medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions