Skip to main content
Menu
Advisories

Legacy widgets markAs route can leak another subscriber's notification by raw message ID

GHSA-63XR-J3CR-GC9PPublished Updated GitHub

Description

Legacy Widgets markAs Route Can Leak Another Subscriber's Notification by Raw Message ID

Report Metadata

  • Target: Novu
  • Product area: legacy widgets, in-app notifications, subscriber authorization
  • Verified against: self-hosted Novu 3.15.0
  • Finding type: broken access control, subscriber-to-subscriber notification disclosure
  • Suggested severity: High
  • Confidence: High

Executive Summary

The legacy widgets endpoint POST /v1/widgets/messages/markAs accepts a subscriber JWT and is meant to mark that subscriber's notifications as seen or read. However, after applying a subscriber-scoped status update, the backend re-reads messages for the response using only _environmentId + _id and does not enforce _subscriberId.

I verified end to end that one authenticated widget subscriber can send another subscriber's raw notification messageId to this endpoint and receive the victim notification object in the HTTP response, including:

  • victim notification content
  • victim payload values
  • victim internal subscriber database id
  • victim notification metadata

The victim notification state remains unchanged, which confirms the issue is a real read leak caused by the unscoped response lookup rather than a cross-subscriber write.

Vulnerability Classification

  • Category: broken access control / IDOR-style response disclosure
  • Boundary crossed:
  • one authenticated widget subscriber to another subscriber's notification object
  • Primary impacts:
  • confidentiality

Security Expectation

Legacy widget notification routes should be scoped to the authenticated subscriber identity.

More concretely:

  • a subscriber JWT should only be able to retrieve notification objects owned by that same subscriber
  • a legacy mark-as route should never return another subscriber's notification object, even if the caller knows a valid messageId
  • notification ownership should be enforced consistently on both the write step and the response lookup

Affected Functionality

Verified vulnerable endpoint:

  • POST /v1/widgets/messages/markAs

Related code areas:

  • apps/api/src/app/widgets/widgets.controller.ts
  • apps/api/src/app/widgets/usecases/mark-message-as/mark-message-as.usecase.ts
  • libs/dal/src/repositories/message/message.repository.ts

Verified proof files:

  • apps/api/src/app/widgets/usecases/mark-message-as/mark-message-as.usecase.spec.ts
  • apps/api/src/app/widgets/e2e/mark-as-cross-subscriber-leak.e2e.ts

Root Cause Summary

The issue comes from combining two different scoping rules in the same use case:

  1. the status-change step is scoped to the authenticated subscriber
  2. the response re-read step is scoped only by environment and raw message id

That mismatch lets the caller smuggle another subscriber's messageId into the route and receive the victim message object back in the response.

Relevant Code Analysis

1. Controller Accepts Arbitrary Message IDs from the Subscriber Route

In apps/api/src/app/widgets/widgets.controller.ts, the legacy route:

  • accepts messageId from the request body
  • validates only that the ids are syntactically valid Mongo ids
  • passes them into MarkMessageAsCommand

There is no controller-side ownership validation beyond the subscriber JWT itself.

2. Status Mutation Is Properly Scoped to the Authenticated Subscriber

In apps/api/src/app/widgets/usecases/mark-message-as/mark-message-as.usecase.ts, the code first resolves the authenticated subscriber and then calls:

  • messageRepository.changeStatus(command.environmentId, subscriber._id, command.messageIds, command.mark)

This part uses the caller's internal subscriber id, so a victim message is not actually updated if it belongs to somebody else.

3. Response Lookup Drops Subscriber Ownership

Immediately after the scoped status change, the same use case performs:

  • messageRepository.find({ _environmentId: command.environmentId, _id: { $in: command.messageIds } })

That lookup does not include _subscriberId.

As a result, if the supplied message id belongs to another subscriber in the same environment, the route still loads and returns the victim message entity.

4. The Verified Runtime Behavior Matches the Code Path

The end-to-end proof shows exactly this split:

  • cross-subscriber response disclosure succeeds
  • cross-subscriber state mutation does not happen

