Add allow same origin to the iFrame widget#16239
Conversation
Greptile OverviewGreptile SummaryAdded
Confidence Score: 3/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant IframeWidget
participant Backend
participant ExternalSite
User->>Backend: Create/Update Widget with URL
Backend->>Backend: Validate URL (@IsUrl decorator)
Backend-->>User: Widget saved with validated URL
User->>IframeWidget: Render widget on page
IframeWidget->>IframeWidget: Check isPageLayoutInEditMode
IframeWidget->>IframeWidget: Validate URL exists
IframeWidget->>ExternalSite: Load iframe with sandbox="allow-scripts allow-forms allow-popups allow-same-origin"
Note over IframeWidget,ExternalSite: NEW: allow-same-origin enables<br/>same-origin access (cookies, localStorage, DOM)
ExternalSite-->>IframeWidget: Render content with same-origin privileges
IframeWidget->>IframeWidget: Handle onLoad/onError events
IframeWidget-->>User: Display iframe or error state
|
| onLoad={handleIframeLoad} | ||
| onError={handleIframeError} | ||
| sandbox="allow-scripts allow-forms allow-popups" | ||
| sandbox="allow-scripts allow-forms allow-popups allow-same-origin" |
There was a problem hiding this comment.
logic: allow-same-origin combined with allow-scripts removes most sandbox protections. The iframe can now access its own origin (cookies, localStorage, DOM), potentially enabling XSS if the URL source is compromised. Verify that iframe URLs come from trusted sources only and cannot be user-controlled.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/page-layout/widgets/iframe/components/IframeWidget.tsx
Line: 106:106
Comment:
**logic:** `allow-same-origin` combined with `allow-scripts` removes most sandbox protections. The iframe can now access its own origin (cookies, localStorage, DOM), potentially enabling XSS if the URL source is compromised. Verify that iframe URLs come from trusted sources only and cannot be user-controlled.
How can I resolve this? If you propose a fix, please make it concise.|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:18183 This environment will automatically shut down when the PR is closed or after 5 hours. |
charlesBochet
left a comment
There was a problem hiding this comment.
IMO this is completely safe for two reasons:
- users are responsible to what they install / setup in their workspace. If they want to hack themselves, they can. (instead of hacking themselves through an iframe, let's just make a chrome extension :p)
- none of the browsers allow any scripting / sharing between a host and an iframe having different hosts (scheme + subdomain + domain + protocol have to be exactly equal). So the only way to hack my-twenty.twenty.com is to host an iframe on... my-twenty.twenty.com), which lead to "hack myself" scenario too
|
Hey @bosiraphael! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
Some iFrames were unusable because of this
Some iFrames were unusable because of this