mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(kanban): sanitize comment author rendering in build_worker_context (#22769)
Operator-controlled HERMES_PROFILE values were rendered as
'**${author}** (${ts}):' — markdown bold with no provenance prefix.
Worker comment bodies render directly underneath. A misleading
profile name like 'hermes-system' or 'operator' could be misread by
the next worker as a system directive above attacker-influenced
content (confused-deputy primitive gated on operator misconfig).
The LLM-controlled author-forgery surface was already closed in
#22435 (author removed from KANBAN_COMMENT_SCHEMA). This is
defense-in-depth: render with an explicit 'comment from worker
`<author>` at <ts>:' prefix so even 'hermes-system' resolves to
'comment from worker `hermes-system` at ...' — parseable as
worker-comment metadata, not a system directive. Strip backticks
from author so they can't break out of the fence.
Update test_build_worker_context_caps_comments to count by body
regex since the rendered author line now also starts with
'comment '.
Closes #22452.
This commit is contained in:
parent
f00dc6d7a3
commit
ade5981429
2 changed files with 38 additions and 5 deletions
|
|
@ -4072,7 +4072,14 @@ def build_worker_context(conn: sqlite3.Connection, task_id: str) -> str:
|
|||
)
|
||||
for c in shown_c:
|
||||
ts = time.strftime("%Y-%m-%d %H:%M", time.localtime(c.created_at))
|
||||
lines.append(f"**{c.author}** ({ts}):")
|
||||
# Render author with explicit "comment from worker" framing so
|
||||
# operator-controlled HERMES_PROFILE values like "hermes-system"
|
||||
# or "operator" can't be misread by the next worker as a system
|
||||
# directive above the (attacker-influenceable) comment body.
|
||||
# Defense-in-depth — the LLM-controlled author-forgery surface
|
||||
# was already closed in #22435. See #22452.
|
||||
safe_author = (c.author or "").replace("`", "")
|
||||
lines.append(f"comment from worker `{safe_author}` at {ts}:")
|
||||
lines.append(_cap(c.body, _CTX_MAX_COMMENT_BYTES))
|
||||
lines.append("")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue