Skip to content

Catch possible ID mismatch when trying to update a view#26715

Merged
janheise merged 5 commits into
masterfrom
fix/view-update-id-mismatch
Jul 22, 2026
Merged

Catch possible ID mismatch when trying to update a view#26715
janheise merged 5 commits into
masterfrom
fix/view-update-id-mismatch

Conversation

@janheise

@janheise janheise commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes an oversight in #26344

which we got notified by https://github.com/Graylog2/graylog2-server/security/advisories/GHSA-w997-cmqr-xrx6

We are now also making sure that for update, the ID from the entity matches the ID from the path. The ID is not enforced by the @Valid on the view entity as it's not necessary for creation. But for an update on an existing view, it is always present and our FE always puts it in the request.

Motivation and Context

How Has This Been Tested?

manual testing, added a unit test

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@luk-kaminski luk-kaminski 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.

LGTM, thx!

@Context SearchUser searchUser) {
// the ID from the path always has to match the id from the request body for an update.
// currently, the FE always uses it like that, so mismatches should only occur when using the API directly
// possible improvement could be removing the ID from the path and only have it in the body

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.

possible improvement could be removing the ID from the path and only have it in the body

That would go against good REST principles for an update (a PUT call). For that the id has to be in the URL.

I recommend the other way around: Ignoring an id that might have been sent in the body.

@janheise janheise Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, fair point. I removed the line with the possible improvement.... The body's id is only tested now to make sure that the request is really for the intended entity - but ignored otherwise.

@janheise
janheise requested a review from boosty July 21, 2026 12:54
@boosty
boosty requested review from a team and removed request for boosty July 21, 2026 14:13
@boosty

boosty commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Forgot to mention: This PR should have a test.

@kroepke kroepke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

makes sense, i'll add a follow-on task for us to think about how to improve these types of checks to make it less likely to miss in the future.

Comment thread changelog/unreleased/pr-26715.toml Outdated
@janheise
janheise requested a review from thll July 22, 2026 08:39
@janheise

janheise commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Forgot to mention: This PR should have a test.

noted & added

@janheise
janheise merged commit 2cd0b30 into master Jul 22, 2026
26 checks passed
@janheise
janheise deleted the fix/view-update-id-mismatch branch July 22, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants