Commit 3ecdbf2
committed
fix(security): replace /tmp fallback with sentinel path in containment guard
The _detect_safe_base_dir function was falling back to Path('/tmp') when
neither CLAUDE_PROJECT_DIR, CWD, nor a .git ancestor could be resolved.
Since SAFE_BASE_DIR is the containment floor for all write-path guards
via _is_relative_to, using /tmp effectively disabled containment as any
path under /tmp would pass validation.
Changed to return a non-existent sentinel path (/__nonexistent_containment_sentinel__)
that ensures all containment checks fail in degenerate cases, rather than
allowing writes to a world-writable directory.
Fixes: CWE-22 path traversal vulnerability in fallback path1 parent bb9afa2 commit 3ecdbf2
1 file changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
104 | 113 | | |
105 | 114 | | |
106 | 115 | | |
| |||
126 | 135 | | |
127 | 136 | | |
128 | 137 | | |
129 | | - | |
130 | | - | |
| 138 | + | |
| 139 | + | |
131 | 140 | | |
132 | 141 | | |
133 | 142 | | |
134 | 143 | | |
135 | 144 | | |
136 | | - | |
137 | | - | |
| 145 | + | |
| 146 | + | |
138 | 147 | | |
139 | 148 | | |
140 | 149 | | |
| |||
0 commit comments