Skip to content

fix(operator-queue): normalize reserved-prefix guard against lookalikes (#1631 follow-up) - #1688

Merged
vybe merged 1 commit into
devfrom
fix/1631-guard-normalization
Jul 18, 2026
Merged

vybe merged 1 commit into
devfrom
fix/1631-guard-normalization

Conversation

@obasilakis

Copy link
Copy Markdown
Contributor

Summary

Fast-follow to #1684 (merged). The /cso --diff audit of the #1631 change found one LOW: the reserved-prefix hijack guard (operator_queue_service.py) was exact-match (req_id.startswith(_RESERVED_ID_PREFIXES)), so a prompt-injected agent could author an item with a lookalike id (Poison-x, uppercase/leading-space) that evaded the filter and appeared as a platform-styled operator alert with attacker text.

  • Not a hijack. An independent refutation proved collision/suppression is impossible — the only id that can collide with the platform's real poison-{execution_id} slot necessarily starts with poison- and is rejected. Every evasion produces a different, non-colliding row. So this is operator-phishing polish, not a new capability (an agent can already author arbitrary queue items).
  • Fix: normalize (strip().lower()) before the prefix check. The platform mints these prefixes lowercase and unpadded, so a normalized match can only be impersonation.

This hardening was committed during the audit but stranded when #1684 squash-merged mid-/cso; landing it on its own branch.

Changes

  • src/backend/services/operator_queue_service.py — strip().lower().startswith(...) in the reserved-prefix guard.
  • tests/unit/test_1631_operator_queue_agent_scoped_ids.py — new test_reserved_prefix_guard_folds_case_and_whitespace (rejects Poison-x, SYNC-FAILING-x, \tgit-bloat-x).
  • docs/security-reports/cso-2026-07-18.md — the audit report.

Test Plan

  • tests/unit/test_1631_operator_queue_agent_scoped_ids.py → 6 passed (5 original + fold-case).
  • No behavior change to the legitimate path — agent-authored non-reserved ids are unaffected.

Refs #1631. Hardening follow-up to #1684.

Generated with Claude Code

…es (#1631 follow-up)

Fast-follow to PR #1684 (merged): the /cso --diff audit of the #1631 change
found one LOW — the reserved-prefix hijack guard was exact-match, so an agent
could author a lookalike (` Poison-x`, uppercase/padded) platform-styled
operator alert. Not a hijack (an independent refutation proved collision/
suppression is impossible — the only colliding string necessarily matches the
prefix and is rejected), but an operator-phishing surface.

Normalize (strip + lower) before the prefix check so a lookalike can't slip
past — the platform mints these prefixes lowercase and unpadded, so a
normalized match can only be impersonation. Covered by a new fold-case test.
Also lands the CSO audit report under docs/security-reports/.

This stranded on the #1684 branch when that PR squash-merged mid-audit; landing
it here on its own. Refs #1631.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated via /validate-pr: focused hardening follow-up to #1684 — normalize-before-check on the reserved-prefix guard, with the named lookalike regression test (test_reserved_prefix_guard_folds_case_and_whitespace). Ran tests/unit/test_1631_operator_queue_agent_scoped_ids.py locally on the PR head merged with dev: 6 passed. No security/packaging concerns (diff strictly tightens an existing guard; no new env vars, modules, or endpoints). Note: body uses bare Refs #1631, so bumping the issue to status-in-dev manually.

@vybe
vybe merged commit aa67626 into dev Jul 18, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants