Repository navigation
Description
🤖 This issue was written by an AI agent (Claude Code) on behalf of @patmmccann.
What happens
updateEventIfRequired → updateAuctionContext merges the account's analytics.modules.<reporter> config into ext.prebid.analytics.<reporter> for each reporter, but it writes into the request's existing JsonNode objects instead of copies:
Lines 433 to 446 in 9ac3345
| final JsonNode analyticsNode = extRequestPrebid != null ? extRequestPrebid.getAnalytics() : null; | |
| if (analyticsNode != null && analyticsNode.isObject()) { | |
| final ObjectNode adapterNode = Optional.ofNullable((ObjectNode) analyticsNode.get(adapterName)) | |
| .orElse(mapper.mapper().createObjectNode()); | |
| moduleConfig.fields().forEachRemaining(entry -> { | |
| final String fieldName = entry.getKey(); | |
| if (!"enabled".equals(fieldName) && !adapterNode.has(fieldName)) { | |
| adapterNode.set(fieldName, entry.getValue()); | |
| } | |
| }); | |
| ((ObjectNode) analyticsNode).set(adapterName, adapterNode); |
adapterNodeis the liveanalyticsNode.get(adapterName)when it exists, andadapterNode.set(...)adds the account fields to it.((ObjectNode) analyticsNode).set(adapterName, adapterNode)changes the sharedext.prebid.analyticsobject.
The new BidRequest/AuctionContext built afterwards still points to the same, now changed, node.
Which node is shared:
- AMP and video events: always the original request's node, because they aren't trimmed per reporter (see Analytics: AMP and video events skip activity controls applied to auction events #4715).
- Auction events: the original node for any reporter that has no entry in
ext.prebid.analytics, becauseprepareAnalyticsreturnsnulland the originalextis kept (L324-L350). It is also the original node forlogAnalytics, which is exempt from trimming.
Reporters run one after another through vertx.runOnContext. So when a reporter that shares the node runs after another reporter's config was merged into it, it sees the earlier reporter's account-level module config under the earlier reporter's key.
Why it matters
Account-level analytics module config (e.g. per-publisher keys or scope IDs for a reporter) could end up visible to other reporters. Which reporters see it depends on reporter order. Changing the request in place from inside the analytics path is also fragile if anything else reads the request afterwards.
To reproduce
Two reporters enabled, e.g. pubstack and greenbids. Account config:
{ "analytics": { "modules": { "pubstack": { "key1": "a" }, "greenbids": { "key2": "b" } } } }An AMP (via stored request) or video request with "ext": {"prebid": {"analytics": {"pubstack": {}, "greenbids": {}}}}: the reporter that runs second sees the other reporter's merged account fields in ext.prebid.analytics.
Expected behaviour
Each reporter gets its own copy of ext.prebid.analytics (ideally trimmed to its own entry), and the request object isn't changed.
Suggested fix
Work on analyticsNode.deepCopy() (and a copy of the adapter node) in updateAuctionContext, and build the new ExtRequestPrebid from that copy.
References
- Found while documenting PBS analytics events: Prebid Server: document analytics events for PBS-Go and PBS-Java prebid.github.io#6997
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity