Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(show): validate hardlinks from archive root

cyhb11f356f129f
diff --git a/core/show_runtime.py b/core/show_runtime.py
index b52f6ea10..1d2777acc 100644
--- a/core/show_runtime.py
+++ b/core/show_runtime.py
@@ -545,11 +545,16 @@ def _safe_extract_tar(tar: tarfile.TarFile, destination: Path) -> None:
target = (destination / member.name).resolve()
if target != destination_resolved and destination_resolved not in target.parents:
raise ValueError(f"Unsafe archive member path: {member.name}")
- if member.issym() or member.islnk():
+ if member.issym():
link_target = (destination / member.name).parent / member.linkname
link_target_resolved = link_target.resolve()
if link_target_resolved != destination_resolved and destination_resolved not in link_target_resolved.parents:
raise ValueError(f"Unsafe archive link target: {member.name}")
+ elif member.islnk():
+ link_target = destination / member.linkname
+ link_target_resolved = link_target.resolve()
+ if link_target_resolved != destination_resolved and destination_resolved not in link_target_resolved.parents:
+ raise ValueError(f"Unsafe archive link target: {member.name}")
try:
tar.extractall(destination, filter="data")
except TypeError:
diff --git a/tests/test_ui_show_pages.py b/tests/test_ui_show_pages.py
index 86696e967..5ca0cb3a2 100644
--- a/tests/test_ui_show_pages.py
+++ b/tests/test_ui_show_pages.py
@@ -1,4 +1,5 @@
import asyncio
+import io
import tarfile
from pathlib import Path
@@ -382,6 +383,23 @@ def test_show_runtime_safe_extract_rejects_external_symlink(tmp_path):
_safe_extract_tar(tar, tmp_path / "destination")
+def test_show_runtime_safe_extract_rejects_external_hardlink(tmp_path):
+ archive_path = tmp_path / "unsafe-hardlink.tgz"
+ with tarfile.open(archive_path, "w:gz") as tar:
+ data = b"safe\n"
+ safe = tarfile.TarInfo("safe")
+ safe.size = len(data)
+ tar.addfile(safe, io.BytesIO(data))
+ hardlink = tarfile.TarInfo("dir/h")
+ hardlink.type = tarfile.LNKTYPE
+ hardlink.linkname = "../outside"
+ tar.addfile(hardlink)
+
+ with tarfile.open(archive_path, "r:gz") as tar:
+ with pytest.raises(ValueError, match="Unsafe archive link target"):
+ _safe_extract_tar(tar, tmp_path / "destination")
+
+
def test_show_runtime_manager_reuses_installed_prebuilt_runtime_without_archive(monkeypatch, tmp_path):
cli_path = tmp_path / "runtime" / "prebuilt" / "current" / "node_modules" / "@avibe" / "show-runtime" / "dist" / "cli.js"
cli_path.parent.mkdir(parents=True)