r/Web_Development • u/PlayboiCult • Jul 30 '24
iframes and CORS/XSS issues
Hello. I'm trying to provide chatbot services to companies and I'm serving the chatbots via iframes (hosted on Vercel). I'm using URL params to access different chatbot resources for different client/companies needs.
Are there CORS/XSS issues I need to be aware of when providing services via iframes? I already handle CORS via my backend (a simple '*' allowing everything atm) but I was curious to see if anyone with experience with iframes can provide any value.
Thanks in advance!
3
Upvotes
1
u/Fragrant-Touch79 Aug 07 '24
As long as you and the iframe src run on https and you allow that origin you should be fine? Wouldn't allow everything though, but maybe you intend to change that later.
1
u/Shot-Bar5086 Sep 16 '24
When providing chatbot services via iframes, you need to be mindful of both **CORS (Cross-Origin Resource Sharing)** and **XSS (Cross-Site Scripting)** issues, especially since you're using URL parameters and working with third-party clients.
CORS Considerations
You mentioned that you already handle CORS on your backend, but since you're serving chatbots via iframes, it's important to ensure:
XSS Concerns
Since you're using URL parameters to configure different chatbot resources, there's potential for **XSS attacks** if user input (URL parameters) is not sanitized properly:
Best Practices to Prevent CORS and XSS Issues
By following these best practices, you'll mitigate CORS and XSS vulnerabilities when embedding your chatbot services in iframes.