Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling load error within subresource integrity check

I'm implementing subresource integrity checks. I'd like to implement a fallback such that 1) the browsers loads from my CDN, performs the integrity check and carries on or 2) in the event of failing the integrity check, an embedded script launches and retrieves the needed script from my application server (resource under my control).

I have a simple javascript which catches window.onerror events, but the script is actually detecting an uncaught ReferenceError (my page references a script within the external resource), and not the browser error "Failed to find a valid digest...".

Has anyone found a way to detect the integrity check has failed, and then use javascript to pull the third-party hosted resource from a more trusted location?

like image 916
user3797714 Avatar asked Nov 03 '16 18:11

user3797714


1 Answers

Take a look at this implementation of SRI-fallback:

https://github.com/cyph/sri-fallback

like image 113
user1995422 Avatar answered Oct 03 '22 22:10

user1995422