TokenEconomizer: repository-planted code runs in the plugin process; tmp writes follow symlinks
Maintainer thường phản hồi trong vòng 1 ngày
@kevinveenbirkenbach đang làm issue này rồi.
Từ ngày 17/11/2026.
- #261 của @kevinveenbirkenbach — đang mở
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
Start with tokeneconomizer/plugin/context.py and tokeneconomizer/plugin/denylist.py, then review linked pull request #261. The report describes module shadowing when spawning the CLI and symlink following for temporary writes; check the existing tests for those paths. Done means both reported attack paths are addressed and covered by tests.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Product: microsoft/TokenEconomizer, Claude Code / Codex plugin.
Affected: commit b57d03f81585a18b936a0eaecbd1eb51cdcecf71 (main on 2026-11-17).
Channel: private report per SECURITY.md (aka.ms/SECURITY.md); not filed as a public issue.
Context
Coding agents typically run their tool calls inside a sandbox that may write
the repository but not the user's configuration. Plugin hooks run outside that
sandbox. Both issues let content an agent (or a cloned repository) places in
the repository act with the hook's unsandboxed privileges.
Issue 1: module shadowing in the spawned CLI (code execution)
tokeneconomizer/plugin/context.py (around lines 84-93) starts
[sys.executable, "-m", "tokeneconomizer.plugin.cli", ...] with
cwd=self.repo.root and no -P/-I. With -m, Python puts the current
directory first on sys.path, ahead of PYTHONPATH. A file such as json.py,
or a tokeneconomizer/ package, in the repository root is imported instead of
the real module and runs in the plugin's process. This path is reached on
session-end and session-start folds regardless of configuration, and for the
loop-guard judge and pending applies.
Reproduction (no plugin code needed): in an empty directory create json.py
containing print("planted"), then run python3 -m json.tool --help there:
planted is printed. With PYTHONSAFEPATH=1 it is not.
Issue 2: symlink write-through of the temporary file
write_json and _write_text in tokeneconomizer/plugin/denylist.py
(around lines 124-138) open path + ".te.tmp" with open(tmp, "w").
_guard_target checks only the final path. A symlink planted at
.claude/settings.local.json.te.tmp makes the write land on the link target,
for example the user-wide ~/.claude/settings.json; the written JSON derives
from the repository's own settings.local.json, so it can carry hooks.
With the default toolprune=auto, the write happens without user action.
Reproduction: plant the symlink .claude/settings.local.json.te.tmp -> /some/victim.json, call denylist.write_json(".claude/settings.local.json", {...}): the victim is overwritten, the target is not created.
Suggested fix (tested locally)
--- a/tokeneconomizer/plugin/context.py
+++ b/tokeneconomizer/plugin/context.py
env["PYTHONUTF8"] = "1"
+ env["PYTHONSAFEPATH"] = "1"
cmd = [sys.executable, "-m", "tokeneconomizer.plugin.cli", *argv,
--- a/tokeneconomizer/plugin/denylist.py
+++ b/tokeneconomizer/plugin/denylist.py
+def _open_tmp(tmp):
+ if os.path.lexists(tmp):
+ os.unlink(tmp)
+ flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, "O_NOFOLLOW", 0)
+ return os.fdopen(os.open(tmp, flags, 0o666), "w", encoding="utf-8")
write_json and _write_text then open the temporary file through
_open_tmp. PYTHONSAFEPATH needs Python 3.11+; for 3.10 a cwd outside the
repository (the --cwd argument already carries the root) closes issue 1 too.
Two further observations, lower severity: on Codex the judge runs
codex exec -s read-only, which can still read files the user's agent sandbox
denies; plugin state is keyed by the origin remote URL, so a repository that
copies another's URL shares its learned state.
PS: I would had liked to report this vulnerability over your website, but it was impossible to register.
- Ngôn ngữ chính
- Python
- Star
- 7.4k
- Fork
- 500
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 124
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TokenEconomizer
-
Pi: paused model calls are reported as "not signed in" when the model's provider comes from an extensionCó thể đã có người làm @balcsida đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
microsoft/TokenEconomizer#288 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
microsoft/TokenEconomizer#264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Hermes plugin uses only part of Hermes's plugin interface; its hooks also run in the gatewayĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
microsoft/TokenEconomizer#232 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CommandCode supportĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
microsoft/TokenEconomizer#205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
microsoft/TokenEconomizer#193 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/TokenEconomizer
Issue tương tự
-
[Bug]: reme CLI crashes when the running server used a relative config pathCó thể đã có người làm @nurlanmnn đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
agentscope-ai/ReMe#770 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
sickn33/agentic-awesome-skills#2437 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
site-bug triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ethereum/consensus-specs#5846 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
BrainLesion/BraTS#200 ·