Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Angular Security Questions and Answers - Security slip ups are everywhere!

What are the key points to keep in mind when you are developing Angular apps?

There are four key points to keep in mind when you are developing an Angular's apps i.e.

1.           The application level securities like authentication and authorization.
2.           Coding with Best Practices.
3.           Preventing cross-site scripting (XSS).
4.           Reporting vulnerabilities and HTTP Level vulnerabilities.
How to write Best Practices Applications?

As per experts, be careful when developing Angular apps,
1.           We keep and watching the latest version of Angular.
2.           Don't try to add hacks or modify to Angular generates files.
3.           Avoid Angular’s Security Risk.
4.           Also, avoid direct use of the DOM APIs.
5.           Try to use offline template compiler.
6.           Try to prevent CSRF or XSRF attacks in your web apps.
7.           Try to prevent JSON data in your web apps.
8.           And so on…

What Is Cross Site Scripting (XSS) Attack?

The Cross Site Scripting (XSS) attack is a type of injection and attackers inject your web applications using the client side scripts and Malicious Code into web pages.

An attacker can insert vulnerability scripts and malicious code in your web applications.

The Cross Site Scripting (XSS) attacks are common on web browsers and it carried out on websites around 84% (approximately).


How To Preventing Cross Site Scripting (XSS) in Angular? 
How Angular Protects Us From XSS Attacks?
The Cross Site Scripting (XSS) attack is a type of injection and attackers inject your web applications using the client side scripts and malicious code into web pages.

An attacker can insert vulnerability scripts and malicious code in your web applications.
The Angular treats all values as untrusted by default. This is the great advantages of Angular.

When a value is Inserted Vulnerability into the DOM from –
1.      A Template
2.      Property
3.      Attribute
4.      Style
5.      Class Binding
6.      Interpolation
7.      And so on.

Angular recognizes the value as unsafe and automatically sanitizes and removes the script tag and other security vulnerabilities.

Angular provides built-in, values as untrusted by default, anti XSS, and CSRF/XSRF protection.

The CookieXSRFStrategy class takes care of preventing XSS and CSRF/XSRF attacks.

The DomSanitizationService takes care of removing the dangerous bits in order to prevent XSS attacks.

Angular applications must follow the same security principles as regular web applications -
1.      You should avoid direct use of the DOM APIs.
2.      You should enable Content Security Policy (CSP) and configure your web server to return appropriate CSP HTTP headers.
3.      You should Use the offline template compiler.
4.      You should Use Server-Side XSS protection.
5.      You should Use DOM Sanitizer.
6.      You should Preventing CSRF or XSRF attacks.

Angular defines the following security -
HTML is used when interpreting a value as HTML i.e.
div [innerHTML]="UNTRUSTED">div>
OR
input value="UNTRUSTED">

Style is used when binding CSS into the style property i.e.
div [style]="height:UNTRUSTED">div>

URL is used for URL properties i.e.
a [href]="UNTRUSTED-URL">a>
OR
script [src]="UNTRUSTED-URL">script>
OR
iframe src="UNTRUSTED-URL" />

Resource URL is a URL that will be loaded and executed i.e.
script>var value='UNTRUSTED';script>


p class="e2e-inner-html-interpolated">{{htmlSnippet}}p>
p class="e2e-inner-html-bound" [innerHTML]="htmlSnippet">p>


Impact of Cross Site Scripting (XSS) -
When attackers successfully exploit XSS vulnerabilities in a web application, they can insert scripts and malicious code.

An Attacker can 
1.      Hijack user’s account
2.      Access browser history and clipboard contents
3.      Application cookies, sessions
4.      Control the browser remotely
5.      Scan and exploit intranet appliances and applications
6.      And so on

Angular defines the following security -

HTML is used when interpreting a value as HTML i.e.
div [innerHTML]="UNTRUSTED">div>
OR
input value="UNTRUSTED">

Style is used when binding CSS into the style property i.e.
div


This post first appeared on Programming, please read the originial post: here

Share the post

Angular Security Questions and Answers - Security slip ups are everywhere!

×

Subscribe to Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×