Skip to content

safeRendering: initial release - #15896

Open
dgirardi wants to merge 43 commits into
prebid:masterfrom
dgirardi:renderBid
Open

dgirardi wants to merge 43 commits into
prebid:masterfrom
dgirardi:renderBid

Conversation

@dgirardi

Copy link
Copy Markdown
Collaborator

Type of change

  • Feature

Description of change

This adds a new safeRendering module that exposes a new public API method renderBid and a single setting safeRendering.exclusive.

renderBid(bid, options) takes a bid (or just an object with an adId) and renders it in its .element, within an iframe that mimicks GAM safeframe isolation (there's no $sf yet, but the iframe cannot reach outside and has the same sandbox setup). options are the same options accepted by renderAd.

safeRendering.exclusive turns off cross-origin messages that are not coming from renderBid. Currently any code that can postMessage to Prebid's window and has a valid adId can get information about the ad and trigger some of prebid's rendering logic; with exclusive: true, any message that does not present the same token and source set up by renderBid is ignored.

Other information

Closes #15847

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T20:46:30.374946Z 2d66347 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

This PR introduces changes that may not work on all browsers. According to Babel, the following polyfills may be needed, and they are not automatically included:

  • Changes to modules/safeRendering.ts may need:
    • es.json.stringify
    • es.map.get-or-insert
    • es.map.get-or-insert-computed
    • es.weak-map.get-or-insert
    • es.weak-map.get-or-insert-computed
    • esnext.map.get-or-insert
    • esnext.map.get-or-insert-computed
    • esnext.weak-map.get-or-insert
    • esnext.weak-map.get-or-insert-computed
  • Changes to src/adRendering.ts may need:
    • es.array.push
  • Changes to src/secureCreatives.js may need:
    • es.weak-map.get-or-insert
    • es.weak-map.get-or-insert-computed
    • esnext.weak-map.get-or-insert
    • esnext.weak-map.get-or-insert-computed

The best way to address this is to provide good test coverage, as normal PR checks run unit tests on older browsers.

Comment thread src/secureCreatives.js
export function receiveMessage(ev, cb) {
const data = parseMessage(ev);
if (data && isMessageAllowed(ev, data)) {
HANDLER_MAP[data.message](ensureAdId(data.adId, getReplier(ev)), data, getBidForMessage(data));

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d66347b5b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread modules/safeRendering.ts
fail(AD_RENDER_FAILED_REASON.CANNOT_FIND_AD, `Cannot find ad '${bid.adId}'`);
return;
}
const element = getAdUnitElement(actualBid);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject legacy renderer bids before sandboxing

🤖 This comment was written by an AI agent (GPT-5.6 Sol) on behalf of the requester.

When renderBid is called for an outstream/custom-renderer bid that has renderer but no safeRenderer, this path still creates the sandbox, but doRender.before later calls executeRenderer and bails before handleRenderRequest sends the iframe a response. Since that handler supplies no doc, executeRenderer falls back to the publisher's document, so bidder renderer code executes outside the promised isolation and the new iframe remains unanswered; reject this bid shape or route it through a safeRenderer before proceeding.

Useful? React with 👍 / 👎.

Comment thread src/secureCreatives.js Outdated
@barecheck

barecheck Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Barecheck - Code coverage report

Total: 91.75%

Your code coverage diff: 0.01% ▴

Uncovered files and lines
FileLines
creative/crossDomain.js107
modules/safeRendering.ts97-98, 150
src/adRendering.ts141-143, 164, 169, 195-196, 428, 451, 474, 487
src/prebid.ts150, 190, 193, 216-219, 255, 310-315, 355-356, 417, 587, 595-596, 636-638, 641-642, 864, 957, 966-968, 972-973, 1002, 1074-1075, 1077, 1085-1086, 1088, 1093, 1188, 1239, 1307, 1357-1358
src/secureCreatives.js32, 66, 127-128, 132-133, 145-146

Comment thread src/secureCreatives.js Fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secure Creative Rendering Module

2 participants