-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Blob URLs are considered unsafe #947
Comments
Follow-up: I discovered after opening this issue that there other Is there perhaps a way for me to manually create a |
Blob URLs have the origin of the context that called createObjectUrl, which is typically your application. Hence, calling createObjectUrl on blob contents that are not trustworthy (provided by a potential attacker; e.g. different user of your application) is potentially dangerous - it creates a URL that's same-origin with your app, but whose contents are attacker-controlled. This can result in XSS vulnerabilities if the URL gets navigated to by your app on purpose, or the attacker can arrange for that to happen; potentially by guessing what the URL is (unfortunately, blob URLs are not required to be hard to guess by the spec, see w3c/FileAPI#74 (comment)). If you're sure from context that the content of the blob is trustworthy, you can use goog.html.uncheckedconversions.safeUrlFromStringKnownToSatisfyTypeContract to "bless" the blob URL into a SafeUrl. If the content of the blob is not trustworthy, you can do the whole thing inside a sandboxed iframe, where the blob URL origin will be the sandboxed origin of the iframe. |
Ah... |
I was attempting to redirect
window.location
to a result fromcreateObjectURL
from blob data returned in the body of anXMLHttpRequest
's response, and found thatsetLocationHref
was failing an assertion when I attempted to do so. After poking around a bit, I was able to narrow it down to a simpler reproduction case:From my understanding, this output of
sanitize
is suggesting that theblob:
URL is inherently unsafe. Based on this similar story from Lighthouse, I'm assuming this is an oversight.It seems like the fix here is just updating
SAFE_URL_PATTERN_
to account forblob
along withhttp(s)
,mailto
, andftp
.The text was updated successfully, but these errors were encountered: