Ogury Bid Adapter: fix SecurityError in cross-origin iframes - #15480
Open
RemyLespagnol wants to merge 2 commits into
Open
Ogury Bid Adapter: fix SecurityError in cross-origin iframes#15480RemyLespagnol wants to merge 2 commits into
RemyLespagnol wants to merge 2 commits into
Conversation
Unguarded window.top access made the adapter throw and return noBid when running inside a cross-origin iframe. - request(): stop overriding site.page with getWindowContext().location.href. The core already enriches ortb2.site.page from refererInfo and merges it under the publisher's own ortb2, so the value is already correct when request() runs. Overriding it discarded publisher-configured URLs and, when the top window was unreadable, fell back to the iframe's own location. - onBidWon(): fire the nurl win ping before writing OG_PREBID_BID_OBJECT and wrap the write in try/catch, so a cross-origin write no longer prevents the win notification. - onTimeout(): report the bid's ortb2.site.page (falling back to refererInfo.page, then window.location.href) so timeout monitoring matches the URL actually sent in the bid request. Bumps ADAPTER_VERSION to 2.1.1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
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:
The best way to address this is to provide good test coverage, as normal PR checks run unit tests on older browsers. |
Barecheck - Code coverage reportTotal: 91.16%Your code coverage diff: 0.00% ▴ ✅ All code changes are covered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description of change
The Ogury bid adapter throws a
SecurityErrorand returnsnoBidwhen it runs inside a cross-origin iframe, because of unguardedwindow.topaccess in three places.1.
site.pagederivation —ortbConverterProps.request()no longer doesdeepSetValue(req, 'site.page', getWindowContext().location.href). The core already sets it:enrichFPDpopulatesortb2.site.pagefromrefererInfobefore every auction and merges it under the publisher's ownortb2, so a publisher-configuredpageUrlalready takes precedence, and the ORTB converter seeds the request frombidderRequest.ortb2. Overriding it here discarded publisher-configured URLs (custompageUrlfor SPAs, SafeFrames) and, when the top window was not readable, fell back to the iframe's own location instead of the real page.2.
onBidWon()— thenurlwin ping now fires before theOG_PREBID_BID_OBJECTwrite, and the write is wrapped intry/catch. Previously a cross-origin write threw and prevented the win notification from being sent at all, losing billing/reporting.3.
onTimeout()— reportstimeoutData[0].ortb2.site.pageinstead of the local frame'swindow.location.href, so timeout monitoring matches the URL actually sent in the bid request. Falls back togetRefererInfo().page, thenwindow.location.href, for timeout events that carry no FPD.ADAPTER_VERSIONbumped2.1.0→2.1.1.No bidder parameters were added or changed, so no documentation PR is required.
Other information
Tests added to
test/spec/modules/oguryBidAdapter_spec.js:bidderRequestBasefixture now carriesrefererInfo;buildRequests— asserts no throw and the correctsite.pagewhenwindow.top.locationthrows aSecurityError;buildRequests— asserts a publisher-providedortb2.site.pageis preserved rather than overridden;onBidWon— asserts thenurlping still fires when the top window is not writable (simulated with a frozen object, same failure shape as a cross-originSecurityError);onTimeout— asserts the reportedlocationis the top-level page URL fromortb2.site.page.Each test was confirmed to fail against the pre-fix code for the expected reason before the fix was applied.
Results:
npx eslint modules/oguryBidAdapter.js test/spec/modules/oguryBidAdapter_spec.js— clean, no issues found.npx gulp test --nolint --file test/spec/modules/oguryBidAdapter_spec.js— 92 tests completed, 0 failures.