[9.5] [Cases] Fix unified event attachments bypassing closed-case check (#291173) - #291204
Merged
Merged
Conversation
…astic#291173) ## Summary `validateCreateCommentRequest` blocks alerts and events from being attached to a closed case. The event check matched by legacy type only (`AttachmentType.event`, i.e. `'event'`), so unified events (`security.event`) never triggered the guard and were silently accepted on closed cases. Alerts already used the unified-aware `isAlertAttachmentType` predicate. This aligns events to the same pattern via `isEventAttachmentType`, which matches both `'event'` (legacy) and `'security.event'` (unified). Also removes the now-dead `getAttachmentsByType` helper (its only call site was the buggy event check). **Found by** @radtke-vale, validated on staging in [this review comment](elastic#290961 (comment)) on elastic#290961. ## Before / after (validated on staging) Before: ``` POST kbn:/api/cases/{caseId}/comments { "type": "security.event", "owner": "securitySolution", "attachmentId": "...", "metadata": { "index": "..." } } ``` → `200`, attachment created on a closed case. After: ```json { "statusCode": 400, "error": "Bad Request", "message": "Event cannot be attached to a closed case" } ``` ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/docs/extend/kibana/contributing/workflow/how-we-use-github#release-notes) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. Made with Cursor (cherry picked from commit 0b5aba9) # Conflicts: # x-pack/platform/plugins/shared/cases/server/common/models/case_with_comments.ts
christineweng
enabled auto-merge (squash)
September 15, 2026 16:17
8 tasks
kibanamachine
requested review from
radtke-vale
and removed request for
kibanamachine
September 15, 2026 16:17
Contributor
Selected for Libra reviewThis PR was selected for Libra review as part of the temporary 50% trial. To opt out permanently, remove the |
kibanamachine
left a comment
Contributor
There was a problem hiding this comment.
Libra found 1 issue.
Generated by Libra
christineweng
force-pushed
the
backport/9.5/pr-291173
branch
from
September 15, 2026 16:40
4a2fd68 to
75e72cf
Compare
kelvtanv
approved these changes
Sep 15, 2026
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
Test Failures
History
|
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.
Backport
This will backport the following commits from
mainto9.5:Questions ?
Please refer to the Backport tool documentation