SlideShare a Scribd company logo
Whitepaper




Exploiting PHP Upload Module of
FCKEditor


Bypassing File-type Check




Anant Kochhar
Utkarsh Bhatt
Sabyasachi Samanta
Exploiting PHP Upload Module of FCKEditor


TABLE OF CONTENTS


Abstract .............................................................. 4

Introduction......................................................... 4

Exploits ............................................................... 4

The Attack Scenario .............................................. 5

Vulnerable Versions ............................................ 15

Impact .............................................................. 15

Recommended Resolutions .................................. 15

About The Authors .............................................. 17

About SecurEyes ................................................ 17

Addendum* ....................................................... 17




                                                                         3
Exploiting PHP Upload Module of FCKEditor


Abstract
The PHP file upload module in FCKEditor allows developers to offer file upload
functionality to end users. This paper describes a vulnerability which allows attackers
to bypass file-type checks in this module and upload malicious PHP code into the web
servers.


Introduction
FCKEditor (now CKeditor) is an open source WYSIWYG text editor from CKSource
that can be integrated into web applications, to give end users word processor like
interface. FCK stands for ‘Frederico Caldeira Knabben’, the creator of the project, and
the first version was released in 2003.


This editor supports many server side languages like ASP, ASP.NET, PHP etc. The PHP
upload module, for PHP web applications, has a vulnerability which allows remote
attackers to bypass file-type checks. This vulnerability was discovered during the
course of our website audit work.


The vulnerability affects FCKEditor versions 2.6.4 and below.


Note: A different recently discovered vulnerability in the ASP.NET connector file allows
attackers to upload malicious ASP code into vulnerable servers.




Exploits
FCKEditor has built-in ‘filemanager’ package, which allows developers to offer a file
upload and management module to web site end users. For PHP web applications, one
of the relevant files is ‘upload.php’, which is available at the following location:
<site name><fckeditor>/editor/filemanager/connectors/php/upload.php
This file allows end users to upload files into the web server. It has a built in file-type
checker which does not allow PHP files to be uploaded, but a new vulnerability allows
remote attackers to bypass this vulnerability.




                                                                                          4
Exploiting PHP Upload Module of FCKEditor


The Attack Scenario
A website, http://www.vulnerable123.com, has integrated FCKEditor version 2.6.4.
For the sake of this proof-of-concept, it is assumed that the test page,
‘uploadtest.html’, packaged with FCKEditor, has not been removed. Also, assume
that there is no session-based access control check on any of the FCKEditor files,
including ‘upload.php’, allowing remote attackers to access them without
authentication.


An attacker browses to the File Upload test page at the URL:


http://www.vulnerable123.com/admin/FCKeditor_2.6.4/editor/filemanager/connectors
/uploadtest.html




He selects the ‘File Uploader’ as PHP, ‘Resource Type’ as File and selects a ‘.txt’ file.




                                                                                            5
Exploiting PHP Upload Module of FCKEditor




The file was successfully uploaded as shown below.




                                                     6
Exploiting PHP Upload Module of FCKEditor




The uploaded file location can be seen by browsing to the above encircled location.
http://www.vulnerable123.com/userfiles/test.txt




The raw HTTP traffic for this transaction, as intercepted in an HTTP proxy, has the
following structure:

                                                                                      7
Exploiting PHP Upload Module of FCKEditor




Next, the attacker tries to upload a PHP file.




                                                 8
Exploiting PHP Upload Module of FCKEditor

On clicking the ‘Send it to the Server’ button, the file doesn’t get uploaded and the
following ‘Invalid File’ message was displayed:




From the above screen, it is evident that ‘upload.php’ implements a file-type check
on all uploaded files. This check can be bypassed in the following way:


Step#1: The attacker enters malicious PHP code into a ‘.txt’ file, which is valid file-
type. Following is the malicious PHP content in the ‘exploit.txt’ file.




                                                                                          9
Exploiting PHP Upload Module of FCKEditor




Step#2: The attacker clicks on the ‘Send it to the Server’ button and captures the
request in an HTTP proxy:




                                                                                     10
Exploiting PHP Upload Module of FCKEditor




He appends the following string to the value of the URL parameter ‘Current Folder’.
command.php%00




                                                                                      11
Exploiting PHP Upload Module of FCKEditor

Note: In the above screenshot ‘%00’ in the string is the Null Byte.
The file was successfully updated as shown below:




