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

Use postMessage instead of directly making API calls in the overlay iframe. #13446

Merged
merged 6 commits into from Oct 3, 2018

Conversation

diosmosis
Copy link
Member

This fix replaces #13420 as we noticed some other issues in Overlay when reviewing it.

Fixes #13406

@@ -139,6 +144,7 @@ var Piwik_Overlay = (function () {
function hashChangeCallback(urlHash) {
var location = getOverlayLocationFromHash(urlHash);
location = Overlay_Helper.decodeFrameUrl(location);
iframeOrigin = location.match(DOMAIN_PARSE_REGEX)[0];
Copy link
Member

Choose a reason for hiding this comment

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

can we be sure there will be an entry with index [0]?

var url = decodeURIComponent(strData[2]);

var params = broadcast.getValuesFromUrl(url);

Copy link
Member

Choose a reason for hiding this comment

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

Can we here only allow specific API methods needed for overlay to increase the security?

iframeDomain = currentUrl.match(/http(s)?:\/\/(www\.)?([^\/]*)/i)[3];
var m = currentUrl.match(DOMAIN_PARSE_REGEX);
iframeDomain = m[3];
iframeOrigin = m[0];
Copy link
Member

Choose a reason for hiding this comment

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

I presume an attacker cannot set a different iframeOrigin to her or his liking? eg by crafting a url that matches the regex etc... Also m[0] and m[3] might not be defined for whatever reason... might need to add some check there to make sure they are set...

I'm thinking would it be possible for additional security to only accept origins of configured siteURLs? I think this check is done so far maybe in the twig but not sure if in JS

@diosmosis
Copy link
Member Author

@tsteur Updated.

@tsteur
Copy link
Member

tsteur commented Oct 2, 2018

LGTM if tests pass

@diosmosis diosmosis merged commit 67eaa2c into 3.x-dev Oct 3, 2018
@diosmosis diosmosis deleted the 13406-overlay-api2 branch October 3, 2018 05:59
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
…frame. (matomo-org#13446)

* Use postMessage instead of directly making API calls in the overlay iframe.

* Make sure it will work when Matomo is on a subfolder.

* Increase overlay security with domain and method whitelists.

* Try to fix UI test.

* Fix tests + UI test blacklist check.

* broadcast.getValuesFromUrl does not decode URL params.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: You can't access this resource as it requires 'view' access for the website id = 60.
2 participants