That makes the root cause precise and hard to dismiss as intended behavior.

Attack Preconditions

The attacker needs:

  • a valid widget subscriber JWT in the target environment
  • the victim notification messageId

The attacker does not need:

  • dashboard access
  • API key access
  • organization member access
  • worker or provider control

Step-by-Step Reproduction

Test Setup

Use one environment with two different widget subscribers:

  • victim subscriber
  • attacker subscriber

Create or seed one in-app notification for each subscriber.

Reproduction A: Leak Another Subscriber's Notification

As the attacker subscriber, send:

POST /v1/widgets/messages/markAs HTTP/1.1
Authorization: Bearer <attacker-subscriber-jwt>
Content-Type: application/json

{
  messageId: <victim-message-id>,
  mark: {
    seen: true
  }
}

Expected behavior:

  • the route should reject the request or return no victim data because the supplied message belongs to another subscriber

Actual behavior:

  • the request succeeds
  • the response returns the victim notification object under data[0]
  • the response includes victim-owned content and payload

Verified example fields returned from the victim object:

  • _id
  • _subscriberId
  • content
  • payload.secretMarker
  • payload.owner

Reproduction B: Confirm the Victim State Does Not Change

After the attacker request above, read the stored victim message directly or through an owned flow.

Expected if no bug existed:

  • there should be no victim disclosure at all

Actual verified behavior:

  • the victim notification remains seen: false
  • the route still returned the victim object to the attacker

This confirms a pure confidentiality break caused by the unscoped response query.

Negative Control

As the attacker subscriber, send the same request using the attacker's own messageId.

Verified behavior:

  • the route succeeds
  • the returned object belongs to the attacker
  • the attacker's notification is actually marked as seen

This shows the endpoint is otherwise functioning normally and the bug is specific to the cross-subscriber response path.

End-to-End Verification

I verified this behavior end to end with a real HTTP harness and persisted database state.

Verification artifacts:

  • apps/api/src/app/widgets/usecases/mark-message-as/mark-message-as.usecase.spec.ts
  • apps/api/src/app/widgets/e2e/mark-as-cross-subscriber-leak.e2e.ts

Observed test results:

  • unit proof: 1 passing
  • end-to-end proof: 2 passing

The HTTP/runtime proof performs the following:

  1. boot a real API instance
  2. create one environment
  3. initialize two distinct widget subscriber sessions in that same environment
  4. seed one attacker notification and one victim notification
  5. call the legacy markAs route as the attacker using the victim messageId
  6. verify the response returns the victim notification object
  7. verify the victim notification state is unchanged
  8. call the route with the attacker's own messageId as a negative control and verify normal behavior

Impact

This is a concrete subscriber-boundary confidentiality break.

Practical consequences include:

  • unauthorized access to another subscriber's in-app notification content
  • unauthorized access to notification payload data that may contain user-specific business data
  • exposure of internal subscriber/message identifiers that can assist follow-on attacks against other subscriber-bound routes

Because the route is authenticated and subscriber-facing, this is more serious than a generic information leak: it breaks the core expectation that one subscriber cannot inspect another subscriber's notifications.

Why This Is In Scope

  • this is a real authorization failure between two different subscribers
  • it has concrete confidentiality impact
  • it is not DoS-only
  • it does not rely on MITM, physical access, or social engineering
  • it is not just content spoofing without an attack path

Recommended Fix

Enforce subscriber ownership on the response lookup in the legacy markAs flow.

Concrete remediation:

  1. include _subscriberId: subscriber._id in the post-update messageRepository.find(...) query
  2. audit other legacy widget message routes for the same pattern of scoped mutation followed by unscoped readback
  3. add regression tests proving one subscriber cannot obtain another subscriber's notification object through legacy widget APIs

Suggested Retest

After the fix:

  1. create one message for subscriber A and one for subscriber B
  2. authenticate as subscriber A
  3. call POST /v1/widgets/messages/markAs using subscriber B's messageId
  4. confirm the route is rejected or returns no victim object
  5. confirm the victim message remains unchanged

Affected versions

References

GitHub · novuhq/novu