Skip to main content

XSS, CSRF and Route Guards vs Backend Authorization

Learn XSS, CSRF and Route Guards vs Backend Authorization (Phase 12 · Security and Performance (Production), Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

XSS (cross-site scripting) • XSS runs an attacker's script in your page (steals tokens and data, acts as the user). Angular is secure by default : interpolation {{ }} escapes values, and bindings to [innerHTML] , [src] / [href] and [style] are sanitised (dangerous parts such as <script> and javascript: URLs are removed). • The danger points: bypassSecurityTrust* ( DomSanitizer ) on untrusted input, direct DOM access ( nativeElement.innerHTML , document.write ), eval , building templates from user text, and third-party libraries. • Add a Content-Security-Policy header as defence in depth.

More lessons in Phase 12 · Security and Performance (Production)