Skip to main content

Posts

Showing posts with the label Angular Prevent XSS CSRF Attacks

Cross Site Script Inclusion (XSSI) - Angular 5 and 4

What Is Cross Site Script Inclusion (XSSI)? Cross-site script inclusion stands for XSSI , also known as JSON vulnerability . It uses to allow an attacker's website to read data from a JSON API . The attack works on older browsers by overriding native JavaScript object constructors, and then including an API URL using a <script> tag. This attack is only successful if the returned JSON is executable as JavaScript. Servers can prevent an 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. Most of the update a page's content dynamically via asynchronous JavaScript requests that return JSON data. Sometimes, JSON can contain sensitive data , and if the correct precautions are not in place, it may be possible fo...

How To Sanitize a Value Manually in Angular?

As per our project requirement, we are sanitizes a value manually using the below sanitize methods- 1.      SecurityContext.HTML 2.      SecurityContext.SCRIPT 3.      SecurityContext.STYLE 4.      SecurityContext.NONE 5.      SecurityContext.RESOURCE_URL 6.      SecurityContext.URL Example 1 – import { Component , SecurityContext } from '@angular/core' export class App {   constructor ( private sanitizer : DomSanitizer) {     this . html = sanitizer . sanitize ( SecurityContext . HTML , "<h2>DOM Sanitize</h2><script>alert(" XSS ")</script>" );   } } Example 2 – import { Component , SecurityContext } from '@angular/core' export class App {   constructor ( private sanitizer : DomSanitizer) {     this . script = sanitizer . sanitize ( Securit...

Angular Prevent XSS/CSRF Attacks - Angular Security!

In This Article - 1.      What Is cross-site scripting (XSS) Attack? 2.      How Angular prevents cross-site scripting (XSS)? 3.      How Angular Protects Us From XSS Attacks? 4.      Attacker’s vulnerability scripts and code 5.      How To Handle XSS Vulnerability Scenarios in Angular? 6.      How To Bypass Angular XSS protection? 7.      How to sanitize a value manually? 8.      How Prevents HTML DOM Based Cross Site Scripting (XSS) Attacks? 9.      How To Handle XSS Vulnerability Scenarios in AngularJs? 10.   Examples 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 scri...