Skip to content

Ensure message ids are server-owned#5941

Open
rebel117 wants to merge 1 commit into
SecureBananaLabs:mainfrom
rebel117:fix-5939-message-id-server-owned
Open

Ensure message ids are server-owned#5941
rebel117 wants to merge 1 commit into
SecureBananaLabs:mainfrom
rebel117:fix-5939-message-id-server-owned

Conversation

@rebel117

@rebel117 rebel117 commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Fixes #5939 (parent bounty: #743)

POST /api/messages was spreading the caller payload before assigning the generated id, so a client could include an id field and override the server-generated one.

What changed

  • messageService.js: Moved id and sentAt assignments after the payload spread so server-owned fields always take precedence over anything the caller provides.
  • message-id-server-owned.test.js: 2 regression tests confirming that a client-supplied id is ignored and that the normal message creation flow still works.

Testing

node --test src/tests/*.test.js
✔ 3 tests pass (1 existing + 2 new)

No existing behavior is affected — messages without a caller-supplied id work exactly as before.

sendMessage() was spreading the caller payload before assigning the
generated id, so a client could override it by including their own id
field. Moved the id and sentAt assignments after the spread so they
always win.

- Reorder property spread in messageService.js
- Add 2 regression tests: client-controlled id ignored, normal flow
github-actions Bot added a commit that referenced this pull request Jun 8, 2026
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.

Bug: Message creation accepts client-controlled id field

1 participant