<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhinav Naik on Medium]]></title>
        <description><![CDATA[Stories by Abhinav Naik on Medium]]></description>
        <link>https://medium.com/@abhinavnaik0601?source=rss-4d6351c632c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pW2m_xUxMivtxPG5.jpg</url>
            <title>Stories by Abhinav Naik on Medium</title>
            <link>https://medium.com/@abhinavnaik0601?source=rss-4d6351c632c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:01:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhinavnaik0601/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[LDAP Injection:]]></title>
            <link>https://medium.com/@abhinavnaik0601/ldap-injection-62a8bf165879?source=rss-4d6351c632c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/62a8bf165879</guid>
            <dc:creator><![CDATA[Abhinav Naik]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 14:30:51 GMT</pubDate>
            <atom:updated>2025-04-23T14:30:51.924Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><h3><strong>What is LDAP?</strong></h3><p>LDAP or <strong>Lightweight Directory Access Protocol</strong> is a network protocol designed to manage and access a network of directories. Such directories are generally employed to store usernames, passwords, email addresses, and organizational information. LDAP is extensively deployed in enterprise settings to perform authentication, email lookup, and access control.</p><h3><strong>What is LDAP Injection?</strong></h3><p>LDAP Injection is a cyberattack against applications that construct LDAP queries based upon user input. If an application does not sanitize or validate input data adequately, attackers can use this to introduce malicious LDAP statements. Such injected queries are able to control the actions of the LDAP query, with the potential to reveal or manipulate sensitive information, invalidate authentication, or provide unauthorized access.</p><h3><strong>How it works?</strong></h3><p>LDAP Injection occurs when an application builds LDAP queries using unsanitized user input. LDAP search filters, used to query the LDAP server, can be manipulated if user-supplied values (like username and password) are directly inserted into these filters.</p><p>If an attacker enters special characters (like &quot;*&quot;), they can alter the logic of the query. For example, using &quot;*&quot; may return all user records, while using logical operators can create conditions that always evaluate as true, effectively bypassing authentication.</p><p>The attack works because the application doesn’t validate or sanitize inputs before building LDAP queries.</p><p>LDAP queries are structured filters used to search directory services. For example:</p><p>(&amp;(uid=john)(userPassword=secret))</p><p>If user input is directly inserted into the query without validation, an attacker might input something like:</p><p>*)(uid=*))(|(uid=*</p><p>Resulting in a query that could bypass authentication or leak data.</p><h3><strong>Impact:</strong></h3><ul><li><strong>Bypassing authentication:</strong> Attackers can gain access without proper credentials.</li><li><strong>Data Exposure:</strong> Achieve unauthorized access to confidential directory information.</li><li><strong>Privilege Escalation:</strong> Change group memberships or attributes.</li><li><strong>Data Manipulation:</strong> Alter or remove directory entries.</li></ul><h3><strong>Testing Methodology:</strong></h3><blockquote><strong>1. Identify LDAP-Connected Features</strong></blockquote><p>Focus on inputs tied to directory services like:</p><ul><li>Login forms</li><li>User search</li><li>Password recover</li><li>Employee directories</li></ul><p>These are potential points for LDAP interaction.</p><blockquote><strong>2. Understand Query Context</strong></blockquote><p>Determine how user inputs are used in LDAP queries.<br> Example:<br> (&amp;(uid=admin)(userPassword=password))</p><blockquote><strong>3. Inject Payloads</strong></blockquote><p>Test with common LDAP injection strings:</p><ul><li>*)(uid=*))(|(uid=*</li><li>admin)(|(password=*)</li><li>&#39; OR &#39;1&#39;=&#39;1— — -A generic payload used to test for injection behavior.<br> Also try URL-encoded variants (e.g., %2a for *).</li></ul><blockquote><strong>4. Monitor Application Behavior</strong></blockquote><p>Look for:</p><ul><li>Unexpected logins</li><li>Multiple user records displayed</li><li>Errors revealing LDAP structure</li><li>Changes in response behavior</li></ul><blockquote><strong>5. Test Bypass Techniques</strong></blockquote><ul><li>Inject into <strong>GET/POST parameters</strong>, headers, cookies</li><li>Use <strong>Unicode/URL encoding</strong></li><li>Try <strong>blind LDAP injection</strong> (e.g., based on response timing)</li></ul><h3>Preventing LDAP Injection Attacks</h3><ul><li>Apply Proper Encoding<br>Encode input at the application layer and enforce strict login validation to block injection attempts.</li><li>Sanitize Inputs<br>Filter and clean user inputs before using them in LDAP queries. Special characters like ()!|&amp;* should be safely encoded.</li><li>Avoid Special Characters<br>For stronger protection, don’t allow special characters in input fields that interact with LDAP, and avoid combining LDAP filters dynamically.</li><li>Use Whitelisting<br>Validate all user input against a whitelist of allowed characters or values (e.g., a list of approved usernames). Always enforce this on the server side.</li><li>Escape User Input<br>Escape every user-supplied value to ensure it’s treated as a literal string — not executable logic. For example, in Java, use backslashes (\\) to escape special characters in search filters.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62a8bf165879" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authentication Token Vulnerabilities:]]></title>
            <link>https://medium.com/@abhinavnaik0601/authentication-token-vulnerabilities-8a986171c173?source=rss-4d6351c632c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a986171c173</guid>
            <dc:creator><![CDATA[Abhinav Naik]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 21:02:27 GMT</pubDate>
            <atom:updated>2025-04-22T21:02:27.611Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Authentication Token Vulnerabilities</strong> refer to weaknesses in how authentication tokens (used to verify users and maintain sessions) are handled, stored, or transmitted, which attackers can exploit to gain unauthorized access. These vulnerabilities can be exploited to gain unauthorized access, impersonate users, or bypass authentication altogether.</p><p>Common Authentication Token Vulnerabilities:</p><blockquote><strong>1. Insecure Token Storage</strong>:</blockquote><blockquote><strong>Insecure Token Storage</strong> occurs when authentication tokens are saved in vulnerable locations like localStorage or sessionStorage, making them accessible to malicious scripts during XSS attacks. This can lead to session hijacking and unauthorized access.</blockquote><p><strong>Testing:</strong> Inspect the application to identify whether tokens are stored in client-side storage or in cookies lacking proper security flags.</p><p><strong>Mitigation:</strong> Use secure cookies to store tokens, ensuring they are marked with HttpOnly, Secure, and SameSite attributes to prevent client-side access and cross-site attacks.</p><blockquote><strong>2. Token leakage:</strong></blockquote><blockquote><strong>Token Leakage</strong> occurs when authentication tokens are unintentionally exposed through URLs, browser history, or server logs. These tokens can be easily intercepted via referrer headers or shared links, allowing attackers to hijack user sessions and gain unauthorized access.</blockquote><p><strong>Testing</strong>: Analyze browser history and inspect network traffic to detect whether tokens appear in request URLs.</p><p><strong>Mitigation</strong>: Refrain from embedding tokens in URLs; use authorization headers to transmit tokens securely.</p><blockquote><strong>3. Token Replay Attacks:</strong></blockquote><blockquote><strong>Token Replay Attacks</strong> occur when an attacker captures a valid authentication token and reuses it to impersonate the user. Without proper safeguards like token expiration, IP/device binding, or token rotation, the system may accept the reused token, leading to unauthorized access.</blockquote><p><strong>Testing:</strong> Use an intercepting proxy to capture tokens and attempt to replay them to verify if access is still granted.</p><p><strong>Mitigation:</strong> Ensure each session uses a unique token, apply nonce validation, and enforce the use of short-lived tokens to limit the risk.</p><blockquote><strong>4. Weak Token Generation:</strong></blockquote><blockquote><strong>Weak Token Generation</strong> occurs when tokens are created using predictable or easily guessable methods, making them vulnerable to brute-force attacks.</blockquote><p><strong>Testing:</strong> Examine token patterns and assess their randomness using security tools.</p><p><strong>Mitigation:</strong> Employ cryptographically secure methods for generating random tokens to ensure unpredictability.</p><blockquote><strong>5. Missing Expiration or Revocation:</strong></blockquote><blockquote><strong>Missing Expiration or Revocation</strong> occurs when tokens lack an expiry time or cannot be revoked after logout or a security breach. This can lead to tokens being valid indefinitely, increasing the risk of unauthorized access.</blockquote><p><strong>Testing:</strong> Verify token expiration settings and assess session continuity and also, verify if tokens remain active after logout or password changes.</p><p><strong>Mitigation:</strong> Use short token lifetimes and ensure secure token refresh processes and also, Implement token revocation mechanisms and allow users to log out from all devices.</p><blockquote><strong>6. Improper JWT Handling:</strong></blockquote><blockquote><strong>Improper JWT Handling</strong> involves insecure practices like accepting unsigned tokens, using weak algorithms, or failing to validate claims such as issuer, audience, and expiration. These flaws can allow attackers to forge or misuse tokens. Proper verification of signatures and claims is essential for secure JWT usage.</blockquote><p><strong>Testing:</strong> Tamper with the JWT payload and observe whether the server still processes the token without verifying its signature.</p><p><strong>Mitigation:</strong> Ensure JWT signatures are always verified using strong secret keys or asymmetric encryption (public/private key pairs).</p><blockquote>7. Scope or Claims Escalation:</blockquote><blockquote><strong>Scope or Claims Escalation</strong> occurs when an attacker modifies the claims or scopes in a token — such as changing a user role to admin — to gain unauthorized privileges. This can happen if the server fails to properly validate token claims.</blockquote><p>Testing: JWT can be tampered to escalate privileges, Failing to validate claims on the server side.</p><p>Mitigations: Always enforce strict server-side validation of all claims and scopes.</p><blockquote><strong>Conclusion</strong></blockquote><p>To mitigate authentication token vulnerabilities, organizations should enforce secure storage, implement proper expiration and revocation mechanisms, validate all tokens properly, and prevent token replay attacks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a986171c173" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Cloud Basics]]></title>
            <link>https://medium.com/@abhinavnaik0601/aws-cloud-basics-bb6d847607cc?source=rss-4d6351c632c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb6d847607cc</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Abhinav Naik]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 20:55:58 GMT</pubDate>
            <atom:updated>2024-04-09T20:55:58.527Z</atom:updated>
            <content:encoded><![CDATA[<p>Introduction to AWS Cloud:</p><p>The AWS Cloud, or Amazon Web Services Cloud, is a comprehensive and widely used platform that provides a suite of cloud computing services. It offers businesses and individuals the ability to build and manage applications and services without the need for physical hardware infrastructure.</p><p>AWS Cloud refers to the global network of servers, storage, databases, networking, and other computing resources managed by Amazon Web Services. These resources are made available to customers on a pay-as-you-go basis, allowing them to access and utilize the computing power of AWS without having to invest in and maintain their own hardware.</p><h4><strong>Key Components of AWS (Data Security):</strong></h4><h3><strong>AWS Key Management Service (KMS)</strong></h3><p>AWS Key Management Service (KMS) is a managed service that allows you to create and control encryption keys used to encrypt your data in AWS. It simplifies the process of managing cryptographic keys and helps you ensure the security and integrity of your sensitive data stored in AWS services and applications.</p><h4>F<em>eatures of AWS KMS:</em></h4><ul><li><em>Centralized Key Management:</em> AWS KMS offers a centralized system to create, import, and manage cryptographic keys across multiple AWS services and applications from a single console, simplifying key lifecycle management.</li><li><em>Secure Key Storage:</em> KMS uses hardware security modules (HSMs) to protect encryption keys. Keys are securely stored within KMS and cannot be exported from the service, ensuring their integrity and confidentiality.</li><li><em>Integration with AWS Services: </em>AWS KMS seamlessly integrates with various AWS services like Amazon S3, Amazon RDS, and Amazon EBS. This integration enables encryption of data at rest using KMS keys and provides control over access to encrypted data.</li><li><em>Envelope Encryption:</em> KMS supports envelope encryption, where data is encrypted using a data key, and the data key itself is encrypted using a master key managed by KMS. This method enhances security and separates encryption responsibilities.</li><li><em>Granular Access Control: </em>AWS KMS allows you to define fine-grained access controls using AWS IAM policies. You can specify who can use specific keys, what operations they can perform, and under what conditions, ensuring secure and controlled access to keys.</li><li><em>Auditing and Monitoring:</em> AWS KMS integrates with AWS CloudTrail to provide comprehensive logging and monitoring of key usage and API calls. This auditing capability allows you to track key usage patterns, monitor security events, and demonstrate compliance with regulatory requirements.</li></ul><h4>Why AWS Key Management Service?</h4><p>Key Management Service is used to encrypt data in AWS. The main purpose of the AWS KMS is to store and manage those encryption keys. Data encryption is vital if you have sensitive data that must not be accessed by unauthorized users. Implement data encryption for both data at rest and data in transit.</p><p>Two main methods to implement encryption at rest are Client-Side Encryption and Server Side Encryption.</p><ul><li><strong>Client-Side Encryption is </strong>where you can encrypt the data on the client side and send it all the way to the server or any backend services like S3, EBS, Redshift, etc. In short, we can say in client-side encryption you encrypt your data and manage your own keys.</li><li><strong>Server-Side Encryption </strong>AWS encrypts the data and manages the keys for you, whereas you let your backend services encrypt the data and manage those keys on your behalf.</li></ul><h3><strong>AWS Secret Manager:</strong></h3><p>AWS Secrets Manager helps you manage, retrieve, and rotate database credentials, application credentials, OAuth tokens, API keys, and other secrets throughout their lifecycles. Many AWS services store and use secrets in Secrets Manager.</p><p>Secrets Manager helps you improve your security posture, because you no longer need hard-coded credentials in application source code. Storing the credentials in Secrets Manager helps avoid possible compromise by anyone who can inspect your application or the components. You replace hard-coded credentials with a runtime call to the Secrets Manager service to retrieve credentials dynamically when you need them.</p><h4>Features of Secret Manager:</h4><p><em>Secret Storage:</em><br>AWS Secrets Manager securely stores sensitive information like credentials, API keys, and configuration parameters.<br>Secrets are encrypted using AWS KMS (Key Management Service) for enhanced security.</p><p><em>Centralized Management:</em><br>Secrets Manager allows centralized management of secrets, making it easy to update, rotate, and delete secrets across multiple applications and services.<br>This centralized approach simplifies secret management and reduces the risk of scattered secrets.</p><p><em>Automatic Rotation:</em><br>AWS Secrets Manager can automatically rotate secrets on a schedule, reducing manual effort and enhancing security.<br>For example, it can periodically rotate database passwords and seamlessly update applications with the new credentials.</p><p><em>Integration with AWS Services:</em><br>Secrets Manager integrates seamlessly with various AWS services like Amazon RDS, Amazon Redshift, Amazon DocumentDB, and Lambda.<br>Applications and services can securely retrieve secrets directly from Secrets Manager when needed.</p><p><em>Access Control:</em><br>AWS Secrets Manager supports fine-grained access control using AWS IAM (Identity and Access Management) policies.<br>Access policies allow you to define who can access specific secrets and what actions they can perform, ensuring secure access to sensitive information.</p><p><em>Automatic Integration with RDS:</em><br>For Amazon RDS database instances, AWS Secrets Manager can automatically manage credentials and rotate passwords without requiring application changes.<br>This feature enhances security by regularly updating database credentials and simplifies secret management for RDS instances.</p><p><em>Auditing and Logging:</em><br>AWS Secrets Manager integrates with AWS CloudTrail to provide audit logs of secret access and management actions.<br>You can monitor and review API calls related to secret retrieval, updates, and rotations for compliance and security purposes.</p><h4><strong>Encryption and decryption processes:</strong></h4><p>To encrypt the secret value in a secret, Secrets Manager uses the following process.</p><ol><li>Secrets Manager calls the AWS KMS GenerateDataKey operation with the ID of the KMS key for the secret and a request for a 256-bit AES symmetric key. AWS KMS returns a plaintext data key and a copy of that data key encrypted under the KMS key.</li><li>Secrets Manager uses the plaintext data key and the Advanced Encryption Standard (AES) algorithm to encrypt the secret value outside of AWS KMS. It removes the plaintext key from memory as soon as possible after using it.</li><li>Secrets Manager stores the encrypted data key in the metadata of the secret so it is available to decrypt the secret value. However, none of the Secrets Manager APIs return the encrypted secret or the encrypted data key.</li></ol><p>To decrypt an encrypted secret value:</p><ol><li>Secrets Manager calls the AWS KMS Decrypt operation and passes in the encrypted data key.</li><li>AWS KMS uses the KMS key for the secret to decrypt the data key. It returns the plaintext data key.</li><li>Secrets Manager uses the plaintext data key to decrypt the secret value. Then it removes the data key from memory as soon as possible.</li></ol><h3><strong>AWS Certificate Manager:</strong></h3><p>AWS Certificate Manager (ACM) is a service provided by Amazon Web Services (AWS) that enables users to provision, manage, and deploy SSL/TLS certificates for use with AWS services and other resources. SSL/TLS certificates are crucial for securing data transmission over the internet by encrypting the communication between a client and a server.</p><p>AWS Certificate Manager (ACM) handles the complexity of creating, storing, and renewing public and private SSL/TLS X.509 certificates and keys that protect your AWS websites and applications. You can provide certificates for your integrated AWS service either by issuing them directly with ACM or by importing third-party certificates into the ACM management system. ACM certificates can secure singular domain names, multiple specific domain names, wildcard domains, or combinations of these. ACM wildcard certificates can protect an unlimited number of subdomains. You can also export ACM certificates signed by AWS Private CA for use anywhere in your internal PKI.</p><h4>Features of AWS Certificate Manager:</h4><p><em>Managed Certificate Issuance:</em> ACM manages the complexity of obtaining and renewing SSL/TLS certificates. It automatically handles certificate provisioning, validation, renewal, and deployment, simplifying the certificate management process for users.</p><p><em>Integration with AWS Services:</em> ACM seamlessly integrates with various AWS services, including Elastic Load Balancing (ELB), Amazon CloudFront, Amazon API Gateway, AWS Elastic Beanstalk, and AWS CloudFormation. This integration makes it easy to use SSL/TLS certificates provisioned through ACM with these services.</p><p><em>Highly Available:</em> ACM is designed to provide high availability and scalability. It distributes certificates across multiple AWS regions, ensuring redundancy and reliability.</p><p><em>Free Public SSL/TLS Certificates:</em> ACM offers free SSL/TLS certificates for use with AWS resources, such as Elastic Load Balancers and CloudFront distributions. These certificates are issued by Amazon Trust Services, eliminating the cost and hassle of obtaining certificates from third-party certificate authorities.</p><p><em>Private Certificate Authority (CA):</em> ACM Private CA is an extension of ACM that allows users to create their own private certificate authority within AWS. With ACM Private CA, users can issue private certificates for internal resources, such as internal websites, VPNs, and other services.</p><p><em>Secure Key Storage: </em>ACM securely stores private keys associated with SSL/TLS certificates using AWS Key Management Service (KMS), providing additional security and control over cryptographic keys.</p><h4>Why do we require an AWS Certificate Manager?</h4><p>The growing significance of SSL/TLS certificates in securing communication between clients and servers over the internet necessitates the use of AWS Certificate Manager (ACM). SSL/TLS certificates are crucial for verifying the identity of websites and encrypting sensitive information during data transfer, establishing trust between websites and users.</p><p>ACM (AWS Certificate Manager) streamlines the management of SSL/TLS certificates by automating essential tasks like certificate renewal, validation, and provisioning. It provides a centralized platform where certificates can be efficiently managed and utilized across a range of AWS services. By offering a unified solution for certificate management, ACM simplifies the overall process, reducing complexities and costs associated with certificate management.</p><p>Thanks for Reading!!!!</p><p><strong><em>References:</em></strong></p><p><a href="https://docs.aws.amazon.com/kms/latest/developerguide/overview.html">AWS Key Management Service</a></p><p><a href="https://docs.aws.amazon.com/secretsmanager/">https://docs.aws.amazon.com/secretsmanager/</a></p><p><a href="https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html">https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb6d847607cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross-site Scripting (XSS): Introduction, Types and Mitigation.]]></title>
            <link>https://medium.com/@abhinavnaik0601/cross-site-scripting-xss-introduction-types-and-mitigation-8165d9e949f3?source=rss-4d6351c632c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8165d9e949f3</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cross-site-scripting]]></category>
            <dc:creator><![CDATA[Abhinav Naik]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 04:08:30 GMT</pubDate>
            <atom:updated>2023-04-14T04:08:30.588Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>Cross-site scripting (XSS) is a type of vulnerability that occurs when malicious code is injected into a website and executed within the context of a user’s web browser. This code can then be used to carry out unauthorized actions and access sensitive data. Often, these attacks appear legitimate because the malicious code is added as parameters in the original URL or other parts of the webpage.</p><p>The severity of a cross-site scripting (XSS) attack can vary, ranging from displaying benign alert boxes to stealing cookies, session IDs, and even taking over user accounts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/0*uwy9lzhKPXX8m7AL.png" /><figcaption>XSS</figcaption></figure><p><strong>Working of XSS:</strong></p><p>XSS works by exploiting vulnerabilities in web applications, allowing for the injection of malicious JavaScript code that is then executed within the victim’s browser. When successfully executed, this malicious code can fully compromise the interactions between the user and the vulnerable web application, granting the attacker unauthorized access and control.</p><p><strong>Types of XXS</strong>:</p><p><strong>Stored XSS:</strong></p><p>Stored cross-site scripting (XSS) or Type-I XSS is a serious web vulnerability where an attacker injects malicious script that is permanently stored on the target server, such as in message boards, databases, or comment fields. When the victim’s browser requests the stored information, the malicious script is executed. This type of XSS can be particularly devastating as it can propagate automatically across multiple accounts and compromise sensitive information without the need to individually target victims or lure them to other websites.</p><p><strong>Reflected XSS:</strong></p><p>Reflected cross-site scripting (XSS) or Type-II XSS is a common web security vulnerability that occurs when server-side scripts fail to properly sanitize web client data before displaying it. This can happen, for example, with HTTP query parameters from an HTML form or a site search engine. If the system does not screen the response to reject HTML control characters, it can result in a cross-site scripting flaw. This allows an attacker to inject malicious script that is executed by the victim’s browser when they click on a link, potentially compromising the security of a trusted site.</p><p><strong>DOM-Based XSS:</strong></p><p>DOM-based XSS, also known as Client-Side XSS, is a type of XSS vulnerability that occurs when the malicious script is executed on the victim’s browser rather than the web server.</p><p>In DOM-based XSS, the attacker injects a malicious script into the web application, which is then executed by manipulating the Document Object Model (DOM) of the affected page.</p><p><strong>Impact of XSS:</strong></p><p>Cross-site scripting (XSS) can have various impacts, including:</p><ol><li>Theft of sensitive information: XSS attacks can allow attackers to steal sensitive information, such as login credentials, personal data, or financial information, from unsuspecting users. This information can be used for identity theft, fraud, or other malicious purposes.</li><li>Unauthorized actions: XSS attacks can enable attackers to perform unauthorized actions on behalf of users, such as changing account settings, making unauthorized purchases, or posting malicious content.</li><li>Defacement and disruption: XSS attacks can deface web pages, modify content, or disrupt the normal functioning of websites, leading to loss of reputation, trust, and business opportunities.</li><li>Spreading of malware: XSS attacks can be used to inject malicious code or links that can download malware onto the victim’s system, potentially leading to further compromise of the user’s device and data.</li><li>Financial and legal consequences: Organizations that fall victim to XSS attacks may face financial and legal consequences, including financial losses, regulatory fines, and lawsuits, resulting in significant damage to their reputation and business operations.</li></ol><p>Overall, the impact of XSS attacks can range from minor inconveniences to severe financial, legal, and reputational damages, making it a serious threat to web security. Proper prevention measures, such as input validation, output encoding, and secure coding practices, are crucial to mitigating the risks associated with XSS vulnerabilities.</p><p><strong>Mitigation for XSS:</strong></p><ol><li>Input validation:</li></ol><p>Validate and sanitize all user-supplied data before it is stored or displayed on a web page, including data from form inputs, URLs, and other sources. This can prevent the execution of malicious scripts.</p><p>for example,</p><p>&lt;script&gt; alert(1)&lt;/script&gt;</p><p>&lt;sCRipT&gt;alert(1)&lt;/sCRiPt&gt;</p><p>&lt;scr&lt;script&gt;ipt&gt;alert(1);&lt;/scr&lt;/script&gt;ipt&gt;</p><p>2. Output encoding:</p><p>Use appropriate output encoding techniques, such as HTML entity encoding, to ensure that user-supplied data is displayed as plain text rather than interpreted as HTML or JavaScript.HTML encoding:</p><p>Html encoding:</p><p>Escapes HTML file removing traces of offending characters that could be wrongfully interpreted as markup. The following characters are reserved in HTML and must be replaced with their corresponding HTML entities:</p><ul><li><strong>“</strong> is replaced with <strong>&amp;quot;</strong></li><li><strong>&amp;</strong> is replaced with <strong>&amp;amp;</strong></li><li><strong>&lt;</strong> is replaced with <strong>&amp;lt;</strong></li><li><strong>&gt;</strong> is replaced with <strong>&amp;gt;</strong> <strong>URL Encoding</strong></li></ul><p><strong>e.g. &amp; = &amp;amp; &lt; = &amp;lt; &gt; = &amp;rt; “ = &amp;quot;</strong></p><p>URL encoding:</p><p>URL encoding, also known as percent-encoding, is a technique used to convert special characters or non-alphanumeric characters in a URL (Uniform Resource Locator) into a format that can be safely transmitted over the internet. URL encoding is necessary because some characters, such as spaces, slashes, and special characters, have special meanings in URLs and can cause issues with the interpretation or processing of the URL by web servers, browsers, or other components of the web infrastructure.</p><p>URL encoding involves replacing special characters with their corresponding hexadecimal ASCII code, preceded by a percent sign (%). For example, the space character “ “ is encoded as “%20”, the slash character “/” is encoded as “%2F”, and the question mark character “?” is encoded as “%3F”.</p><p>3. Content Security Policy (CSP):</p><p>Implement CSP headers on web servers to specify which sources of content are allowed to be loaded by a web page, effectively preventing the execution of malicious scripts from unauthorized sources.</p><p>The Idea is if the attacker tries to load his scripts if the script won’t be on the website policy and the browser will stop it and there will be no attack. It’s a kind of white list approach where you <strong>whitelist</strong> the script source.</p><p>4. Secure coding practices:</p><p>Follow secure coding practices, such as using parameterized queries or prepared statements in database queries, avoiding the use of eval() or similar functions, and using frameworks or libraries with built-in XSS protection.</p><p>5. Use HTTP only Flag:</p><p>One additional mitigation technique for cross-site scripting (XSS) vulnerabilities is to use the “HttpOnly” flag for cookies. The HttpOnly flag is a cookie attribute that can be set by the server when sending cookies to the client. When a cookie is marked as HttpOnly, it prevents JavaScript from accessing the cookie’s value, thereby mitigating the risk of XSS attacks that attempt to steal or manipulate cookie data.</p><p>for example,</p><p>Set-Cookie: USER=USER1; expires=Wednesday, 10-Jun-2023 11:11:11GMT; HttpOnly</p><p>By setting the HttpOnly flag for cookies, web developers can ensure that sensitive information, such as session IDs or authentication tokens, stored in cookies is protected from being accessed or modified by malicious scripts injected through XSS attacks. This adds an additional layer of security to help prevent unauthorized access to user accounts or other sensitive data.</p><p>Thanks for Reading!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8165d9e949f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>