fix: unset LHM_*_CONFIG in the hook wrapper#37
Closed
walter-square wants to merge 1 commit into
Closed
Conversation
alecthomas
reviewed
Jun 11, 2026
alecthomas
left a comment
Collaborator
There was a problem hiding this comment.
I think instead we should just remove these envars. I haven't used them once since I initially added them.
Collaborator
|
See #40 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Problem
The
LHM_GLOBAL_CONFIG/LHM_LOCAL_CONFIGoverrides are intended fordry-runergonomics, but they're also honored during normal hook execution. Anything that injects env vars into the developer's shell beforegitruns, e.g.direnvloading a.envrcfrom a freshly cloned repo, could redirect lhm's config sources to attacker-chosen YAML, which then runs via lefthook.The Fix
This prepends
unset LHM_GLOBAL_CONFIG LHM_LOCAL_CONFIGto the generated wrapper-script content before itexecslhm run-hook, so lhm-as-a-hook never sees those vars even when the surrounding shell does. The vars still work fordry-runvia the explicit--global-config/--local-configflags.Testing
cargo test(146 passing, including wrapper-content assertions).