We've made a Chrome extension that sits within an iFrame to prevent XSS in case of a visit to an evil.com. The purpose of the extension is to serve relevant data from a web service pertaining to the page being visited. The app authenticates via MSAL and currently stores the token in sessionStorage. Each tab requires its own login, which is a poor experience, so we're moving to use localStorage. I've found links suggesting relative security is better with sessionStorage, though the root issues seem to apply to both. What are best practices to achieve our use case, and what is the attack surface? Thank you.
-- EDITED 10/22 --
Adding diagram below to help clarify. Specific questions re MSAL.js for the given the scenario:
- Is our iframed app, or its localStorage-cached token vulnerable to anything running in the host websites
- Does using sessionStorage vs localStorage on MSAL impose any security concerns? (localStorage is very important to our UX as with sessionStorage visiting any website / new tab would start a new login process)
- Are there any CSPs that we should look into incorporating in our MSAL app that would reinforce security further?
