GIFAR
   HOME

TheInfoList



OR:

Graphics Interchange Format Java Archives (GIFAR) is a term for
GIF The Graphics Interchange Format (GIF; or , see pronunciation) is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on 15 June 1987. ...
files combined with the
JAR A jar is a rigid, cylindrical or slightly conical container, typically made of glass, ceramic, or plastic, with a wide mouth or opening that can be closed with a lid, screw cap, lug cap, cork stopper, roll-on cap, crimp-on cap, press-on c ...
file format. GIFARs could be uploaded to Web sites that allow image uploading, and then run as though they were part of the legitimate code of that site. Java was patched in JRE 6 Update 11, with a CVE published on December 4 2008. In this attack, GIF Java archive files (GIFARs) were uploaded to Web sites on the understanding that they are GIFs, and the file was then interpreted as a JAR file when viewed and executed. This circumvented the
same-origin policy In computing, the same-origin policy (SOP) is an important concept in the web application security model. Under the policy, a web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages ...
that browsers impose; bypassing the content validation usually used. Attackers reference this malicious image in the applet code on the hosted site, establishing cross-domain communication with the (your) target domain. This technique worked because GIF images store their header in the beginning of the file, and JAR files (as with any ZIP archive-based format) store their data at the tail. This attack is not unique to GIFs and JARs; there is a general class of vulnerabilities of file type combinations such as .doc, .jpg, etc. A GIFAR allowed an attacker to access the victim's
HTTP cookies HTTP cookies (also called web cookies, Internet cookies, browser cookies, or simply cookies) are small blocks of data created by a web server while a user is browsing a website and placed on the user's computer or other device by the user's we ...
. This allows
session hijacking In computer science, session hijacking, sometimes also known as cookie hijacking, is the exploitation of a valid computer session—sometimes also called a ''session key''—to gain unauthorized access to information or services in a computer sys ...
, where the victim's logged-in user accounts can be accessed. GIFARs should not have been executed if the user is viewing the image; it had to be interpreted as a JAR not a GIF to run. For the attack to work, the victim must be logged into the Web site that is hosting the image. Any site that includes login sessions with user-uploaded pictures can be vulnerable.


Java archives (JARs)

JAR files are collections of compiled Java code, intended to be executed as standalone programs. They are
ZIP archive ZIP is an archive file format that supports lossless data compression. A ZIP file may contain one or more files or directories that may have been compressed. The ZIP file format permits a number of compression algorithms, though DEFLATE is th ...
s mostly containing Java class files. Developers can create or extract JAR files using the jar command that comes with a
JDK The Java Development Kit (JDK) is a distribution of Java Technology by Oracle Corporation. It implements the Java Language Specification (JLS) and the Java Virtual Machine Specification (JVMS) and provides the Standard Edition (SE) of the Java ...
. The zip file format allows for a metadata comment to occur at the end of the file after the central directory. In zips, because the central directory specifies the offset of each file with respect to the start, it is possible for the first file entry to start at an offset other than zero. This allows arbitrary data to occur in the file both before and after the zip archive data, and for the archive to still be read by the zip application. A side effect of this is that it is possible to author a file that is both a working zip archive and another format; provided that the other format tolerates arbitrary data at its beginning, middle, or end. Self-extracting archives (SFX) of the form supported by WinZip and DotNetZip, take advantage of this—they are .exe files that conform to the PKZIP AppNote.txt specification and can be read by compliant zip tools or libraries. This property of the zip format (including JARs) can be exploited to hide harmful Java classes inside a seemingly normal file, such as a GIF image uploaded to the Web. The so-called "GIFAR" exploit was demonstrated as an effective attack against Web applications such as Facebook. This made it possible to allow a "considered-safe" site to run Java. For example, a Webmaster could host this file on their site by saying that it is an applet—or an attacking party could upload a GIFAR to an image host; and the end-user's browser would run the applet because it is stated safe. Although it would not have mitigated this attack, developers can digitally sign JAR files. In this case, the signature becomes part of the (embedded) manifest file. The JAR is not signed, but every file inside the archive is listed, along with each file's signed checksum. Multiple entities may sign the JAR file (which changes the JAR file itself with each signing). When a Java runtime loads signed JAR files, it validates the signature(s) and avoids classes that do not match. If end-users only run JARs signed by trusted parties, malicious code cannot be inserted and run.


SUN & JRE