The attacker browses to the uploaded file URL and confirms that the malicious file has
been uploaded: http://www.vulnerable123.com/userfiles/command.php




                                                                                    12
Exploiting PHP Upload Module of FCKEditor




He enters a system command as shown below and clicks on the ‘Search’ button.
dir C:xampphtdocsadmin




He is shown the following details:




                                                                               13
Exploiting PHP Upload Module of FCKEditor




   List of files and
   folders in the
   ‘admin’ directory



The above screenshot shows that the command displayed the directory listing of the
mentioned folder.
What’s going on?


   1) There is a proper validation for the file type in the ‘filename’ parameter.
   2) The ‘exploit.txt’ file is uploaded successfully because ‘.txt’ is an allowed file-
      type.
   3) The text file contains malicious PHP code, but since the server does not execute
      text files, it does not pose a security risk.
   4) Instead of the ‘exploit.txt’ file, however, ‘command.php’ file is created on the
      server.
   5) Moreover, the content of ‘command.php’ is the same as the content of
      ‘exploit.txt’ file.


   This happens because:
   1) The ‘currentfolder’ URL parameter value gives the name of a sub-folder, in the
      upload folder where the file will be uploaded.
   2) By inserting the ‘%00’ null byte character at the end of the sub-folder name, it
      is possible to create a new file instead of a new folder.



                                                                                           14
Exploiting PHP Upload Module of FCKEditor

   3) This happens because the path of the file to be created looks like the following:
       /root/mysite/userfiles/command.php%00/exploit.txt
   4) As the server ignores everything after the null byte, a new file is created called
       ‘command.php’ with the following location:
       /root/mysite/userfiles/command.php




Vulnerable Versions
This vulnerability affects FCKEditor versions 2.6.4 and below.


Impact
The impact of the above findings is SEVERE since attackers can upload malicious files,
like web shells and completely compromise affected web servers.


Recommended Resolutions
These are some of the measures that should be taken to remove this vulnerability
   1. Older versions of FCKEditor should be replaced with latest version of FCKEditor
       (CKEditor 3.6.6) to thwart the above vulnerabilities.
   2. For FCKEditor of version 2.6.4 and less, the ‘currentfolder’ parameter can be
       disabled with the following code changes in the upload.php file:
          ‘sCurrentFolder     =   GetCurrentFolder()’      should   be    replaced   with
          ‘sCurrentFolder = "/"’




                                                                                      15
Exploiting PHP Upload Module of FCKEditor




                     Vulnerable Code




                           Safe Code




                                            16
Exploiting PHP Upload Module of FCKEditor


About The Authors

Anant Kochhar, Utkarsh Bhatt and Sabyasachi Samanta are Information Security
Consultants and they have, between them, secured several web applications. They can
be   reached   at   anant.kochhar@secureyes.net,     utkarsh.bhatt@secureyes.net     and
sabyasachi.samanta@secureyes.net respectively.




About SecurEyes

SecurEyes is a Bangalore based firm specializing in IT security. SecurEyes offers a
wide range of security services and products to its clients. For more information,
please visit our website: http://www.secureyes.net/.




Addendum*

While we discovered this vulnerability independently and during the course of our
work, it has recently come to our attention that this vulnerability was already in the
public realm. This was an honest oversight on our part and we did not intend to take
the credit away from those who discovered and disclosed this vulnerability first. More
information is available at: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-
2009-2265




                                                                                         17

More Related Content

What's hot

Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
Niyas Nazar
 
SSRF For Bug Bounties
SSRF For Bug BountiesSSRF For Bug Bounties
SSRF For Bug Bounties
OWASP Nagpur
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Sam Bowne
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
Nezar Alazzabi
 
OWASP Top Ten 2017
OWASP Top Ten 2017OWASP Top Ten 2017
OWASP Top Ten 2017
Michael Furman
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesSoftware Guru
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
Rodolfo Assis (Brute)
 
OWASP Top 10 2021 What's New
OWASP Top 10 2021 What's NewOWASP Top 10 2021 What's New
OWASP Top 10 2021 What's New
Michael Furman
 
Web application security & Testing
Web application security  & TestingWeb application security  & Testing
Web application security & TestingDeepu S Nath
 
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsWeaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Harsh Bothra
 
Directory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksDirectory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion Attacks
Raghav Bisht
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
Jannis Kirschner
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
Amit Tyagi
 
OSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ InfosectrainOSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ Infosectrain
InfosecTrain
 
Command injection
Command injectionCommand injection
Command injection
penetration Tester
 
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security RisksOWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
Andre Van Klaveren
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
Mohammed Danish Amber
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
Scott Hurrey
 
Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
Sergey Belov
 
What is Penetration Testing?
What is Penetration Testing?What is Penetration Testing?
What is Penetration Testing?
btpsec
 

What's hot (20)

Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
SSRF For Bug Bounties
SSRF For Bug BountiesSSRF For Bug Bounties
SSRF For Bug Bounties
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
 
OWASP Top Ten 2017
OWASP Top Ten 2017OWASP Top Ten 2017
OWASP Top Ten 2017
 
OWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application VulnerabilitiesOWASP Top 10 Web Application Vulnerabilities
OWASP Top 10 Web Application Vulnerabilities
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
 
OWASP Top 10 2021 What's New
OWASP Top 10 2021 What's NewOWASP Top 10 2021 What's New
OWASP Top 10 2021 What's New
 
Web application security & Testing
Web application security  & TestingWeb application security  & Testing
Web application security & Testing
 
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & ProfitsWeaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
Weaponizing Recon - Smashing Applications for Security Vulnerabilities & Profits
 
Directory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksDirectory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion Attacks
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
 
Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)Cross Site Scripting ( XSS)
Cross Site Scripting ( XSS)
 
OSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ InfosectrainOSCP Preparation Guide @ Infosectrain
OSCP Preparation Guide @ Infosectrain
 
Command injection
Command injectionCommand injection
Command injection
 
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security RisksOWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
OWASP Top 10 2017 rc1 - The Ten Most Critical Web Application Security Risks
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
 
What is Penetration Testing?
What is Penetration Testing?What is Penetration Testing?
What is Penetration Testing?
 

Similar to File upload-vulnerability-in-fck editor

Php File Upload
Php File UploadPhp File Upload
Php File Uploadsaeel005
 
Setting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntuSetting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntu
kesavan N B
 
Prevent hacking
Prevent hackingPrevent hacking
Prevent hacking
Viswanath Polaki
 
Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson
Dev_Events
 
CodeIgniter Lab
CodeIgniter LabCodeIgniter Lab
CodeIgniter Lab
Leo Nguyen
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
HackIT Ukraine
 
Installing WordPress on AWS
Installing WordPress on AWSInstalling WordPress on AWS
Installing WordPress on AWS
Manish Jain
 
News web application
News web applicationNews web application
News web application
PrateekSingh467
 
Hawkeye the Credential Theft Maalware
Hawkeye   the Credential Theft MaalwareHawkeye   the Credential Theft Maalware
Hawkeye the Credential Theft Maalware
Vishal Kumar
 
Automation of web attacks from advisories to create real world exploits
Automation of web attacks from advisories to create real world exploitsAutomation of web attacks from advisories to create real world exploits
Automation of web attacks from advisories to create real world exploits
Munir Njiru
 
Online Bank Hack
Online Bank HackOnline Bank Hack
Online Bank HackCaleb Sima
 
Malicious file upload attacks - a case study
Malicious file upload attacks - a case studyMalicious file upload attacks - a case study
Malicious file upload attacks - a case study
Oktawian Powazka
 
Test automation with php codeception
Test automation with php codeceptionTest automation with php codeception
Test automation with php codeception
buddhieash
 
Web-servers & Application Hacking
Web-servers & Application HackingWeb-servers & Application Hacking
Web-servers & Application Hacking
Raghav Bisht
 
Installation of Joomla on Windows XP
Installation of Joomla on Windows XPInstallation of Joomla on Windows XP
Installation of Joomla on Windows XP
Rupesh Kumar
 
Create Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien PotencierCreate Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien Potencier
Himel Nag Rana
 

Similar to File upload-vulnerability-in-fck editor (20)

Php File Upload
Php File UploadPhp File Upload
Php File Upload
 
php secure
php securephp secure
php secure
 
Setting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntuSetting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntu
 
Lfi
LfiLfi
Lfi
 
Prevent hacking
Prevent hackingPrevent hacking
Prevent hacking
 
Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson Creating Sentiment Line Chart with Watson
Creating Sentiment Line Chart with Watson
 
CodeIgniter Lab
CodeIgniter LabCodeIgniter Lab
CodeIgniter Lab
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
 
