Use local storage only for low risk data such as UI preferences, themes, or non sensitive session state. Anything written there can be read by browser code and altered by the user. If you must store a value, treat encryption as obfuscation unless the key is protected outside the browser. Sensitive secrets belong on the server, not in client storage.
What local storage is good for, and what it is not
Local storage is best treated as a convenience layer for non sensitive client state, not as a protected data store. In an Angular app, that usually means UI choices such as theme, layout, language, or other preferences that improve usability but do not create security exposure if read or changed by the user.
The key limitation is trust. Browser storage is readable by page code and editable by the person using the browser, so anything you persist there should be assumed visible and mutable. For sensitive application data, the safer pattern is to keep the value on the server and send the minimum needed to the client for rendering or interaction.
Why encryption alone does not make browser storage safe
Encryption in local storage can reduce casual inspection, but it does not change the trust boundary. If the decryption key is available in the browser, the same script context that can read the stored value can usually reach the key path as well, which turns encryption into obfuscation rather than strong protection.
That matters because the browser is part of the attacker and user-controlled environment. Any secret that must remain confidential after delivery to the page should be protected outside client storage, with the browser holding only a short-lived reference, a scoped token, or no secret at all.
When teams do need persistence for an application workflow, the safer design is to separate state from secrecy. Store identifiers or preferences locally only when exposure is acceptable, and move authentication material, recovery data, API secrets, and anything that would increase blast radius to server-side storage or a dedicated secret service.
Safer Angular patterns for client state
Angular teams should decide first whether the data can be reconstructed, reloaded, or derived on demand. If it can, avoid storing it locally. If it must persist, keep the value small, non sensitive, and time-bounded, and prefer server validation over trusting what comes back from the browser.
- Use local storage for preferences and non sensitive session hints only.
- Do not place passwords, API keys, refresh tokens, or sensitive profile data there.
- Assume users can change any stored value and build server-side checks accordingly.
- Remove stored values on logout, account switch, or when the state is no longer needed.
If the application needs stronger handling for user data at rest, the mobile app security guidance is a useful comparator because it treats client-side storage as a place where sensitive material must be tightly constrained, not casually cached. For broader data handling decisions, data access governance helps frame who should be able to reach the underlying information in the first place.
Risk and Threat Considerations
Local storage becomes risky when teams use it for values that influence authorization, identity state, or confidential business data. A malicious user, injected script, or compromised browser extension can read, alter, or replay that content, which can lead to account confusion, privilege misuse, or disclosure of information that should never have been client-side in the first place.
Failure mechanism: The application treats browser-stored data as trustworthy or confidential, but the browser execution environment is under user control and cannot enforce secrecy on its own. If a script can access the page, it can usually access local storage too.
Impact: Sensitive data can be exposed, manipulated state can be accepted by the app, and any token or credential stored there can widen the impact of XSS, session theft, or simple device access.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V9 — Self-contained Tokens | Browser-stored tokens affect token handling and replay risk. |
| Recommendation — Keep sensitive tokens out of browser storage and validate token handling server-side. | ||
| CIS Controls v8 | CIS-3 — Data Protection | Local storage can expose sensitive data at rest on endpoints. |
| Recommendation — Classify client-stored data and block sensitive values from endpoint storage. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Secret-like values in local storage create credential lifecycle risk. |
| Recommendation — Manage secrets centrally and rotate any exposed authenticators quickly. | ||
Practitioner Guidance
What to verify: Before approving any local storage use, confirm that the value is non sensitive, does not grant access, and can safely be altered without breaking security logic. If changing the stored value could change what the user can see or do, it is usually the wrong candidate for client storage.
Common mistake: Teams often store tokens because it is convenient, then try to compensate with encryption. That usually leaves the real problem untouched, because browser-side protection does not remove the need to assume read and write access by the user and any script running in the page.
Practitioner takeaway: Treat local storage as an untrusted convenience cache, not a security boundary, and design Angular flows so that sensitive data, privileged state, and durable secrets never need to survive in the browser.
Related resources from NHI Mgmt Group
- What breaks when sensitive data is stored in Android local storage without encryption?
- How should organisations train employees to use public AI tools without exposing sensitive data?
- How should organisations prepare enterprise data for AI use without exposing sensitive information to public LLMs?
- What do teams get wrong about storing sensitive application data in cookies, JWTs, local storage, or log files?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 3, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org