Legacy widgets markAs route can leak another subscriber's notification by raw message ID
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.tsapps/api/src/app/widgets/usecases/mark-message-as/mark-message-as.usecase.tslibs/dal/src/repositories/message/message.repository.ts
Verified proof files:
apps/api/src/app/widgets/usecases/mark-message-as/mark-message-as.usecase.spec.tsapps/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:
- the status-change step is scoped to the authenticated subscriber
- 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
messageIdfrom 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_subscriberIdcontentpayload.secretMarkerpayload.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.tsapps/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:
- boot a real API instance
- create one environment
- initialize two distinct widget subscriber sessions in that same environment
- seed one attacker notification and one victim notification
- call the legacy
markAsroute as the attacker using the victimmessageId - verify the response returns the victim notification object
- verify the victim notification state is unchanged
- call the route with the attacker's own
messageIdas 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:
- include
_subscriberId: subscriber._idin the post-updatemessageRepository.find(...)query - audit other legacy widget message routes for the same pattern of scoped mutation followed by unscoped readback
- add regression tests proving one subscriber cannot obtain another subscriber's notification object through legacy widget APIs
Suggested Retest
After the fix:
- create one message for subscriber A and one for subscriber B
- authenticate as subscriber A
- call
POST /v1/widgets/messages/markAsusing subscriber B'smessageId - confirm the route is rejected or returns no victim object
- confirm the victim message remains unchanged