-
Notifications
You must be signed in to change notification settings - Fork 33
lvpr-tv: postMessage & controls #615
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
cf42501 to
f166290
Compare
| return; | ||
| } | ||
|
|
||
| const handleMessage = (event: MessageEvent) => { |
Check warning
Code scanning / CodeQL
Missing origin verification in `postMessage` handler Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix the issue, the handleMessage function should explicitly verify the origin of incoming messages against a list of trusted origins. This can be done by ensuring that the isAllowedOrigin function is correctly implemented and used to validate the event.origin. If the origin is not trusted, the function should immediately return without processing the message.
Steps to fix:
- Ensure the
isAllowedOriginfunction is implemented to check theoriginagainst a predefined list of trusted origins. - Use the
isAllowedOriginfunction in thehandleMessagefunction to validate theevent.origin. - Add comments to clarify the purpose of the origin check for future maintainers.
-
Copy modified line R55 -
Copy modified line R57 -
Copy modified line R61
| @@ -54,3 +54,5 @@ | ||
| const handleMessage = (event: MessageEvent) => { | ||
| // Validate the origin of the incoming message | ||
| if (!isAllowedOrigin(event.origin)) { | ||
| console.warn(`Blocked message from untrusted origin: ${event.origin}`); | ||
| return; | ||
| @@ -58,2 +60,3 @@ | ||
|
|
||
| // Process the message from a trusted origin | ||
| //console.log("Received message from parent:", event.data); |
Description
Concise description of proposed changes
Additional Information