Experiencing a Security Incident? → 24/7 Response: +91 73059 79248
Briskinfosec
COMPANY
About Briskinfosec Scope My Security Program Our Clients Testimonials Careers Partnership
INDUSTRIES
Banking & Financial Services Healthcare Manufacturing Government Energy & Utilities Telecom Technology Retail & E-Commerce All Industries →
CONNECT
Contact Us Request Assessment Responsible Disclosure Client Certificate Verification Training Certificate Verification
SECURITY TESTING (VAPT)
Web Application VAPT Mobile App Security API Security Testing Cloud Security Assessment Network Security Audit IoT Penetration Testing OT/SCADA Security Database Penetration Wireless Security CREST VAPT
ADVANCED ASSESSMENT
Red Team Operations AI/LLM Security Audit Digital Forensics Cyber Intelligence Secure Code Review DevSecOps Hardware Security Thick Client Security Host Level Security Automotive VAPT Telecom VAPT
DATA & PRIVACY
Data Security Audit Data Privacy Audit Data Masking & Privacy DSPM Data Breach Simulation SBOM & SCA Website Security All Assurance Services →
COMPLIANCE FRAMEWORKS
ISO 27001:2022 SOC 2 PCI-DSS HIPAA GDPR DPDPA NIST CSF IRDAI ISO 22301 (BCP) ISO 42001 (AI) IEC 62443 (OT) ISO 21434 (Automotive) PDPL (Saudi)
GRC SERVICES
GRC Framework Cyber Risk Assessment Third-Party Risk (TPRM) Data Privacy Compliance Data Retention Policy National Security Compliance Cybersecurity Insurance All Compliance →
GOVERNANCE LAYER
Data Governance Security Posture Management Cybersecurity Maturity AI Maturity Assessment Cyber Resilience BCP/DR Planning vIT Compliance Business Impact Analysis
MANAGED SECURITY
Managed Security (MSSP) SOC as a Service V-CISO Incident Response Virtual Security Team Third Eye (Surveillance)
CONTINUOUS MONITORING
SOAR Integration Security Monitoring Threat Intelligence Platform Cyber Threat Intelligence Lateral Movement Detection Penetration Test as Service
DEFENSIVE OPS
Perimeter Security Access Control Review Cloud Config Review CDN Security Network Architecture Cloud Security Management Virtualization Security All MSSP Services →
ELITE ASSESSMENTS
Threat Modeling Ransomware Readiness Threat & Vulnerability Mgmt Military Grade Review Hacker's POV Assessment
HUMAN LAYER
Security Awareness Training Phishing Simulation Tabletop Exercise Secure Code Training Cybersecurity Culture Cybersec Leadership Incident Response Training Data Privacy Training
STRATEGIC SERVICES
Application Security Governance Quarterly AppSec Review Minimum Security Baseline Secure SDLC Cyber Sense Plan Integration Threat Analysis Infra Risk Assessment Web Extensions Security bSAFE Security Score Layered Security Philosophy All Maturity Services →
PLATFORMS
LURA Portal LuraInsight (SAST) bSAFE Score BriskBox All Products →
Staffing
LEARN
Blog Videos Case Studies Press Room
INTELLIGENCE
Threatsploit Reports Security Essentials Carousel Flyers & Downloads All Resources →
Briskinfosec is a CREST accredited cybersecurity firm, globally recognized for penetration testing and VAPT services Briskinfosec is a CERT-In empanelled cybersecurity company based in Chennai with global operations in Dubai
Get Your bSafe Score →
Briskinfosec
COMPANY
About Briskinfosec Scope My Security Program Our Clients Testimonials Careers Partnership
INDUSTRIES
Banking & Financial Services Healthcare Manufacturing Government Energy & Utilities Telecom Technology Retail & E-Commerce All Industries →
CONNECT
Contact Us Request Assessment Responsible Disclosure Client Certificate Verification Training Certificate Verification
SECURITY TESTING (VAPT)
Web Application VAPT Mobile App Security API Security Testing Cloud Security Assessment Network Security Audit IoT Penetration Testing OT/SCADA Security Database Penetration Wireless Security CREST VAPT
ADVANCED ASSESSMENT
Red Team Operations AI/LLM Security Audit Digital Forensics Cyber Intelligence Secure Code Review DevSecOps Hardware Security Thick Client Security Host Level Security Automotive VAPT Telecom VAPT
DATA & PRIVACY
Data Security Audit Data Privacy Audit Data Masking & Privacy DSPM Data Breach Simulation SBOM & SCA Website Security All Assurance Services →
COMPLIANCE FRAMEWORKS
ISO 27001:2022 SOC 2 PCI-DSS HIPAA GDPR DPDPA NIST CSF IRDAI ISO 22301 (BCP) ISO 42001 (AI) IEC 62443 (OT) ISO 21434 (Automotive) PDPL (Saudi)
GRC SERVICES
GRC Framework Cyber Risk Assessment Third-Party Risk (TPRM) Data Privacy Compliance Data Retention Policy National Security Compliance Cybersecurity Insurance All Compliance Services →
GOVERNANCE LAYER
Data Governance Security Posture Management Cybersecurity Maturity AI Maturity Assessment Cyber Resilience BCP/DR Planning vIT Compliance Business Impact Analysis
MANAGED SECURITY
Managed Security (MSSP) SOC as a Service V-CISO Incident Response Virtual Security Team Third Eye (Surveillance)
CONTINUOUS MONITORING
SOAR Integration Security Monitoring Threat Intelligence Platform Cyber Threat Intelligence Lateral Movement Detection Penetration Test as Service
DEFENSIVE OPS
Perimeter Security Access Control Review Cloud Config Review CDN Security Network Architecture Cloud Security Management Virtualization Security
ELITE ASSESSMENTS
Threat Modeling Ransomware Readiness Threat & Vulnerability Mgmt Military Grade Review Hacker's POV Assessment
HUMAN LAYER
Security Awareness Training Phishing Simulation Tabletop Exercise Secure Code Training Cybersecurity Culture Cybersec Leadership Incident Response Training Data Privacy Training
STRATEGIC SERVICES
Application Security Governance Quarterly AppSec Review Minimum Security Baseline Secure SDLC Cyber Sense Plan Integration Threat Analysis Infra Risk Assessment Web Extensions Security bSAFE Security Score → Layered Security Philosophy →
PLATFORMS
LURA Portal LuraInsight (SAST) bSAFE Score BriskBox All Products →
Staffing
LEARN
Blog Videos Case Studies Press Room
INTELLIGENCE
Threatsploit Reports Security Essentials Carousel Flyers & Downloads All Resources →
Home → Blog → What Is CRLF Injection Attack?
Web Application Security

