-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
@@ -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]; |
There was a problem hiding this comment.
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); | ||
|
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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
@tsteur Updated. |
LGTM if tests pass |
…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.
This fix replaces #13420 as we noticed some other issues in Overlay when reviewing it.
Fixes #13406