Eidpermissions race condition causes intermittent EID stripping

オープン
#4,792 コメント 4 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

@anishb-ms がすでに取り組んでいます。

2026年5月28日 から。

評価

この issue はまだ評価されていません。

説明

Context

We are working with requests to PBS that contain an EID and a corresponding entry under eidpermissions. (See attached example using source ceeid.eu.)

Observed behaviour

We observe intermittent behaviour from PBS: sending an identical request to PBS many times causes the requests to the bidders to be sometimes constructed with the EID, sometimes without. Here are three different examples that PBS generated in response to the identical incoming example request linked above.

Expected behaviour

100x identical requests to PBS --> 100x identical requests to all bidders.

Troubleshooting so far

I asked Claude to analyse why this is the case and it pinpointed the following limitation in the PBS codebase. Would be great if a more knowledgeable person could check whether this analysis holds up.

Claude Analysis

Problem

When Prebid Server processes an auction with multiple bidders and ext.prebid.data.eidpermissions configured, EIDs are intermittently stripped from bidder requests that should be permitted to receive them.

In our captured sport.cz request, source ceeid.eu is explicitly allowed for adform, adf, and sspBC. The outbound requests showed:

Bidder Permitted? Received ceeid.eu?
adform yes yes
adf yes no
sspBC yes no
ix no no (correct)

Sending the same request again produces a different subset of bidders that get ceeid.eu — the behaviour is non-deterministic.

Root cause

A shared-state bug in upstream exchange/utils.go. In the per-bidder loop in cleanOpenRTBRequests:

Plain Text
reqWrapperCopy := req.CloneAndClearImpWrappers()
bidRequestCopy := *req.BidRequest        // shallow struct copy
reqWrapperCopy.BidRequest = &bidRequestCopy
reqWrapperCopy.Imp = imps

bidRequestCopy := *req.BidRequest is a shallow copy. The User field is a *openrtb2.User, so every per-bidder copy in the loop points at the same User struct. User.EIDs is therefore shared across all bidders.

removeUnpermissionedEids then mutates that shared state:

Plain Text
reqWrapper.User.EIDs = eidsAllowed

The loop is for bidder, imps := range impsByBidder — and Go map iteration order is randomised. Whichever bidder gets filtered first wins:

  • If a non-permitted bidder (e.g. ix) is processed first, it removes ceeid.eu from the shared User.EIDs. Every bidder processed after it sees the already-filtered list, even if they were permitted.
  • If a permitted bidder is processed first, its filter takes an early-exit and doesn't mutate.

In our captured request, the iteration order happened to be roughly adform → ix → (adf, sspBC), which is why only adform retained ceeid.eu.

Scope

  • Affects upstream Prebid Server, not just our pbs-go/4.0.0p fork.
  • Triggers whenever eidpermissions is configured AND at least one bidder in the auction is excluded from a source that another bidder is permitted for.
  • Symptoms scale with number of bidders and number of excluded sources — silent data loss with no error logged.

Recommended fix

In cleanOpenRTBRequests, deep-copy User (or at minimum the EIDs slice) before any per-bidder mutation:

Plain Text
if bidRequestCopy.User != nil {
   userCopy := *bidRequestCopy.User
   userCopy.EIDs = slices.Clone(bidRequestCopy.User.EIDs)
   bidRequestCopy.User = &userCopy
}

Other per-bidder mutators on User (e.g. buyeruid assignment, GDPR/consent handling) may have the same exposure and should be audited as part of the fix.

Suggested actions

  1. Patch with the deep-copy fix above
  2. Verify with a load test that hammers the same sport.cz request and confirms 100% of permitted bidders receive ceeid.eu.
  3. Audit other per-bidder mutations in cleanOpenRTBRequests for the same shared-pointer pattern.

References

monetize_to_psp.json
psp_response_1.json
psp_response_2.json
psp_response_3.json

主要言語
Go
スター
581
フォーク
967
平均マージ
3日 14時間
マージ済み PR(30日)
2

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

prebid/prebid-server のほかの issue

prebid/prebid-server の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。