0

I'm investigating if there is a "safe"/sensible way to load third party components into an angular 2+ app in a way that protects the host app from typical security vulnerabilities or any it opens up in doing so. Reading pages like:

I'm no expert so I may be asking the wrong question or looking at the wrong things so here's the situation: There's an app A and using a "market place" style setup e.g. Play store or Apple's App store type thing,

  1. A third party can submit an app B that is effectively an ng2 module
  2. App A's servers stores and hosts the angular component for app B i.e. there's no need for B to load any external files.
  3. A user of app A can choose to "install" app B after which app A will load app B for the user (some kind of manual review done on app B).

Ideally what I've been looking for is a way to lock down app B so that it can't just pull in arbitrary code into app A and possibly isolate it so that it can only access a subset/whitelisted set of the angular APIs and only a prescribed API from app A can be injected into B.

Is there a way to achieve this in angular 2+?

Am I searching for the right things in terms of ensuring the continued integrity of app A and protecting the user?

If it's not possible to isolate app B, what aspects of security should I be researching/considering? This idea is in its infancy at the moment so nothing's set in stone but some method is needed to support hosting third party code.

(Side note: Stackoverflow thinks the questions appears subjective and I don't understand why so rather than down voting, I'd learn more from comments saying why this is subjective.)

zcourts
  • 4,863
  • 6
  • 49
  • 74
  • 2
    Just a direction, you are looking to sandbox third party js like in this question: https://security.stackexchange.com/a/15193 – elpddev Apr 15 '17 at 08:41
  • @elpddev, excellent thank you. If you move your comment to being an answer I'll accept that. From your link I've had a quick eval of the options presented there and Google's Caja looks like a good choice. I did a quick angular 2 app and was able to load it fine, assuming their isolation mechanism works it's a good fit for doing (will spend more time evaluating) what I was thinking of. For ref https://developers.google.com/caja/docs/about/ – zcourts Apr 15 '17 at 12:15
  • 1
    Its just a direction. If interested, there were several other linked articles. Caja seems a bit not easy to implement. http://stackoverflow.com/questions/22535495/using-google-caja-to-run-user-supplied-javascript http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment/ – elpddev Apr 15 '17 at 23:12

0 Answers0