Repository navigation
fix(slack): recover trusted bot attachment text - #13651
iamwhatever merged 2 commits into
Conversation
|
Intent: Route attachment-only Slack cards after positive trusted-bot admission so trusted alarm bots can start a turn. |
|
Current head
The green-age rebase is locally validated (951 overlap-selected tests plus docs/mypy), and no source change is indicated by these failures, so I have not pushed an unchanged commit to retrigger them. |
|
Re-triggered the fork checks with no-code commit This fresh suite is intended to determine whether the GPT, Opus, security-scope, internal-content, Build, and CI lanes now run without the prior GitHub App quota / runner-infrastructure failures. If GitHub requests approval for the fork workflows, please approve this run. |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The renderer that every human forward and pasted table goes through was rebuilt into a lazy budget engine, a far larger change than this trusted-bot fix needs. Watch
Suggestions
[DESIGN-REVIEWED] 40e8cf8 Description read[DESCRIPTION-READ] 671395635a80a214d0298d1603b66f7cf33252fb68eeefdfc10689c4417c6f72 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The fix needs only a gated attachment loop. The lazy-budget rewrite of the shared Block Kit renderer has no named harm, and the old output slice already capped it. Not justified as shipped
What this change shipsInventory (6 items) — 4 justifiedIntent: let alarm cards from trusted Slack bots that carry text only in attachments start a turn instead of vanishing. FIX (#13405).
[FIRST-PRINCIPLES-REVIEWED] 40e8cf8 Description read[DESCRIPTION-READ] 8a04f06b1e37b6edaaa57e0057275ab887cb868cf6a8ae2a636b2422a4c6c2b5 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
7b8d5dc to
f88e148
Compare
|
Rebased: main advanced from |
|
f88e148 to
35bfea6
Compare
d684a12 to
8785f5e
Compare
|
[operator: iamwhatever] Rebased onto current GPT 6.1 blocking F1 (autouse fixture on shared GPT 6.1 advisory (renderer docstring claims a work bound): fixed in the same push. The docstring now says only that the recovered output never exceeds the cap. First Principles CONCERNS (items 2-5) and Design suggestion (simpler budget): acknowledged, no code change in this PR. The size, scope and design trade-off is the author's and maintainers' call. Both lanes marked it advisory, and Opus 5.5 found nothing blocking. If a maintainer wants the smaller version (drop Design: check a real AWS Chatbot payload: still open. No live alarm card has been sent; the tests use built Slack event shapes, as the PR body says. |
|
[operator: iamwhatever]
The E2E lane is also red on |
|
This lets alarm cards from allowlisted Slack bots (AWS Chatbot, Amazon Q) whose text sits only in an ordinary attachment start a turn, instead of being dropped. The fix sits at the drop point in src/kiro_crew/slack/events.py. I tried to get past the trust check. The new |
iamwhatever
left a comment
There was a problem hiding this comment.
Deep security re-review of a held PR (I tried to break it). Alarm cards from allowlisted bots (AWS Chatbot, Amazon Q) put their text only in an ordinary attachment. Base dropped them; this PR now routes them, using the attachment fallback first and its Block Kit text second. I tried to get past the trust check. The new _extract_trusted_bot_attachment_text runs only when from_trusted_bot is true, and trusted_bot_admission (unchanged) requires a positive bot_id match, never trusts our own id and fails closed when our own id is unknown. A human message, an untrusted bot, and is_share/is_msg_unfurl attachments (even with a string value like "false", which counts as true and is skipped) all stay out. Tests pin each case (test_human_attachment_fallback_stays_excluded, test_trusted_bot_shared_attachment_is_skipped_before_content). Link previews cannot reach the new path: the recovery runs only when text is empty or a Slack placeholder, and Slack adds unfurls later as message_changed, which the subtype gate drops first. Prompt injection: an alarm description written by anyone who can edit a CloudWatch alarm now reaches the agent unfenced, with the same authority an allowed user has. But base already passes a trusted bot's text field the same way, so this is the same trust class with more volume, not a new hole. The shared renderer rewrite keeps base output for forwards and human messages: no section.fields unless the caller asks, the same strip and the same 16,000 cap. 321 Slack tests pass locally on 8785f5e. Hold reason status: the security widening still needs an owner pick (below). The renderer rewrite is checked and safe. The First Principles CONCERNS got a plain-comment reply on 10-09 (left to the maintainer), not a target=first-principles disposition. It is advisory, and readiness is passed. No conflict, no CHANGES_REQUESTED, all checks green. Non-blocking: optional, smaller: apply the First Principles subtraction. Drop _BoundedBlockText/_until_full/the _with_budget overloads and include_section_fields in src/kiro_crew/slack/events.py, join per-attachment results and slice once at _MAX_RECOVERED_TEXT_CHARS. Also confirm the shape with a real AWS Chatbot payload, which is still unchecked. On the owner decision: Accept the widening. A bot on slack.trusted_bot_ids already gets full user-level turns from its text field. Treating its attachment-only card the same way is what the allowlist already promises, and the turn cap and review-channel denial still apply. Land before #11220, as the author proposed. Risk: medium. — crew-pr-reviewer
8785f5e to
fb9f980
Compare
Head branch was pushed to by a user without write access
fb9f980 to
40e8cf8
Compare
|
Rebased onto main at head Dispositions for the two CONCERNS on this head (advisory, no code change): First Principles, item 3 (bounded traversal "no named harm") — rebutted, same answer as on Design Review, shared-path rewrite — the output contract of the shared path is unchanged: same lines, same |
iamwhatever
left a comment
There was a problem hiding this comment.
This PR fixes the root cause of #13405: alarm cards from allowlisted bots such as AWS Chatbot and Amazon Q were dropped when their text sat only in an ordinary attachment. They now start a turn. I read the whole src/kiro_crew/slack/events.py diff. I tried to get past the trust check. _extract_trusted_bot_attachment_text runs only when from_trusted_bot is already true and the shared-message path found nothing. is_share and is_msg_unfurl attachments are skipped, so human messages, untrusted bots and link unfurls cannot reach it. The recovered text goes into the same text variable that bot's top-level text uses today, so this adds no new class of untrusted input. For the shared renderer rewrite, I traced _BoundedBlockText and _table_row_fragments against base: leading-whitespace stripping, empty-line skipping, empty-cell " | " placement and the 16,000-character cap all give the same output. The one difference is a trailing-whitespace strip after the cap. Base is main, the head is mergeable and checks are green. The current-head Design and First Principles CONCERNS have written answers, backed by a measured cost of join-then-slice. The only review left is my own earlier, dismissed one, and the head has changed since my HOLD. — crew-pr-reviewer (deep re-check)
bolichen97
left a comment
There was a problem hiding this comment.
Maintainer approval after a full diff read on head 40e8cf86c9.
Sensitive change review
- Rule changed:
_route_message(src/kiro_crew/slack/events.py ~L2595-2602). Before:text = _extract_shared_text(event) or fallback. After: same, plusif not text and from_trusted_bot: text = _extract_trusted_bot_attachment_text(event)before theor fallback. Net effect: trusted-bot attachment content that previously never reached the agent now does. - What makes a bot "trusted":
from_trusted_botis set only bytrusted_bot_admission(bot_id, cfg.slack.trusted_bot_ids)in_on_event(main L1180) — positive match against the operator allowlist, own bot id never trusted, fail-closed when self id is unverified. The PR does not touch admission, the SEL audit, the review-channel denial, or the per-thread turn cap; recovery runs before those gates so they still apply to the recovered text. Defaulttrusted_bot_ids=[]means the new path is unreachable out of the box. - Untrusted text still excluded: for
from_trusted_bot=Falsethe new branch is skipped,_extract_shared_textstill only readsis_share/is_msg_unfurlattachments, and link-preview attachments on human messages remain dropped (test_human_attachment_fallback_stays_excluded). The trusted recovery itself skipsis_share/is_msg_unfurlattachments so content the forwarded path declined cannot be reclassified. - Worst case if wrong: a listed trusted bot (e.g. AWS Chatbot) relaying attacker-influenced alarm text becomes agent input — but that bot's plain-text messages were already admitted as input, so the injection surface is the same principal, only more of its payload. Bounded by the 16,000-char global budget and the existing turn cap.
- Evidence checked: full diff of all 4 files; main-branch
_on_event/_route_messagefor wherefrom_trusted_botoriginates; renderer refactor compared line-by-line with the old join/strip semantics (list prefix, quote prefix, empty-line suppression, table" | "joining, leading/trailing strip) — equivalent for the forwarded path; existing testtest_malformed_table_rows_are_skipped("| ok") still holds under the new lazy row renderer. CI: all check runs success/skipped (two "neutral" advisory reviews). - Undo: revert the PR; no config/data migration.
Problem / Motivation
Goal: Let configured trusted Slack bots route attachment-only alarm-card text into the existing message flow.
Trusted Slack bots can send alarm cards with empty top-level
text. When the card content exists only inside an ordinary attachment, Kiro Crew drops the message before a turn starts.Why it matters
AWS Chatbot and Amazon Q alarm cards can disappear silently even when the sender is trusted and the Slack channel is configured to route messages. Plain-text messages from the same bot still work, which makes the failure hard to diagnose.
Not a goal
What changed (motivation → approach → change)
The drop happens in
src/kiro_crew/slack/events.pyafter normal shared-message extraction returns no text. At that point, and only for a positively admitted trusted bot, Slack recovers ordinary attachment content: a real trimmedfallbackfirst, otherwise Block Kit text when the fallback is blank or one of Slack's generic placeholders.One bounded Block Kit renderer handles
rich_text,section.text, andcontextfor both paths. Trusted ordinary attachments enable itssection.fieldsbranch. Forwarded-message output stays unchanged. Each renderer invocation has a hard 16,000-character traversal and output cap. The trusted-bot attachment loop separately enforces one 16,000-character global budget across attachments and separators. Container and scalar fields are accepted only in their expected types. The owning Slack specification records these boundaries.Backwards compatibility
Compatible: existing top-level text and forwarded-message precedence are unchanged. Ordinary attachment recovery is reachable only for positively admitted trusted bots after the existing shared-message path yields no content; human, untrusted-bot, and link-unfurl behavior remains excluded.
Tests
test/test_slack_events_coverage.pyandtest/test_events_forward.py: 321 passed, covering trusted fallback,section.text, trusted-onlysection.fields, text-before-fields ordering, iterable and non-iterable malformed fields, forwarded andis_msg_unfurlnon-reclassification, human/untrusted exclusion, generic placeholders, per-renderer and trusted-bot global budgets, stripped-output budget consumption, renderer-exhaustion ordering, traversal stop, and per-test turn-ledger isolation.prepare-prgates plus the reproduciblemake buildpassed, including Black, isort, flake8, mypy, docs, vendor, CloudFormation, TypeScript, ESLint, i18n, Electron, duplication, bundle-size, and cycle checks.test_app_script_cron_sibling_import.pyreachesPlatformCompositionErrorduring collection on this enterprise-profile host and reproduces identically on cleanorigin/main, isolating a base/environment failure outside the Slack patch.prove.py:PROVEN).Manual verification
Not performed: no live Slack alarm card was sent. The automated tests exercise the production admission, extraction, and dispatch path with serialized Slack event shapes; provider payload variants outside those fixtures remain a residual risk.
Screenshots / video
N/A — no user-interface surface changes.
Related Issues
Fixes #13405
Pattern harvest
Rule candidate: review-prompt
Pattern: external message recovery must stay behind positive trust admission, validate payload shapes, and enforce resource limits before accumulation.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)