You have the following set on your IFrame with a Blob URL/Object-URL.
allow-scripts
allow-popups
allow-same-origin
I'm assuming the contents of the IFrame are generated from user/uncontrolled input, and could contain HTML and/or script.
First, let's go through these one-by-one.
allow-scripts
This allows JavaScript code within the IFrame to run. This could be dangerous, depending on the other values set.
With allow-scripts
only, any script could
- Make AJAX requests with e.g.
fetch
, although any responses would could not be read by the IFrame. e.g. Send cross-site request forgery (CSRF) attacks, or "phone home" to the malicious's users web app. Note that contrary to popular belief, AJAX can be sent to any origin (Cross-origin writes are typically allowed
), the Same Origin Policy only prevents reading of the response, not writing. Also, it would only be able to send the same CSRF attack as an externally hosted webpage - it wouldn't be able to read the values of tokens from the parent without allow-same-origin
.
- Automatically navigate the user away from the page with
document.location
- note this is within the IFrame, not outside of it.
- Host a form (e.g. asking for username and password), to capture credentials from the user, especially effective if the attacker mimics the style of your outer side. Note this does not require
allow-forms
as the attacker can simply use JavaScript to POST the data to their own site.
allow-popups
Allows new windows/tabs to be opened from links or JavaScript. The latter will also require allow-scripts
to be set.
allow-same-origin
This allows the same origin to be used, should the origins of the documents be compatible. Note that this does not override any default origins - that is, an attacker can't host Twitter.com in an IFrame and use this to gain access to the victim's cookies or CSRF tokens within the page, nor can they simply load Twitter.com and pretend that the content was generated from the same origin as the parent.
With Blob URLs/Object-URLs, this has the affect of setting the IFrame to have the same origin as its parent, therefore letting you read and manipulate objects within the IFrame you create.
Without allow-scripts
being set, all this does on its own is allow your outer IFrame to manipulate and read objects, however, with allow-scripts
this can allow the IFrame to manipulate and read objects in the parent, i.e. your page, which is not safe.
Therefore, this setup introduces a cross-site scripting (XSS) flaw into your application due to allow-scripts
and allow-same-origin
. It would be better to consider alternative solutions to this problem that don't require allow-same-origin
. I am not sure exactly what you wish to achieve with this value from your question, but in most cases an alternative can be found.