Repository navigation
Conversation
`normalize_dir` in cwd.lua and `build_config` in terminal.lua passed any
cwd text that was not an existing directory to `vim.fn.expand`. On Unix,
expand runs text between backticks through 'shell'. With git_repo_cwd or a
cwd_provider that returns ctx.file_dir, the directory part of a terminal,
archive-member or URI buffer name (and the root git prints) reached that
call, so a folder name holding a backtick pair ran a command when the user
opened or toggled Claude.
Add `cwd.expand_leading`, which expands only a leading `~`, `~/`, `$VAR`
or `${VAR}` from the environment, without a shell, and use it in both
places. The rest of the text is taken as written; normalize_dir still
returns nil for text that names no directory, and build_config still
passes a non-directory cwd through literally. `$VAR` later in the text,
`~user` and globs are no longer expanded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015koAoMEFEUXUgoDF7Nam12
ThomasK33
enabled auto-merge
December 3, 2026 09:33
kylecarbs
approved these changes
Dec 3, 2026
Only the whole-file hashes of lua/claudecode/terminal.lua and lua/claudecode/cwd.lua changed. The change is confined to cwd resolution in build_config and cwd.lua, which no model step covers; the terminal lifecycle and diff lifecycle models pass against the changed code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015koAoMEFEUXUgoDF7Nam12
Member
Author
|
Re-recorded Also retitled the PR to a Conventional Commits title so Generated by Claude Code |
kylecarbs
approved these changes
Dec 3, 2026
ThomasK33
deleted the
claude/claude-security-fix-find_01gqxbxfanwgsi8fqbalxw4k-76to65
branch
December 3, 2026 10:15
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.
Summary
This PR fixes a security vulnerability where paths containing backticks could be passed to
vim.fn.expand(), which interprets backticks as shell command delimiters. This could occur when paths come from untrusted sources like terminal buffer names or git output.Key Changes
New
cwd.expand_leading()function: Safely expands only leading~,~/,$VAR, or${VAR}patterns without callingvim.fn.expand(). This prevents backticks and other shell metacharacters from being interpreted as commands.Updated
cwd.normalize_dir(): Now usesexpand_leading()instead ofvim.fn.expand(), ensuring paths with special characters are handled safely.Updated
terminal.build_config(): Replacedvim.fn.expand()call withexpand_leading()when resolving the working directory fromcwdorcwd_providerresults.Comprehensive test coverage: Added unit tests in
command_args_spec.luaandcwd_spec.luato verify:vim.fn.expand()expand_leading()correctly handles all expansion patterns while leaving the rest of the path untouchedDocumentation updates: Updated README and integration test comments to clarify that only leading expansions are performed and paths are never passed to
vim.fn.expand().Implementation Details
The
expand_leading()function:^%$,^%${,^~)vim.loop.os_homedir()forHOMEvim.fn.expand(), eliminating the shell injection vectorThis approach maintains backward compatibility with existing configurations while securing paths that come from dynamic sources like buffer names or git commands.