angular-security

Reviews Angular web features for XSS, CSRF, CSP, token storage, and dependency vulnerabilities.

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/envoydev/claude-stack --skill angular-security-envoydev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: angular-security
Source: https://github.com/envoydev/claude-stack/tree/main/stack/skills/angular-security
Command: npx skills add https://github.com/envoydev/claude-stack --skill angular-security-envoydev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Angular's default escaping closes classic XSS, but developers still introduce vulnerabilities through sanitizer bypasses, unsafe token storage, missing CSRF protection, and secrets shipped in the client bundle. This Skill provides a systematic client-side security checklist for hardening or reviewing Angular web features. ## Core Features & Use Cases - XSS and Sanitizer Audit: Detects dangerous bypassSecurityTrust* calls, raw innerHTML assignments, and DOM sinks that skip Angular's sanitizer, with vulnerable vs. safe code patterns. - CSP, CSRF, and Token Storage Guidance: Covers nonce-based Content-Security-Policy, HttpClient XSRF configuration for cookie-authenticated APIs, and httpOnly cookie storage versus localStorage token risks. - Supply Chain and SSR Checks: Runs npm audit --omit=dev for known CVEs and flags SSR/TransferState leaks, open redirects, and secrets compiled into environment.ts. - Use Case: Before shipping a new Angular feature that renders API data and handles login redirects, run this review to catch a bypassSecurityTrustResourceUrl on a query param and an unvalidated returnUrl open redirect. ## Quick Start Review this Angular feature for security issues including XSS, CSRF, token storage, and vulnerable npm packages.

Frequently Asked Questions about angular-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent XSS in Angular applications?▼

Angular auto-escapes interpolated values by output context, so XSS enters through escape hatches like DomSanitizer bypassSecurityTrust calls, nativeElement.innerHTML, and Renderer2 raw DOM writes. Never bypass the sanitizer on user-influenced input and prefer structural rendering over innerHTML bindings.

How to configure CSRF protection with Angular HttpClient?▼

For cookie-authenticated APIs, use provideHttpClient with withXsrfConfiguration so HttpClient reads the XSRF-TOKEN cookie and sends the X-XSRF-TOKEN header for server validation. Pure Bearer-token APIs carry no ambient cookie, so CSRF does not apply to them.

Is localStorage safe for storing auth tokens in Angular?▼

localStorage and sessionStorage are readable by any script on the origin, so one XSS drains every stored token. Prefer an httpOnly, Secure, SameSite cookie that JavaScript cannot read, paired with CSRF protection, or minimize token lifetime if JS storage is unavoidable.

Can I put API keys in Angular environment.ts?▼

No, environment.ts is compiled into the client bundle and anything in it is world-readable. Only publishable keys like a Stripe publishable key belong client-side; real secrets must stay behind a backend-for-frontend.

When does this Angular security review not apply?▼

It covers only the client-side web surface, not non-security work or the mobile native shell. Server-side findings route to ASP.NET hardening guidance, and native-shell issues like Keychain storage and WebView lockdown route to the Ionic/Capacitor attack surface review.