I ran into this when deploying an event receiver that would update the master page of all sites (SPWeb objects) when activated in a particular site collection (SPSite object).
Accessing referenced file from is not allowed because the reference is outside of the App Web.


Better Resolution

I adapted this script to something a bit more readily reusable:  Just enter the root URL of a site collection and it will update the master pages for all app webs within it.