[BUG] The eval handshake falls back to $HOME when the account has no passwd entry
维护者通常 1 天内回复
评估
调研方向
The fallback is in _account_home() in the crewai_core eval_handshake module, and awaiting_dir() and run_awaited_by_evaluation() depend on it. The CLI copy is _awaiting_dir in crewai_cli.crew_run_tui. Run the reproduction script from the issue with the pwd lookup patched to raise KeyError, and confirm that the directory resolves through $HOME. Done means both helpers raise OSError when the account database has no entry, with no $HOME fallback, and the existing call sites treat that as no evaluation waiting.
由索引模型根据 Issue 内容生成。
描述
Description
crewai_core.eval_handshake decides whether a run may upload its trace without asking, by looking for a token file in this user's crewAI data directory. Its module docstring promises that a project's .env cannot move that directory:
Nor can it move the directory: it is found from this account's home in the account database, never from
HOMEorXDG_DATA_HOME, which a.envcan set.
But _account_home does not hold that promise when the account database has no entry for the process's uid:
def _account_home() -> Path:
"""This account's home from the account database, never `$HOME`."""
if os.name == "posix":
with contextlib.suppress(ImportError, KeyError, OSError):
import pwd
return Path(pwd.getpwuid(os.getuid()).pw_dir)
return Path.home()
Path.home() is os.path.expanduser("~"), which reads $HOME on POSIX. Running an arbitrary uid that has no passwd entry is standard practice in containers (OpenShift, docker run --user 1001), and there pwd.getpwuid(...) raises KeyError, is suppressed, and _account_home() returns $HOME - exactly the variable a project's .env can set.
The CLI copy of the same logic, crewai_cli.crew_run_tui._awaiting_dir, has the same fallback (except (ImportError, KeyError, OSError): home = Path.home()).
Consequence: in such a container, a project whose .env carries HOME=<repo> plus CREWAI_EVAL_AWAITING_RUN=<32 hex>, with a checked-in file <repo>/.local/share/crewai/eval-awaiting/<32 hex>, makes run_awaited_by_evaluation() true for an ordinary crewai run. That flips should_enable_tracing to True before any consent check, so the run's trace is uploaded although nobody ran crewai eval and nobody approved tracing - the bypass the docstring says is impossible.
Steps to Reproduce
The relevant path can be exercised without a real container by simulating the three conditions (uid missing from the account database, POSIX branch, $HOME planted):
import os
import sys
import types
from pathlib import Path
from crewai_core import eval_handshake
fake_pwd = types.ModuleType("pwd")
fake_pwd.getpwuid = lambda uid: (_ for _ in ()).throw(KeyError(uid))
sys.modules["pwd"] = fake_pwd
eval_handshake.os.name = "posix"
eval_handshake.os.getuid = lambda: 4242
Path.home = classmethod(lambda cls: Path("<repo>")) # what $HOME would resolve to
os.environ["CREWAI_EVAL_AWAITING_RUN"] = "a" * 32
assert eval_handshake.awaiting_dir() == Path("<repo>/.local/share/crewai/eval-awaiting")
assert eval_handshake.run_awaited_by_evaluation() is True # with the planted file present
On a real POSIX container where pwd.getpwuid(os.getuid()) raises KeyError, HOME is read from the project's .env the same way, with no patching at all.
Expected Behavior
When the account database cannot name this account's home, the handshake should fail closed - report no trusted folder (for example raise OSError, which both call sites already handle as "no evaluation is waiting") instead of falling back to $HOME. The CLI's copy of _awaiting_dir should do the same, so crewai eval also never writes its token under a folder a .env chose.
AI assistance
I used an AI coding agent to investigate, reproduce, and prepare this report, and reviewed its results. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors cannot add it with my current permissions.
- 主要语言
- Python
- 星标
- 61.2k
- 派生
- 9.2k
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 180
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
crewAIInc/crewAI 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM provider可能已有人在做 @HashimSyedUBC 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
[BUG] Native Azure provider ignores the seed setting可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
crewAIInc/crewAI#9787 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary可能已有人在做 @basil-k-aji-dev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
bug harness
难度 2/5 1-3 小时 新手友好度 72/100
mruangutai/harness#2687 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
modal-labs/modal-client#4158 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 72/100
The-Swarm-Corporation/swarms-rs#168 ·
维护者通常 1 天内回复
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373未关闭
难度 2/5 1-3 小时 新手友好度 72/100
linuxserver/docker-healthchecks#137 · 1 条评论 ·