Skip to content

[fix][push] bind push action counters to the ingesting app - #7899

Open
ar2rsawseen wants to merge 1 commit into
masterfrom
fix/push-action-counter-scope
Open

[fix][push] bind push action counters to the ingesting app#7899
ar2rsawseen wants to merge 1 commit into
masterfrom
fix/push-action-counter-scope

Conversation

@ar2rsawseen

Copy link
Copy Markdown
Member

The [CLY]_push_action handler resolved the message by _id and later updated it by _id, with no reference to the app the event arrived under:

msgs = await Message.findMany({_id: {$in: ids}}),
...
common.db.collection('messages').updateOne({_id: common.db.ObjectID(mid)}, updates[mid])

The message id is delivered to devices in the notification payload as c.i, so it is not private to the app that sent the campaign. An event submitted with one app's key could therefore move another app's result.actioned and its per-platform and per-language subcounters.

Both the lookup and the write now carry the request's app.

One detail worth checking in review

app is stored as an ObjectID on messages — message.js:42 declares type: 'ObjectID', and api-reset.js selects with dbext.oid(ob.appId). So the request's id is converted rather than compared as a string. Comparing a string would have matched nothing and silently stopped all push action counting, which is the failure mode to watch for here.

What this is and is not

It closes an app boundary rather than a capability. A recipient of a campaign already holds the sending app's public key, since it ships inside the application they installed, and reporting an action against a message id through that key is the intended ingestion path. So these counters were always movable by a recipient; what was wrong is that a different app's key could move them.

Related and not addressed here: there is no deduplication by message, device and action, so a single recipient can report the same action repeatedly through the intended path. That is an analytics integrity question rather than an app boundary one, and it applies equally to the star-rating widget counters.

The [CLY]_push_action handler looked the message up by _id and later updated it
by _id, with no reference to the app the event arrived under. The message id is
delivered to devices in the notification payload as c.i, so it is not private to
the app that sent the campaign, and an event submitted with one app's key could
move another app's actioned counters and their platform and language subcounters.

Both the lookup and the write now carry the request's app. `app` is stored as an
ObjectID on messages, matching how api-reset selects them, so the request's id is
converted rather than compared as a string; comparing a string here would have
matched nothing and silently stopped all action counting.

This closes an app boundary rather than a capability. A recipient of a campaign
holds the sending app's public key already, since it ships inside the application
they installed, and reporting an action against a message id through that key is
the intended ingestion path. So these counters were always movable by a recipient.
What was wrong is that a different app's key could move them.
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.

1 participant