What Is CRLF Injection Attack?

July 15, 2022
6 min read
6,440 Views
Contents
What Is CRLF Injection Attack?

"Twitter is one of the most popular social media platforms available today, with 100 million daily active users and 500 million tweets sent daily. But, do they have the best cybersecurity defense? Youssef discovered It was possible to inject the CRLF injection vulnerability to HTTP response splitting in the endpoint https://ads.twitter.com/subscriptions/mobile/landing that allows to an attacker add a malicious header in the response headers.This vulnerability was spotted by Youssef on Twitter webapp and reported on hackerone.

Twitter was all in praise for this bug bounty. Now, let's understand this further so that we can avoid such vulnerabilities"

Web applications all over the digital world are full of security holes that can be used to get around security measures. One type of attack is an injection attack. We know that a web application has many injection vulnerabilities, such as SQL injection, HTML injection, CRLF injection, cross-site scripting, and many others. This article will talk in depth about the CRLF injection vulnerability and how it affects the security of web applications. Let's start with what it means.

image

What's the CRLF?

Carriage Return

Carriage return line feed is what CRLF stands for. ASCII 13 (\r) shows a carriage return, which means the end of a line. We use ‘\r’ to show that a line is over.

Line Feed

ASCII 10 (\n), which stands for "line feed," shows where a new line starts. We put '\n' at the beginning of a new line. If you write something after "n," it will start on a new line. CRLF characters are the ‘\n’ and ‘\r’ (cr and lf).

