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 → How hackers bypass file upload and how t...
Web Application Security

How hackers bypass file upload and how to prevent it?

June 14, 2022
6 min read
17,679 Views
Contents
How hackers bypass file upload and how to prevent it?

Starbucks does have the best coffee in the world. But, do they have the best cybersecurity defense? Johnstone discovered It was possible to execute arbitrary code by uploading a webshell using the resume feature at https://ecjobs.starbucks.com.cn and then using the resume upload capability.This vulnerability was spotted by John stone on Starbucks webapp.

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

Administrators and the security team must exercise caution when dealing with files uploaded by users because they could be used as a point of entry by cybercriminals.

If these files aren't properly vetted, a remote attacker could upload a malicious file to the webserver, resulting in a major breach. Malicious files can be uploaded if proper file validation procedures are not followed. Code will be executed as a result.

According to OWASP, unrestricted file upload vulnerabilities can be used in two ways. To prevent this kind of attack, web applications usually have restrictions in place, but hackers can use a variety of methods to circumvent these restrictions and gain access to a reverse shell.

Step 1: Overcoming Whitelists

image

Whitelisting is another common form of online security. Whitelisting is exactly the opposite of blacklisting, in which the server only accepts a limited number of extensions.

If you want to upload a profile picture, for example, the app may only accept JPG, JPEG, or PNG files. Blacklisting is better than this method of prevention, but it can still be easily evaded.

Files with double extensions can be served by some web servers, such as Apache.

The server will accept a PHP file that also has a JPG extension attached to it:

shell.php.jpg

A null byte injection can also be used to get around whitelist filters. Injecting between a prohibited and an allowed extension can lead to a bypass because anything after the null character is ignored when the file is saved:

In this case, shell.php%00.jpg

Or:

shell.php\x00.jpg

It's also possible to use Burp and modify the hex request to achieve this goal. During the request, we'll replace the G character with a null character, so name the image php-backdoor.phpG.jpg.

Make sure you've intercepted an upload request before you can look for G: Hexadecimal representation.

image

Send the request by replacing the 47 with 00:

image

It's possible to use this technique in situations where null byte injection fails.

To get around whitelisting, you can use file type headers to deceive the server. GIF files can typically be uploaded in the same way that images can. The upload can be tricked by including GIF89a; at the beginning of the shell:

GIF89a; _ GET['cmd']) ; ?>

Step 2: Overcoming Blacklists

image

There are a number of ways to get around blacklisting. The term "blacklisting" refers to a security measure that prevents particular data strings, in this case, specific extensions, from being delivered to the server. Initially, it may appear to be an ideal solution for preventing dangerous extensions, often executables, from being uploaded, but it is a simple one to circumvent.

There are additional extensions that can be used to bypass blacklist filtering in addition to the usual extensions. PHP files can have these extensions:

.pht, .phtml, .php3, .php4, .php5, .php6, .inc

JSP is another popular web shell extension; nevertheless, the following are some suitable substitutes:

.jspx, .jspf, .jsw, .jsv

Filters can be tricked into accepting a file by merely altering the case of the extension, such as this:

.pHp, .Php,.phP

Step 3: Exif Information

Exif data in an image can be used to circumvent file upload limits in the next approach. An image processing server can be instructed to run a piece of legitimate PHP code in a comment.

If it hasn't previously been installed, we can utilise exiftool to accomplish this task by using the package manager to do so:

~# apt install exiftool

After that, we can add a comment to our image with a simple command shell:

~# exiftool -Comment="" image.jpg

Now that the code has been successfully added, we can see it by running the file command on our image:

~# file image.jpg

image.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, comment: "", baseline, precision 8, 1920x840, components 3

Just add a PHP extension and we'll be good to go:

~# mv image.jpg image.php.jpg

This technique can be combined with any of the approaches to bypass blacklists or whitelists.

Step 4: Other ways to bypass,

Sometimes, client-side JavaScript is the only thing that keeps files from being uploaded. If the upload still works without it, you can sometimes get around restrictions by turning JavaScript off in your browser.

If that doesn't work, it's easy to get around client-side filters by intercepting the request and changing the file extension.

Validating uploaded content can also be done by looking at the file's content type.

For example, when you upload an image, the content type of the file is usually checked to make sure it is an image and not a script or other type of malicious file.

This kind of protection is easy to get around by catching the request and changing the type of content.

In some cases, uploaded files can also be checked by how long the content is.

It depends on the situation, but a shorter payload is often all that's needed.

For example, this is how you can shorten a typical PHP command shell:

Realtime Attacks:
https://hackerone.com/reports/506646
https://hackerone.com/reports/343726
https://sidblog.medium.com/file-upload-to-rce-7c04b3b252de
https://chris-young.net/2020/04/14/file-upload-to-remote-code-execution/

[Bonus] RCE via .gif upload:
https://hackerone.com/reports/135072

Mitigation:

  • Check the formats and extensions of files, Make sure you compare the file extension of the files you upload to a list of file types that are allowed. Do this on the server side, because checks on the client side can be gotten around.
  • Keep your website updated
  • Instead of user input, name the files randomly or use a hash.
  • Use captcha to stop uploads from bots and script
  • Check if the Content-Type Header is correct, A Content-Type header will be sent along with files that are uploaded from a browser. Make sure that the type given is on a list of file types that are allowed. (Keep in mind, though, that simple scripts or proxies can fake the file type, so this protection, while useful, is not enough to stop a skilled attacker.)
  • Don't show the path of the file you uploaded.

To summarise, file uploads pose a serious threat to websites and apps and have serious consequences for organisations and users who don't know what's going on. Developers should do everything they can to stop uploads that aren't safe. To know further details on how we can support you, please reach us out

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
Cybersecurity Tabletop Exercises and Vendor Risk Management
Building an AI-Augmented SOC That Actually Works
How to Create a Secure AWS IAM Audit User for Cloud Security Assessments
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,031
Mastering Web App VAPT The Complete Guide
Mastering Web App VAPT The Complete Guide
Apr 26, 2024 · 9,393
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,411
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