Repository navigation
Conversation
eval_handshake promises that a project's .env cannot move the folder the eval token is read from, because it comes from the account database rather than HOME. But _account_home suppressed a missing passwd entry and fell back to Path.home(), which is $HOME on POSIX: in a container running an arbitrary uid, a .env that sets HOME and a token file committed under it made an ordinary crewai run upload its trace as if crewai eval had started it. Raise OSError instead when the account database cannot name this account's home; both call sites already read that as "no evaluation is waiting". The crew_run_tui copy of the lookup gets the same treatment.
Strix Security Review✅ No open security findings. PR summary: When the host has no account-database entry for the process's uid (common in containers), the eval-handshake token folder used to fall back to `$HOME`, which a project's `.env` can set; the PR now fails closed by raising `OSError` from `_account_home` and the CLI's `_awaiting_dir`, with tests for that case. Review summaryReviewed the fail-closed change to the eval handshake. The PR stops Ruled out (6)
Review 1 on this PR · Reviewed by Strix |
Fixes #9764
Summary
eval_handshakepromises that a project's.envcannot move the folder its eval token is read from, because the folder comes from the account database and never fromHOME._account_homebroke that promise when the account database has no entry for the process's uid: it suppressed theKeyErrorfrompwd.getpwuid(os.getuid())and fell back toPath.home(), which reads$HOMEon POSIX. Running an arbitrary uid without a passwd entry is standard in containers (OpenShift,docker run --user 1001), so a project.envcould setHOME(plusCREWAI_EVAL_AWAITING_RUN) and a checked-in token file under it made an ordinarycrewai runupload its trace as ifcrewai evalhad started it - with nobody having asked.crewai_cli.crew_run_tui._awaiting_dir, the CLI's copy of the same lookup, had the same fallback.Changes
lib/crewai-core/src/crewai_core/eval_handshake.py_account_home: on POSIX, stop suppressing a failed account-database lookup; raiseOSErrorinstead of returningPath.home(). Update its docstring andawaiting_dir's.lib/cli/src/crewai_cli/crew_run_tui.py_awaiting_dir: same change, socrewai evalalso never writes its marker under a folder a.envchose.lib/crewai-core/tests/test_eval_handshake.pyawaiting_dir()raisesOSError; a token planted under theHOMEthe process would otherwise read is not read (awaited_evaluation()isNone);awaiting_evaluation()yieldsFalseand leaves no variable behind.Both existing call sites already handle
OSError(awaited_evaluationreturnsNone, andawaiting_evaluation/evaluating_after_runsuppress it), so the failure is fail-closed: no file is read or written.Verification
pytest lib/crewai-core/tests/test_eval_handshake.py->20 passed, 1 skipped(the skip is the POSIX-only real-home test on Windows);pytest lib/cli/tests/test_crew_run_tui.py->144 passed.eval_handshake.py(new tests kept): all three new tests fail - the first becauseawaiting_dir()returns the planted home instead of raising, the second because the planted token is read and the run is marked awaited, the third because the context manager reports the mark as taken.AI assistance
I used an AI coding agent to investigate, implement, and test this change, and reviewed its results. Per CONTRIBUTING.md, please apply the
llm-generatedlabel; external contributors cannot add it with my current permissions.