-
Notifications
You must be signed in to change notification settings - Fork 7
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
✨ Improve iframe display #842
base: preprod
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Report for the pull request #842🌐 Translation statusUI's texts
FAQ's questions
|
} | ||
}) | ||
|
||
window.addEventListener('message', function (evt) { |
Check warning
Code scanning / CodeQL
Missing origin verification in `postMessage` handler Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 2 days ago
To fix the problem, we need to verify the origin of incoming messages in the postMessage
handler. This involves checking the origin
property of the event
object against a list of trusted origins before processing the message. This ensures that only messages from trusted sources are handled, mitigating the risk of malicious messages.
- Identify the trusted origins that are allowed to send messages.
- Modify the
postMessage
handler to include a check for theorigin
property. - Only process the message if the origin is in the list of trusted origins.
-
Copy modified lines R81-R88
@@ -80,7 +80,10 @@ | ||
window.addEventListener('message', function (evt) { | ||
if ( | ||
evt.data.kind === 'resize-height' && | ||
iframe.style.height !== `${evt.data.value}px` | ||
) { | ||
iframe.style.height = `${evt.data.value}px` | ||
const trustedOrigins = ['https://www.example.com', 'https://nosgestesclimat.fr']; | ||
if (trustedOrigins.includes(evt.origin)) { | ||
if ( | ||
evt.data.kind === 'resize-height' && | ||
iframe.style.height !== `${evt.data.value}px` | ||
) { | ||
iframe.style.height = `${evt.data.value}px` | ||
} | ||
} |
|
No description provided.