CRLF – Defined

When a user does anything on the internet, the web browser sends some requests to the web server. The web server responds to the browser's request with an HTTP response.

Some HTTP headers and the website content are part of the HTTP response. Here, the special CRLF characters come into play. They separate the headers from the actual content of the website in the HTTP response.

Carriage return line feed not only marks where a new HTTP header begins or ends, but it also tells the user where a line begins or ends in a file or a block of text.

The operating systems also use these CRLF characters. CR and LF are used to end lines in Windows, but only LF is used in UNIX/Linux. The CRLF character sequence is also used to end a line in the HTTP protocol.

What is a CRLF injection vulnerability?

The attacker attacks the web application by adding carriage return and line feed (cr and lf) through the user input area. With the CRLF injection attack, the web server or web application is tricked into thinking that the first object it was given has ended and another object has begun. Since CRLF characters were made to separate the HTTP headers from the web content, they are not meant to be harmful. But they can still be used as payloads for attacks that are meant to do harm.

The main reason for a CRLF injection attack is that the user's input is not sanitised before it is checked against a trusted source.

Injecting CRLF into a web application

In bugcrowd, CRLF injection in a web application is given a severity level of P3.

CRLF injection can further be escalated from information disclosure to Remote Code Execution. It can also lead to cross-site scripting attacks, poisoning of web caches, and many other things.

image

Impacts of CRLF injection:

Cross-site scripting:

The Web Application's protection against Cross-Site Scripting (XSS) can be gotten around by adding CRLF to the URL and putting an XSS payload in it using HTTP headers. Here, a URL-encoded value for CRLF is used to tell the browser where the request body starts and to put Cross-Site Scripting payload in it. A simple example was shown in below:

Request:

        http://example-website.com/%0d%0aLocation:%0d%0aContent-Type:text/html%0d%0aX-XSS-Protection%3a0%0d%0a%0d%0a%3csvgonload%3dalert%28document.domain%29%3e

Response:

image

Client-side Cookie Injection:

It is possible for an attacker to alter the cookie before it is transmitted to a web server, known as a Client-side Cookie Injection attack. This vulnerability can lead to Man-in-the-middle Cookie Hijacking, Session Forgery, Session Hijacking, etc.

A simple CRLF injection example is presented below:

Request:

        https://example-website.com/session_start/%0aSet-Cookie: malicious_cookie1

Response:

image

HTTP Response Splitting:

When an attacker sends a single HTTP request and forces the Server to make two output Responses, this is called HTTP Response Splitting. The attacker might be able to change some parts of the first response, but what really matters is whether or not the attacker can change the entire second response, right down to the last byte of the HTTP response body.

Request:

        http://example-website.com/url?=foobar%0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-Type:%20text/html%0d%0aContentLength:%2019%0d%0a%0d%0a

TEST

Response:

image

HTTP Header Injection:

When CRLF injection is used, HTTP header injection vulnerabilities can be opened up.

This can make it so attackers have to add or set their own HTTP custom headers to bypass the security measures like XSS filters or the same-origin policy. Attackers can also get confidential data, such as CSRF tokens, and set their own cookies. Attackers can bypass the security features of web apps this way.

If the attacker can inject HTTP headers like the "Access-Control-Allow-Origin" header, he can turn on cross-origin resource sharing and get the JavaScript codes that are protected by the "same-origin policy."

Now let's look at how to add HTTP headers to HTTP response headers. With the %0d %0a character, we can add a fake HTTP response header to the URL parameter. To add a fake HTTP response header, we will use a single CRLF. We will change the HTTP request as shown below,

Example:

GET /%0d%0aMy-Header: Header

If web applications have a CRLF injection vulnerability, the header will show up in the response headers and the other headers as well.

