Eidpermissions race condition causes intermittent EID stripping

Abierto
#4,792 4 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 7 días

@anishb-ms ya está trabajando en esto.

Desde el 28/5/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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

Lenguaje dominante
Go
Estrellas
581
Forks
967
Merge medio
3 d 14 h
PR fusionados (30 d)
2

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de prebid/prebid-server

Todos los issues de prebid/prebid-server

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.