In GIFARs, the Java VM recognizes the JAR part which is run as an applet in the victim's browser as though it were written by the Web site's developers. Though Sun has patched the Java vulnerability (in advisory #244988 (as of versions JDK and JRE 6 Update 11 (December 2, 2008), JDK and JRE 5.0 Update 17, and SDK and JRE 1.4.2_19)., because some users run installed versions of Java pre-dating the JRE patch, this issue needs to be addressed as an issue of browser security. Sun's patch does not, however, stop applications from taking ownership of user-supplied content. From Sun; “...applets are not allowed to open network connections to any computer, except for the host that provided the .class files.” One is capable of uploading a GIFAR to a site as they will validate as images. You can include an embed pointing to that GIFAR in another page (hosted anywhere) and make people stumble onto it. It will be allowed to make any network connections it wants to that site in their name. With the applet running, the attacker can access the victim's account.


GIFs

The Graphics Interchange Format (GIF) is based on a
bitmap In computing, a bitmap is a mapping from some domain (for example, a range of integers) to bits. It is also called a bit array A bit array (also known as bitmask, bit map, bit set, bit string, or bit vector) is an array data structure that c ...
image format An Image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be c ...
that was introduced by
CompuServe CompuServe (CompuServe Information Service, also known by its initialism CIS) was an American online service provider, the first major commercial one in the world – described in 1994 as "the oldest of the Big Three information services (the oth ...
in 1987. GIF has declined on the
World Wide Web The World Wide Web (WWW), commonly known as the Web, is an information system enabling documents and other web resources to be accessed over the Internet. Documents and downloadable media are made available to the network through web se ...
but continues to have wide support. GIF images are compressed using the Lempel-Ziv-Welch (LZW)
lossless data compression Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information. Lossless compression is possible because most real-world data exhibits statistic ...
technique to reduce file size without degrading visual quality. GIF stores multiple images in one file. This technique is used extensively on the Web to produce simple
animations Animation is a method by which still figures are manipulated to appear as moving images. In traditional animation, images are drawn or painted by hand on transparent celluloid sheets to be photographed and exhibited on film. Today, most anima ...
. GIF was one of the first two image formats commonly used on Web sites.
CompuServe CompuServe (CompuServe Information Service, also known by its initialism CIS) was an American online service provider, the first major commercial one in the world – described in 1994 as "the oldest of the Big Three information services (the oth ...
's GIF appeared in 1987 to provide a color image format to replace the
run-length encoding Run-length encoding (RLE) is a form of lossless data compression in which ''runs'' of data (sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original ...
(RLE) format, which was black and white
XBM In computer graphics, the X Window System used X BitMap (XBM), a plain text binary image format, for storing cursor and icon bitmaps used in the X GUI. The XBM format is superseded by XPM, which first appeared for X11 in 1989. Format XBM fil ...
. GIF became popular because it could use
data compression In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compression ...
, which enabled large images to be downloaded in a short time.
JPEG JPEG ( ) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and imag ...
came later, with the
Mosaic browser NCSA Mosaic is a discontinued web browser, one of the first to be widely available. It was instrumental in popularizing the World Wide Web and the general Internet by integrating multimedia such as text and graphics. It was named for its support ...
.


Solutions

Some solutions to this issue may be: If you are the Web surfer, update to the latest version of JRE. Webmasters cannot ensure that their customers will be protected because they cannot control the JRE version that their users run. If you host images, run a backend script that verifies the absence of jar files appended to vulnerable file types (Reference http://securethoughts.com/2009/01/easy-server-side-fix-for-the-gifar-security-issue , A solution that could help an developer filter malicious jar content server side). If the application is able to restrict the upload of malicious files, it solves the problem without worrying about which version of JRE the client is running. This is ultimately a Web application issue. When a Web app chooses to take ownership of a user-controlled file, serving it from their domain, it weakens the integrity of the domain. The impact of these attacks could also be minimized if Web applications that took user-controlled files served those files from a “throw away” domain. As an application developer, you can also prevent these types of attacks by using a separate domain for user-influenced files.


References

{{Reflist, colwidth=30em, refs= {{cite web, url=https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT, title= .ZIP File Format Specification - Version 6.3.6, date=July 15, 2020, publisher=PKWARE Inc., archive-url=https://web.archive.org/web/20190515065009/https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT, archive-date=2019-05-15, url-status=unfit {{cite web , title=A photo that can steal your online credentials, url=http://www.infoworld.com/d/security-central/photo-can-steal-your-online-credentials-306, first=Robert, last=McMillan, date=August 1, 2008, publisher=Infoworld.com, archive-url= https://web.archive.org/web/20200918084425/https://www.infoworld.com/article/2653025/a-photo-that-can-steal-your-online-credentials.html, archive-date=2020-09-18


External links


LZW and GIF explained





JAR File Overview
Graphics file formats Archive formats Java platform Computer security