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

window.postMessage needs targetOrigin=* for dataurl #36039

Open
Worldwidebrine opened this issue Sep 25, 2024 · 3 comments
Open

window.postMessage needs targetOrigin=* for dataurl #36039

Worldwidebrine opened this issue Sep 25, 2024 · 3 comments
Labels
Content:WebAPI Web API docs

Comments

@Worldwidebrine
Copy link
Contributor

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

What specific section or headline is this issue about?

Security concerns

What information was incorrect, unhelpful, or incomplete?

Always specify an exact target origin, not *, when you use postMessage to dispatch data to other windows.

What did you expect to see?

Add data:, I guess?

I tried with iframe.src=dataurl, and I realized I need "*".

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@Worldwidebrine Worldwidebrine added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Sep 25, 2024
@github-actions github-actions bot added the Content:WebAPI Web API docs label Sep 25, 2024
@Josh-Cena
Copy link
Member

Josh-Cena commented Sep 25, 2024

Could you show a minimal example of what you mean? You mean when your target's URL is a data: URL you have to use "*"?

@Worldwidebrine
Copy link
Contributor Author

Worldwidebrine commented Sep 26, 2024

With a second thought, I think this should be add to

Note: Data URLs are treated as unique opaque origins by modern browsers, rather than inheriting the origin of the settings object responsible for the navigation.
https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data

rather than window.postMessage page. Sorry for that.

new URL(dataurl).origin returns string "null".
But postMessage doesn't allow string "null" as origin.
Real null or undefined value will be considered as empty origin argument, then postMessage will use current origin, and dataurl will never receive any.

@Josh-Cena
Copy link
Member

I see, I would not be opposed to a single line addition that says "note that data URLs have opaque origins, so to send data to a context with a data URL, you cannot specify the target origin."

@Josh-Cena Josh-Cena removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs
Projects
None yet
Development

No branches or pull requests

2 participants