Installing WordPress on AWS
Installing WordPress on AWSInstalling WordPress on AWS
Installing WordPress on AWS
 
News web application
News web applicationNews web application
News web application
 
Hawkeye the Credential Theft Maalware
Hawkeye   the Credential Theft MaalwareHawkeye   the Credential Theft Maalware
Hawkeye the Credential Theft Maalware
 
XSS
XSSXSS
XSS
 
XSS
XSSXSS
XSS
 
Automation of web attacks from advisories to create real world exploits
Automation of web attacks from advisories to create real world exploitsAutomation of web attacks from advisories to create real world exploits
Automation of web attacks from advisories to create real world exploits
 
Online Bank Hack
Online Bank HackOnline Bank Hack
Online Bank Hack
 
Malicious file upload attacks - a case study
Malicious file upload attacks - a case studyMalicious file upload attacks - a case study
Malicious file upload attacks - a case study
 
Test automation with php codeception
Test automation with php codeceptionTest automation with php codeception
Test automation with php codeception
 
Web-servers & Application Hacking
Web-servers & Application HackingWeb-servers & Application Hacking
Web-servers & Application Hacking
 
Installation of Joomla on Windows XP
Installation of Joomla on Windows XPInstallation of Joomla on Windows XP
Installation of Joomla on Windows XP
 
Create Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien PotencierCreate Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien Potencier
 

Recently uploaded

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 

Recently uploaded (20)

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 

