InterviewHubPRO
Section Overview
Q172

Question 172 of 283

Part 7: Change Detection, Security (XSS/Sanitizer) & Interceptors (151 - 176)

61%
Angular & Signals (283 Qs)•Part 7: Change Detection, Security (XSS/Sanitizer) & Interceptors (151 - 176)

Does Angular prevent HTTP level vulnerabilities?

Angular has built-in support for preventing http level vulnerabilities such as as cross-site request forgery (CSRF or XSRF) and cross-site script inclusion (XSSI). Even though these vulnerabilities need to be mitigated on server-side, Angular provides helpers to make the integration easier on the client side.

  1. HttpClient supports a token mechanism used to prevent XSRF attacks
  2. HttpClient library recognizes the convention of prefixed JSON responses(which non-executable js code with ")]}',\n" characters) and automatically strips the string ")]}',\n" from all responses before further parsing

Practical Code Example

typescript
// HTTP Vulnerability Protection:
// Angular HttpClient provides built-in XSRF/CSRF protection:
// Automatically reads XSRF-TOKEN cookie and appends X-XSRF-TOKEN header to outgoing requests.