0% found this document useful (0 votes)
19 views

task 2 report xss

Uploaded by

anurag.21bcan254
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

task 2 report xss

Uploaded by

anurag.21bcan254
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

XSS and HTML Injection

#What is HTML injection


HTML injection is a type of attack where malicious HTML
code is inserted into a website. This can lead to a variety of
issues, from minor website defacement to serious data
breaches. Unlike other web vulnerabilities, HTML injection
targets the markup language that forms the backbone of
most websites.

#What is XSS and Types of XSS


Cross-site Scripting attacks (XSS) can be used by attackers to
undermine application security in many ways. It is most
often used to steal session cookies, which allows the
attacker to impersonate the victim. In addition to that, XSS
vulnerabilities have been used to create social networks
worms, spread malware, deface websites, and phish for
credentials. They have also been used in conjunction with
social engineering techniques to escalate to more damaging
attacks such as private information retrieval.
Cross-site Scripting can be classified into three major
categories — Stored XSS, Reflected XSS, and DOM-based
XSS.
Stored XSS (Persistent XSS)
The most damaging type of XSS is Stored XSS (Persistent
XSS). An attacker uses Stored XSS to inject malicious content
(referred to as the payload), most often JavaScript code, into
the target application. If there is no input validation, this
malicious code is permanently stored (persisted) by the
target application, for example within a database. For
example, an attacker may enter a malicious script into a user
input field such as a blog comment field or in a forum post.

Reflected XSS (Non-persistent XSS)


The second and the most common type of XSS is Reflected
XSS (Non-persistent XSS). In this case, the attacker’s payload
has to be a part of the request that is sent to the web server.
It is then reflected back in such a way that the HTTP
response includes the payload from the HTTP request.
Attackers use malicious links, phishing emails, and other
social engineering techniques to lure the victim into making
a request to the server. The reflected XSS payload is then
executed in the user’s browser.
DOM-based XSS
DOM-based XSS is an advanced XSS attack. It is possible if
the web application’s client-side scripts write data provided
by the user to the Document Object Model (DOM). The data
is subsequently read from the DOM by the web application
and outputted to the browser. If the data is incorrectly
handled, an attacker can inject a payload, which will be
stored as part of the DOM and executed when the data is
read back from the DOM.

#What are Input Validation attacks


Input validation attacks are a method of cyberattack in
which the attacker injects malicious input that can be
interpreted and executed by a target system to exploit its
vulnerabilities. Input validation attacks can employ a variety
of input types such as code, scripting, and commands.

#Impacts and Mitigation measures

Prevention Measures:
1. Input Validation and Sanitization:
o Input Validation: Strictly validate all user input to
ensure it adheres to expected formats and lengths.
o Output Encoding: Properly encode output to
prevent malicious scripts from being interpreted as
code. Use appropriate encoding techniques like
HTML encoding, URL encoding, and JavaScript
encoding.
o Context-Specific Encoding: Employ context-specific
encoding to accurately represent data within
different HTML contexts (e.g., attributes, scripts,
styles).
2. Web Application Firewalls (WAFs):
o Real-time Protection: WAFs can detect and block
XSS attacks in real-time by analyzing incoming and
outgoing traffic.
o Rule-Based and Signature-Based Detection: WAFs
use rule-based and signature-based techniques to
identify malicious patterns.
o Positive Security Model: WAFs can be configured
to allow only trusted traffic, reducing the attack
surface.
3. Secure Coding Practices:
o Minimize Trust in User Input: Never trust user
input directly. Always validate and sanitize it before
using it in dynamic content.
o Use a Secure Framework: Employ a secure web
application framework that provides built-in
security features and best practices.
o Regular Security Audits and Code Reviews:
Conduct regular security audits and code reviews
to identify and address vulnerabilities.
4. Content Security Policy (CSP):
o Restrict Resource Loading: CSP defines a security
policy that restricts the resources a browser can
load, preventing the execution of unauthorized
scripts.
o Strict Content Security: Implement a strict CSP
policy to minimize the attack surface.
o Report-Only Mode: Use report-only mode to
gather information about potential attacks without
blocking them.
Mitigation Measures:
1. Regular Patching and Updates:
o Keep Software Up-to-Date: Regularly update web
applications and frameworks to address known
vulnerabilities.
o Patch Management: Implement a robust patch
management process to promptly apply security
patches.
2. Robust Error Handling:
o Avoid Revealing Sensitive Information: Avoid
exposing sensitive information in error messages.
o Generic Error Messages: Use generic error
messages to prevent attackers from gaining
insights into the application's structure.
3. User Education and Awareness:
o Train Developers: Train developers on secure
coding practices and the risks of XSS attacks.
o User Awareness: Educate users about phishing
attacks and the importance of avoiding suspicious
links and downloads.
4. Monitoring and Logging:
o Log Web Traffic: Log web traffic to identify
suspicious activity and potential attacks.
o Monitor Security Logs: Regularly monitor security
logs for signs of intrusion attempts.

# PRACTICAL LABS
# PORTSWIGGER
Submitted By =
anuraggx

You might also like