Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[security] bidders can execute external code on the page without winning #5117

Closed
jeremiegirault opened this issue Apr 14, 2020 · 9 comments
Closed
Assignees
Labels
bug pinned won't be closed by stalebot

Comments

@jeremiegirault
Copy link
Contributor

Type of issue

data leak / optimization / security

Description

I was playing with Renderer when creating a custom adapter with outstream video support. So I created a Renderer in order to display a player when retrieving some VAST response.
I noticed that the Renderer class loads the external script in it's constructor, not in the render function. Therefore external scripts are loaded, not only when the bid in won but when bid responses are received.
That can cause multiple requests during the auction and bidders that do not win can load any external scripts and access the whole page under the "outstream" module code. That can lead to strategies of sending empty bids to execute random code on the page.

Steps to reproduce

Here "github code" in a bid adapter interpret bids :

export const spec = {
  ...
  interpretResponse (res) {
     return {
       ...
       cpm: 0,
       renderer: Renderer.install({ url: '//foo/bar.js' })
     }
  }
}

Expected results

I expect the external script url (//foo/bar.js) to be loaded only when the bid is won.

Actual results

The external script is loaded immediately.

Workaround

As a publisher I would override using adunit-based renderer in order to prevent loading of external renderer scripts.

Platform details

[email protected] / MacOS 10.14.6 / edge beta 81.0.416.50

@stale
Copy link

stale bot commented Apr 28, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 28, 2020
@jeremiegirault
Copy link
Contributor Author

up

@stale stale bot removed the stale label Apr 28, 2020
@stale
Copy link

stale bot commented May 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 13, 2020
@jeremiegirault
Copy link
Contributor Author

not stale

@stale stale bot removed the stale label May 13, 2020
@bretg bretg added the bug label May 13, 2020
@snapwich snapwich added the pinned won't be closed by stalebot label May 13, 2020
@mkendall07 mkendall07 self-assigned this May 13, 2020
@wqi1972
Copy link
Collaborator

wqi1972 commented May 13, 2020

I guess the issue is, inside src/Renderer.js, code

  if (!isRendererDefinedOnAdUnit(adUnitCode)) {
    // we expect to load a renderer url once only so cache the request to load script
    loadExternalScript(url, moduleCode, this.callback);
  } else {
    utils.logWarn(`External Js not loaded by Renderer since renderer url and callback is already defined on adUnit ${adUnitCode}`);
  }

get called inside Renderer function, instead it suppose be called only after bid won event. (but I am not sure it suppose be after prebid auction won event or dfp auction won event)

@jeremiegirault
Copy link
Contributor Author

A simple way would be to call it in the render function. I can submit a pr if you want

@mkendall07
Copy link
Member

We definitely should not be loading the renderer code if the bid did not win. It should indeed be triggered by the render function. If that's not the case, a PR would be appreciated. We'd obviously need to test this well. Thanks for the report.

In regards to the context which the renderer is executed, it's expected to be in the global context. We have plans to change this in the future, but will take some time to flush out the technical details and implementation.

@jeremiegirault
Copy link
Contributor Author

Hello for cross-reference I added sample code : #5235
I can't build anything because of an outdated dependency, I may try it later.

@jeremiegirault
Copy link
Contributor Author

I switched node version and fixed tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pinned won't be closed by stalebot
Projects
None yet
Development

No branches or pull requests

5 participants