Security features comparison - Angular-React
Security features comparison - Angular-React
Input Validation
How do we prevent attacks that exploit input
validation vulnerabilities to inject malicious
code or data into the application?
4
Content Security Policy (CSP)
What additional security measures are needed
to implement security standards/policies that
help in preventing code injection attacks and
other cross-site scripting (XSS) attacks?
Dependency Protection
What additional security mechanism help
ensure that all dependencies are resolved
appropriately and securely, avoiding risks that
can be introduced by manually managing
dependencies?
Security Reference
Angular
It has built-in input validation that verifies user input on the client
side before sending it to the server using reactive forms or
template-driven forms.
Use:
import { ReactiveFormsModule } from '@angular/forms';
-or-
Use:
import {HttpClientXsrfModule} from
'@angular/common/http'
Use:
import {
HttpEvent, HttpInterceptor, HttpHandler, HttpRequest
} from '@angular/common/http';
It provides buit-in support for Content Security Policy (CSP),
allowing developers to specify a policy that limits the sources of
content that an application may load.
1. Enable CSP:
<meta http-equip="content-security-policy" content="default-
src 'self ...'">
Use:
filename: data.service.ts
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root';
});
See:
Angular Router Module
See:
https://github.com/axios/axios
Benefits of Dependency Injection
1. Modularization - assist your application's attack surface be smaller. You may lessen the
effects of any possible security flaws by segmenting your code into smaller, more focused
modules.
2. Encapsulation - DI helps to enforce encapsulation, which means that components can only
access services and other dependencies that are explicitly injected into them. The possibility of
code injection attacks is decreased.
3. Centralized Configuration - DI allows you to manage and update your dependencies more
easily over time by centralizing the setup of all of your application's dependencies in one
location.