fix(kvb-check-security): never copy a file through a symlinked folder
copy() checked is_symlink() only on the last path part. When a committed folder is replaced by a link to an outside directory, git diff still lists the files below it, so root / name resolved through the link and the scan copied and read a file outside the repository. A source whose resolved path leaves the repository is now skipped. Found by an independent skeptic review of a MEDUSA temp-file hit. 🎯 Fix: 96 % 💥 Break: 2 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 94 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
731d0df43b
commit
67cbe0ddd3
2 files changed
+16
-2
No files matched your search
@@ -291,11 +291,12 @@ def copy(root: Path, paths: list[str], tree: Path) -> dict[str, str]:
|
||||
the tree path of every copied file mapped to its repository path.
|
||||
"""
|
||||
names = {}
|
||||
top = root.resolve()
|
||||
taken = set(paths) | {parent.as_posix() for name in paths for parent in Path(name).parents}
|
||||
for name in paths:
|
||||
source = root / name
|
||||
# Trip-wire: a symlink's target may lie outside the repository; even a copied link lets the scan read it.
|
||||
if source.is_symlink() or not source.is_file():
|
||||
# Trip-wire: a symlink's target may lie outside the repository, also through a linked parent folder; even a copied link lets the scan read it.
|
||||
if source.is_symlink() or not source.resolve().is_relative_to(top) or not source.is_file():
|
||||
continue
|
||||
scratch = name
|
||||
if Path(name).suffix.lower() in SKIPPED:
|
||||
|
||||
Reference in new issue
Block a user