Commit cd5116b
security: Fix 3 critical issues from external review round 4 (v2.0.8)
This commit addresses all FAIL/CRITICAL issues identified by Codex and
Gemini verification reviews of v2.0.6 and v2.0.7.
CRITICAL SECURITY FIX #1: Command substitution after secret export
──────────────────────────────────────────────────────────────────────
Issue: External dirname command executed after API key fetch/export,
enabling PATH poisoning to leak credentials
Codex PoC: Successfully leaked LINUX_FETCHED_SECRET_789 via malicious
dirname in PATH
Fix: Replaced $(dirname "$var") with ${var%/*} shell builtin
- bin/glm-mcp-wrapper:161 - npx_dir="${npx_bin%/*}"
- bin/claude-by-glm:303 - claude_dir="${claude_bin%/*}"
Impact: Eliminates credential leak surface completely by avoiding
external command execution after secrets are in environment
CRITICAL PORTABILITY FIX #2: realpath -m regression
──────────────────────────────────────────────────────────────────────
Issue: Plain realpath requires paths to exist, breaking:
- Fresh installations (install dir doesn't exist yet)
- Clean home scenarios (sessions dir not created yet)
- First-run validation (paths validated before creation)
Affected: scripts/install.sh:43, scripts/uninstall.sh:46,
bin/glm-cleanup-sessions:121,125,242,243 (6 locations)
Fix: Added canonicalize_path() function to scripts/common-utils.sh
- Portable to both GNU (Linux) and BSD (macOS)
- Works with non-existent paths by canonicalizing parent + basename
- Falls back gracefully when realpath unavailable
- Handles recursive parent canonicalization
Impact: Restores installation and cleanup functionality on macOS and
in all first-run scenarios
CRITICAL FUNCTIONALITY FIX #3: Incomplete nvm/volta support
──────────────────────────────────────────────────────────────────────
Issue: bin/glm-mcp-wrapper was updated for nvm/volta in v2.0.6, but
bin/claude-by-glm validation was not, blocking nvm/volta users
Fix: Added nvm/volta paths to claude validation trust pattern
- bin/claude-by-glm:291 - Added "$HOME"/.nvm/*/bin/claude
- bin/claude-by-glm:291 - Added "$HOME"/.volta/bin/claude
- Updated error message to include new trusted paths
Impact: nvm/volta users can now use claude-by-glm wrapper without
"Untrusted claude path" errors
Verification:
─────────────
✅ Syntax checks: PASS (all 7 modified files)
✅ Security scan: PASS (gitleaks found no issues)
✅ Shellcheck: PASS (no new warnings)
Security Properties Maintained:
────────────────────────────────
✅ PATH hardening intact (trusted paths only)
✅ Binary validation enforced (nvm/volta now trusted)
✅ Config isolation preserved (CLAUDE_CONFIG_DIR separation)
✅ No command substitution after secret operations
✅ Path canonicalization prevents traversal attacks
External Review Status:
───────────────────────
Round 4 identified 3 CRITICAL issues in v2.0.6/v2.0.7
All 3 issues now resolved in v2.0.8
Ready for verification review round 5
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent e155735 commit cd5116b
7 files changed
Lines changed: 69 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
290 | 291 | | |
291 | | - | |
| 292 | + | |
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
295 | | - | |
| 296 | + | |
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
| 303 | + | |
302 | 304 | | |
303 | | - | |
| 305 | + | |
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
120 | 121 | | |
121 | | - | |
| 122 | + | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | | - | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | | - | |
242 | | - | |
| 243 | + | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
160 | 161 | | |
161 | | - | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
57 | 102 | | |
58 | 103 | | |
59 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
53 | 49 | | |
54 | 50 | | |
55 | 51 | | |
| |||
0 commit comments