Skip to content

Commit c6a8627

Browse files
authored
Merge pull request #148 from szTheory/hotfix/fix-xss-and-remote-shell
Fix XSS and Electron remote shell vulnerabilities by sanitizing HTML output
2 parents 18da3bd + 64753a7 commit c6a8627

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## 3.6.0 - 4 May 2021
4+
5+
### Security
6+
7+
- Fix for XSS and Electron reverse shell vulnerabilities by sanitizing `exiftool` HTML output in the UI. To take advantage of this, an attacker would have had to write image metadata containing malicious script code to a file that you then download and run through ExifCleaner. Proofs of concept:
8+
9+
XSS:
10+
11+
```bash
12+
exiftool -Comment='<img src=x onerror=alert("ok") /><b>OverJT</b>' -PixelUnits='meters' image.png
13+
```
14+
15+
Electron reverse shell:
16+
17+
```bash
18+
exiftool -Comment='<img src=x onerror=window.require("child_process").exec("/usr/bin/firefox") /><b>OverJT</b>' -PixelUnits='meters' image.png
19+
```
20+
321
## 3.5.1 - 1 May 2021
422

523
## Infrastructure

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
77
![ExifCleaner demo](https://user-images.githubusercontent.com/28652/71770980-f04e8b80-2f2b-11ea-90f1-4393ec57adc0.gif)
88

9-
## !!!!! NOTE - UPGRADE TO 3.5.0 OR GREATER ASAP !!!!!
9+
## !!!!! NOTE - UPGRADE TO 3.6.0+ ASAP !!!!!
1010

11-
If you are running 3.4.0 or earlier of ExifCleaner, update immediately! A security vulnerability was found in exiftool, the command-line application that powers ExifCleaner under the hood, and this was updated in ExifCleaner 3.5.0.
11+
If you are running a version of ExifCleaner before 3.6.0, upgrade immediately! A security vulnerability was found in exiftool, the command-line application that powers ExifCleaner under the hood, and this was updated in ExifCleaner 3.5.0. There was also an XSS and Electron remote shell vulnerability due to unsanitized HTML output that was fixed in ExifCleaner 3.6.0.
1212

1313
## Benefits
1414

src/renderer/sanitize.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Sanitize HTMl to prevent XSS and Electron remote shell attacks
2+
export function sanitizeHTML(text: string): string {
3+
const element = document.createElement("div");
4+
element.innerText = text;
5+
6+
return element.innerHTML;
7+
}

src/renderer/table_update_row.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { sanitizeHTML } from "./sanitize";
2+
13
export function updateRowWithExif(
24
tdNode: HTMLTableDataCellElement,
35
exifData: any
@@ -34,9 +36,14 @@ export function updateRowWithExif(
3436

3537
function buildExifString({ exifData }: { exifData: any }): string {
3638
let str = "";
39+
3740
for (const [key, value] of Object.entries(exifData)) {
38-
str += key + " " + "<strong>" + value + "</strong>" + "<br>";
41+
if (typeof value !== "string") {
42+
continue;
43+
}
44+
str += key + " " + "<strong>" + sanitizeHTML(value) + "</strong>" + "<br>";
3945
}
46+
4047
return str;
4148
}
4249

0 commit comments

Comments
 (0)