Name some security best practices in Angular

Technology CommunityCategory: AngularName some security best practices in Angular
VietMX Staff asked 3 years ago
  1. To systematically block XSS bugs, Angular treats all values as untrusted by default (sanitation)
  2. Angular templates are the same as executable code: HTML, attributes, and binding expressions (but not the values bound) in templates are trusted to be safe. To prevent these vulnerabilities, use the offline template compiler, also known as template injection.
  3. Avoid interacting with the DOM directly and instead use Angular templates where possible.
  4. Injecting template code into an Angular application is the same as injecting executable code into the application. So, validate all data on server-side code and escape appropriately to prevent XSS vulnerabilities on the server.
  5. Angular HttpClient provides built-in support to prevent XSRF attacks on the client side.
  6. Servers can prevent the XSSI attack by prefixing all JSON responses to make them non-executable, by convention, using the well-known string ")]}',\n". Angular’s HttpClient library recognizes this convention and automatically strips the string ")]}',\n" from all responses before further parsing.