# OHIF Viewers: DOM-Based Cross Site Scripting (XSS) through MIME type of document

Attacker-controlled MIMETypeOfEncapsulatedDocument DICOM tag becomes a blob: URL's Content-Type, so a text/html encapsulated document executes script in the OHIF origin.

- Payout: Research
- Severity: high
- Program: OHIF Viewers
- Found by: MBWlodarczyk
- Disclosed: 2026-11-10
- CVE: CVE-2026-118670
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-xwgp-w3pj-q5h3
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-xwgp-w3pj-q5h3
- Tags: area:oss domain:oss domain:web impact:ato impact:data-leak kind:research platform:ghsa sev:high tech:react technique:source-review vuln:xss

**Target:** DICOM PDF viewer extension (dicom-pdf) rendering encapsulated documents via blob: URLs
**Root cause:** The MIMETypeOfEncapsulatedDocument tag (0042,0012) is read without validation and passed as the Blob type when constructing blob: URLs; the browser honors the blob's stored Content-Type over the <object type="application/pdf"> hint, so text/html renders and executes in the OHIF origin.
**Steps:**
1. Craft an encapsulated PDF DICOM instance with SOP Class 1.2.840.10008.5.1.4.1.1.104.1, setting `MIMETypeOfEncapsulatedDocument` (0042,0012) to `text/html` and `EncapsulatedDocument` (0042,0011) to HTML containing `<script>`.
2. Deliver it to the victim: email a `.dcm` for local viewing, upload to a shared PACS, or serve via a DICOMweb source.
3. Victim opens the study; getSopClassHandlerModule.js:15,20 reads the MIME tag and sets `defaultType: MIMETypeOfEncapsulatedDocument`.
4. Retrieval path builds `URL.createObjectURL(new Blob([value[0]], { type: defaultType }))` (local), `utils.b64toBlob(value.InlineBinary, defaultType)` (InlineBinary), or `new Blob([arr], { type: defaultType })` (bulk data).
5. OHIFCornerstonePdfViewport.tsx:86-92 embeds the blob URL in `<object data={url} type="application/pdf">`; the blob's stored text/html Content-Type wins and the script executes in the OHIF origin.
**How found:** Code review of the taint path: the unvalidated MIMETypeOfEncapsulatedDocument tag flows as defaultType into Blob construction across all three retrieval paths, and the render sink relies on `<object type>` which does not override the blob's stored Content-Type.
**Exploitation:** Attacker supplies a malicious encapsulated-document DICOM object to a victim (email, shared PACS, or compromised DICOMweb source). When OHIF renders it, the attacker MIME type makes the blob render as HTML, executing script same-origin with OHIF — enabling theft of localStorage/sessionStorage auth tokens and same-origin requests to the PACS.
**Escalation:** Same-origin execution also compromises other applications hosted on the same DNS name.
**Insight:** When a viewer builds blob: URLs from attacker metadata, the Blob `type` is the real Content-Type — `<object type>`/`<embed type>` attributes are only hints. Grep for `new Blob(..., { type: <metadata> })` and b64toBlob calls fed by DICOM/upload metadata.

## Proof of concept (copied exactly from the original report)

**Local directURL creates Blob with attacker MIME type**

```
directURL: params => {
  const { instance, tag, defaultType } = params;
  const value = instance[tag];
  if (value instanceof Array && value[0] instanceof ArrayBuffer) {
    return URL.createObjectURL(new Blob([value[0]], { type: defaultType }));  // attacker MIME
```

**MIME tag read and passed as defaultType**

```
const { SeriesDescription = 'PDF', MIMETypeOfEncapsulatedDocument } = instance;
...
const renderedUrlParams = {
  instance,
  tag: 'EncapsulatedDocument',
  defaultType: MIMETypeOfEncapsulatedDocument || 'application/pdf',  // attacker-controlled
```

**object element renders blob URL with attacker MIME**

```
<object
  data={url}                 {/* blob: URL whose stored MIME = attacker's MIMETypeOfEncapsulatedDocument */}
  type="application/pdf"     {/* only a hint; overridden by the blob's own Content-Type */}
  className={style}
>
```