File upload-vulnerability-in-fck editor

  • 1. Whitepaper Exploiting PHP Upload Module of FCKEditor Bypassing File-type Check Anant Kochhar Utkarsh Bhatt Sabyasachi Samanta
  • 2. Exploiting PHP Upload Module of FCKEditor TABLE OF CONTENTS Abstract .............................................................. 4 Introduction......................................................... 4 Exploits ............................................................... 4 The Attack Scenario .............................................. 5 Vulnerable Versions ............................................ 15 Impact .............................................................. 15 Recommended Resolutions .................................. 15 About The Authors .............................................. 17 About SecurEyes ................................................ 17 Addendum* ....................................................... 17 3
  • 3. Exploiting PHP Upload Module of FCKEditor Abstract The PHP file upload module in FCKEditor allows developers to offer file upload functionality to end users. This paper describes a vulnerability which allows attackers to bypass file-type checks in this module and upload malicious PHP code into the web servers. Introduction FCKEditor (now CKeditor) is an open source WYSIWYG text editor from CKSource that can be integrated into web applications, to give end users word processor like interface. FCK stands for ‘Frederico Caldeira Knabben’, the creator of the project, and the first version was released in 2003. This editor supports many server side languages like ASP, ASP.NET, PHP etc. The PHP upload module, for PHP web applications, has a vulnerability which allows remote attackers to bypass file-type checks. This vulnerability was discovered during the course of our website audit work. The vulnerability affects FCKEditor versions 2.6.4 and below. Note: A different recently discovered vulnerability in the ASP.NET connector file allows attackers to upload malicious ASP code into vulnerable servers. Exploits FCKEditor has built-in ‘filemanager’ package, which allows developers to offer a file upload and management module to web site end users. For PHP web applications, one of the relevant files is ‘upload.php’, which is available at the following location: <site name><fckeditor>/editor/filemanager/connectors/php/upload.php This file allows end users to upload files into the web server. It has a built in file-type checker which does not allow PHP files to be uploaded, but a new vulnerability allows remote attackers to bypass this vulnerability. 4
  • 4. Exploiting PHP Upload Module of FCKEditor The Attack Scenario A website, http://www.vulnerable123.com, has integrated FCKEditor version 2.6.4. For the sake of this proof-of-concept, it is assumed that the test page, ‘uploadtest.html’, packaged with FCKEditor, has not been removed. Also, assume that there is no session-based access control check on any of the FCKEditor files, including ‘upload.php’, allowing remote attackers to access them without authentication. An attacker browses to the File Upload test page at the URL: http://www.vulnerable123.com/admin/FCKeditor_2.6.4/editor/filemanager/connectors /uploadtest.html He selects the ‘File Uploader’ as PHP, ‘Resource Type’ as File and selects a ‘.txt’ file. 5
  • 5. Exploiting PHP Upload Module of FCKEditor The file was successfully uploaded as shown below. 6
  • 6. Exploiting PHP Upload Module of FCKEditor The uploaded file location can be seen by browsing to the above encircled location. http://www.vulnerable123.com/userfiles/test.txt The raw HTTP traffic for this transaction, as intercepted in an HTTP proxy, has the following structure: 7
  • 7. Exploiting PHP Upload Module of FCKEditor Next, the attacker tries to upload a PHP file. 8
  • 8. Exploiting PHP Upload Module of FCKEditor On clicking the ‘Send it to the Server’ button, the file doesn’t get uploaded and the following ‘Invalid File’ message was displayed: From the above screen, it is evident that ‘upload.php’ implements a file-type check on all uploaded files. This check can be bypassed in the following way: Step#1: The attacker enters malicious PHP code into a ‘.txt’ file, which is valid file- type. Following is the malicious PHP content in the ‘exploit.txt’ file. 9
  • 9. Exploiting PHP Upload Module of FCKEditor Step#2: The attacker clicks on the ‘Send it to the Server’ button and captures the request in an HTTP proxy: 10
  • 10. Exploiting PHP Upload Module of FCKEditor He appends the following string to the value of the URL parameter ‘Current Folder’. command.php%00 11
  • 11. Exploiting PHP Upload Module of FCKEditor Note: In the above screenshot ‘%00’ in the string is the Null Byte. The file was successfully updated as shown below: The attacker browses to the uploaded file URL and confirms that the malicious file has been uploaded: http://www.vulnerable123.com/userfiles/command.php 12
  • 12. Exploiting PHP Upload Module of FCKEditor He enters a system command as shown below and clicks on the ‘Search’ button. dir C:xampphtdocsadmin He is shown the following details: 13
  • 13. Exploiting PHP Upload Module of FCKEditor List of files and folders in the ‘admin’ directory The above screenshot shows that the command displayed the directory listing of the mentioned folder. What’s going on? 1) There is a proper validation for the file type in the ‘filename’ parameter. 2) The ‘exploit.txt’ file is uploaded successfully because ‘.txt’ is an allowed file- type. 3) The text file contains malicious PHP code, but since the server does not execute text files, it does not pose a security risk. 4) Instead of the ‘exploit.txt’ file, however, ‘command.php’ file is created on the server. 5) Moreover, the content of ‘command.php’ is the same as the content of ‘exploit.txt’ file. This happens because: 1) The ‘currentfolder’ URL parameter value gives the name of a sub-folder, in the upload folder where the file will be uploaded. 2) By inserting the ‘%00’ null byte character at the end of the sub-folder name, it is possible to create a new file instead of a new folder. 14
  • 14. Exploiting PHP Upload Module of FCKEditor 3) This happens because the path of the file to be created looks like the following: /root/mysite/userfiles/command.php%00/exploit.txt 4) As the server ignores everything after the null byte, a new file is created called ‘command.php’ with the following location: /root/mysite/userfiles/command.php Vulnerable Versions This vulnerability affects FCKEditor versions 2.6.4 and below. Impact The impact of the above findings is SEVERE since attackers can upload malicious files, like web shells and completely compromise affected web servers. Recommended Resolutions These are some of the measures that should be taken to remove this vulnerability 1. Older versions of FCKEditor should be replaced with latest version of FCKEditor (CKEditor 3.6.6) to thwart the above vulnerabilities. 2. For FCKEditor of version 2.6.4 and less, the ‘currentfolder’ parameter can be disabled with the following code changes in the upload.php file: ‘sCurrentFolder = GetCurrentFolder()’ should be replaced with ‘sCurrentFolder = "/"’ 15
  • 15. Exploiting PHP Upload Module of FCKEditor Vulnerable Code Safe Code 16
  • 16. Exploiting PHP Upload Module of FCKEditor About The Authors Anant Kochhar, Utkarsh Bhatt and Sabyasachi Samanta are Information Security Consultants and they have, between them, secured several web applications. They can be reached at anant.kochhar@secureyes.net, utkarsh.bhatt@secureyes.net and sabyasachi.samanta@secureyes.net respectively. About SecurEyes SecurEyes is a Bangalore based firm specializing in IT security. SecurEyes offers a wide range of security services and products to its clients. For more information, please visit our website: http://www.secureyes.net/. Addendum* While we discovered this vulnerability independently and during the course of our work, it has recently come to our attention that this vulnerability was already in the public realm. This was an honest oversight on our part and we did not intend to take the credit away from those who discovered and disclosed this vulnerability first. More information is available at: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE- 2009-2265 17