Skip to content

[9.5] [Cases] Fix unified event attachments bypassing closed-case check (#291173) - #291204

Merged
christineweng merged 3 commits into
elastic:9.5from
christineweng:backport/9.5/pr-291173
Sep 15, 2026
Merged

christineweng merged 3 commits into
elastic:9.5from
christineweng:backport/9.5/pr-291173

Conversation

@christineweng

Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.5:

Questions ?

Please refer to the Backport tool documentation

…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 christineweng added the backport This PR is a backport of another PR label Sep 15, 2026
@christineweng
christineweng enabled auto-merge (squash) September 15, 2026 16:17
@kibanamachine
kibanamachine requested review from radtke-vale and removed request for kibanamachine September 15, 2026 16:17
@kibanamachine kibanamachine added the reviewer:libra PR review with Libra. This disables Claude and Scout reviewers label Sep 15, 2026
@kibanamachine

Copy link
Copy Markdown
Contributor

Selected for Libra review

This PR was selected for Libra review as part of the temporary 50% trial.

To opt out permanently, remove the reviewer:libra label. It will not be added again to this PR.

@kibanamachine kibanamachine 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.

Libra found 1 issue.

Generated by Libra

Comment thread x-pack/platform/plugins/shared/cases/server/common/models/case_with_comments.ts Outdated
@kibanamachine

Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

Test Failures

  • [job] [logs] Scout Lane #26 - stateful-classic / default / local-stateful-classic - CustomStatusAlert - creates a custom status alert rule
  • [job] [logs] Scout Lane #28 - stateful-classic / default / local-stateful-classic - Event Annotation listing page - delete flow - select all and delete removes every group and surfaces the empty state
  • [job] [logs] Scout Lane #28 - stateful-classic / default / local-stateful-classic - Event Annotation listing page - renders the toolbar and saved annotation groups

History

@christineweng
christineweng merged commit e3f7abe into elastic:9.5 Sep 15, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR reviewer:libra PR review with Libra. This disables Claude and Scout reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants