fix(agent): creator 纳入运行时保留参数,从 ctx.username 注入,防 LLM 伪造开票人 - #11
Open
leaderwm wants to merge 1 commit into
Open
Conversation
create_ticket 的 creator 原取自 LLM 可控 tool_args(schema 未声明但 LLM 私带时 仍被透传),模型幻觉/注入可伪造开票人;对齐 tenant 保留参数同款机制: args 剥离 creator,ctx 有登录态且 handler 声明 creator 形参时注入 username
leaderwm
force-pushed
the
fix/agent-tool-creator-spoof
branch
from
September 4, 2026 10:30
41c28ed to
da93461
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
create_ticket的creator(开票人)取自 LLM 可控的 tool_args:schema 未声明该字段,但 LLM 私带creator时仍会透传到 handler——模型幻觉/注入可伪造开票人;正常路径又因 schema 未声明恒为空串。改动
在
ToolRegistry.run对齐tenant保留参数的既有机制:creator加入 LLM 参数剥离清单(tenant/tenant_id/tenantId/creator);creator形参时,注入ctx.username(inspect.signature判定,与 tenant_aware 判定同款)。新增 2 例回归:有 ctx 时注入登录名(剥离伪造值)、无 ctx(老链路)时剥到默认空串。
验证
python -m pytest tests/ -q --ignore=tests/test_api.py -m "not integration":828 passed(3 个失败为 main 上已存在的 test_batch3_infra openai SDK 环境差异,与本 PR 无关,已在未改动代码上复现确认)python scripts/validate_golden.py通过