First of all, I reported this “issue” to Kirby, but the moderators (with outstanding good support) decided it was a real Kirby-threat, because it’s not 100% Kirby-only-related (and not an issue when you’re not explicitly doing the wrong things).
Issues with EXIF (meta) data in images are a big thing these days
- Woocommerce affected by auto-parsing EXIF-data.
- Android affected by “stagefright” (MMS) bug.
- OS X / iOS affected by “stagefright like” bug.
According to the first article (in the list above) Wordpress is vulnerable for EXIF-data, because that data can contain (javascript) code. So when you query information about a camera-model, the ISO or used white-balance, some embedded code (inside the same EXIF container) can also be parsed.
Normally the EXIF data looks something like this;
Camera : Lumia 950XL
Author : Bill Gates
ISO : 3200
Flash : no
Caption : Nice shot of fireworks by daylight
But everyone is free to add data like this;
Camera : Lumia 950XL
Author : Bill Gates
ISO : 3200
Flash : no
Caption : Nice shot of fireworks by daylight<script>var iframe = document.createElement('iframe');iframe.src = 'http://www.bild.de/';document.body.appendChild(iframe);</script>
You see what I did there? I extended the description tag with a nifty javascript (which injects an iFrame after the description itself).
###So what’s all the fuzz about?
Well, image this scenario;
- I create a nice image, let’s say a Kirby logo
- Inside the EXIF data I embed a nice caption;
Kirby is so cool! - But, wait! …I also inject the javascript…
On the “outersight” you will see nothing about the inject script (you can see it in the screenshot above).
The image just looks like… an image;
http://www.fotothing.com/photos/fb3/fb3e0755b710f2ae98d4d0c084aa49eb.jpg
But try to download the (original) image and see for your self;
http://www.fotothing.com/photos/fb3/fb3e0755b710f2ae98d4d0c084aa49eb.jpg
(I placed it on that site, because it doesn’t strip EXIF while uploading).
###On second sight
When you open this image inside an image-editor (that supports EXIF) or just a plain text reader you will notice some…
The meta-data does not only contains the “right” text Kirby is so Cool! but also the script after it.
Now let’s continue our scenario;
- You like the image and decides to place it on your site.
- You also want to show it’s title / caption, so you create a Kirby-query like this;
echo '<img src="' . $page->file($page->img())->url() . '"><br>';
$image = $page->file($page->img());
$exif = $image->exif();
echo $exif->data()['ImageDescription'];
The script above doesn’t do much;
- It writes down an image (with the
fieldnamewhich is calledimg(). - It queries it’s exif-data.
- It parses the
descriptionand writes it down.
###So what?
…well… here we are;
It parses the description and writes it down.
And we all know what the description is; a nifty javascript that injects an iFrame…
The screenshot above is a real-life implementation of both the (infected) image and the php script.
Querying the EXIF-data not only writes down the description of the image, but also the script. In this case the iFrame is visible and harmless, but of course one can make it invisible and harmful within the same line of code.
###Now what?
Well, one thing; as always be sure to check your images, the assets and don’t write out code without escaping any tags.
The right output of the meta-data should be something like;
<script>var iframe = document.createElement('iframe');iframe.src = 'http://www.bild.de/';document.body.appendChild(iframe);</script>
So, not a fully functional, executable script-tag.
Please mention, the Kirby moderators are aware of the issue, they supported my report withing 1 hour and this issue is not only Kirby related;
It’s just good practice to never trust user-input or third-party-input… check your assets!




