Check origin in window.addEventListener('message') #12010#12013
Check origin in window.addEventListener('message') #12010#12013yasmoradi merged 2 commits intobitfoundation:developfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughAdds a security gate to the message event listener that checks the origin of incoming messages and ignores cross-origin messages originating from within the window (iframes/tabs). Expands previous comment with detailed security rationale while preserving existing PUBLISH_MESSAGE handling logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR addresses a security vulnerability by adding origin verification to the window message event listener. The change prevents potential Cross-Site Scripting (XSS) attacks by validating that messages received from the window context originate from the same domain, while still allowing trusted messages from service workers.
Changes:
- Added origin validation logic to check if messages come from the same origin when received via window.postMessage
- Added comprehensive documentation explaining the security rationale for window vs. service worker message handling
- Refactored comment placement for better code organization
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Scripts/events.ts
Outdated
Show resolved
Hide resolved
…te.Client.Core/Scripts/events.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yas Moradi <yas@bitplatform.dev>
closes #12010
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.