Preventing CRLF Injections:

  • User input should be Sanitizated.
  • Encode the CR and LF characters (\r, \n)  so that the server can't read them even if they are sent.
  • Validate the user input before they reach the response headers (example: by using methods like StringEscapeUtils.escapeJava()).
  • A header that isn't needed should be disabled.

Summary:

Developers should be careful and aware that their platforms might have these kinds of flaws.

This will help them make an application that is safe. In terms of application security, the user input can't be trusted, so it needs to be checked before it can be used in the application. We need both good development practises and security methods to keep ourselves safe from threats in the world.

Web Application Security
Share this article
A
Written by
Arulselvar Thomas Founder & Director
Cybersecurity expert at Briskinfosec Technology and Consulting, specializing in security assessments, compliance, and helping organizations build resilient security postures.
Recent Blogs
How to Create a Secure AWS IAM Audit User for Cloud Security Assessments
The Cyber Capability Gap Between Mythos, GPT-5.5 and Open-Weight Models Explained
Inside Claude Mythos and What the Indian Defender Actually Needs to Know
Related Services
VAPT Cloud Security Red Team Network Security API Security Mobile App Security
Latest Videos
Navigating Compliance in Cybersecurity Laws, Privacy laws and Your Business
Navigating Compliance in Cybersecurity Laws,...
Apr 26, 2024
Beyond Size: How to Elevate your SOC Cybersecurity Monitoring
Beyond Size: How to Elevate your SOC Cybersec...
Mar 20, 2024
Red Team Assessment
Red Team Assessment
Mar 13, 2024
Get Protected

Discuss your security posture with our certified experts. Get a free initial assessment.

Schedule Free Consultation WhatsApp Us

Related Articles

Ransomware The Deadliest Threat to Modern Cybersecurity
Ransomware The Deadliest Threat to Modern Cybersecurity
Jun 18, 2024 · 5,000
Mastering Web App VAPT The Complete Guide
Mastering Web App VAPT The Complete Guide
Apr 26, 2024 · 9,279
A Deep Dive into VAPT Methodology and Coverage Respective of Different Compliance Requirements
A Deep Dive into VAPT Methodology and Coverage Respective of Different Compliance Requirements
Nov 27, 2023 · 8,354
Read Next (Top Blog)
Getting Started with Frida

Ready to Strengthen Your Security?

Talk to our CREST-certified security experts today

WhatsApp Us
Chat instantly with our security team
AI Presales Bot
Get instant answers from LURA AI
Schedule Consultation
Book a free security consultation
Email Us
contact@briskinfosec.com
Link copied to clipboard!
About Us
About Briskinfosec Certin Our Clients Testimonials Press Room
Services
Application Security Mobile App Security Cloud Security Red Team Operations SOC as a Service MSSP All Services →
Compliance
ISO 27001 SOC 2 PCI-DSS GDPR HIPAA All Compliance →
Resources
Blog Videos Case Studies Threatsploit Reports All Resources →
Connect
Careers Partnership Contact Us Responsible Disclosure Terms and Conditions Privacy Policy
India (HQ) Bascon Futura Sv It Park, 12th Floor, 10/2,
Venkatanarayana Rd, T. Nagar, Chennai, Tamil Nadu 600017
+91 73059 79248 · contact@briskinfosec.com
UAE (Dubai) IFZA Business Park, Building A1, Dubai Digital Park,
Dubai Silicon Oasis, Post Box 342001, UAE
contact@briskinfosec.com
Briskinfosec CREST accredited cybersecurity company and globally recognized provider of penetration testing and VAPT services CERT-In empanelled cybersecurity company with headquarters in Chennai and operations in Dubai offering VAPT services Briskinfosec ISO 27001 certified company ensuring robust information security management system Briskinfosec ISO 9001:2015 certified cybersecurity company committed to quality management in India Briskinfosec is a DUNS registered cybersecurity company with a verified global business identity offering VAPT services
© 2026 Briskinfosec Technology & Consulting Pvt Ltd. All rights reserved.
Scope Your Security Program
Chat on WhatsApp Ask LURA AI AI