# Fickle PDFs: exploiting browser rendering discrepancies

Hybrid PDF with a text field default value and a conflicting widget annotation renders different invoice totals across Safari, Chrome, Firefox and Drive preview.

- Payout: Research
- Severity: medium
- Program: PDF viewers
- Write-up by: PortSwigger Research
- Disclosed: 2024-07-09
- Write-up quality: 7/10
- Original: https://portswigger.net/research/fickle-pdfs-exploiting-browser-rendering-discrepancies
- Library page: https://bugbountylibrary.com/r/blog%3Aportswigger-net-research-fickle-pdfs-exploiting-browser-rendering-discrepancies
- Tags: area:os domain:desktop domain:web impact:integrity kind:research platform:research sev:medium tech:chromium tech:firefox technique:parser-differential vuln:business-logic

**Target:** PDF interactive form fields and widget annotations rendered by browser PDF engines (PDFium, PDF.js, Safari)
**Root cause:** PDF viewers disagree on precedence between a form field's default value (/V) and its widget annotation appearance stream; Safari/Preview show the default value while Firefox and Drive preview show the annotation, and Chrome updates to the default value upon interaction.
**Steps:**
1. Build a PDF with PDFBox: create PDAcroForm and a PDTextField with `field.setValue("£399")` (default value shown by Safari/Preview).
2. Set `PDAcroForm.getNeedAppearances()` true so PDFBox does not regenerate the appearance from the default value.
3. Create a PDFormXObject appearance stream and `appearanceContents.showText("£999")`, attach it as the widget annotation appearance.
4. Open the same file in Safari/Preview (shows £399), Chrome/Firefox/Drive preview (shows £999), and ChatGPT (reads £399).
5. Deliver the file to a victim whose viewer differs from the approver's viewer to induce a payment discrepancy.
**How found:** Inspired by Konstantin Weddige's 'Kobold Letters'; observed that browsers handle interactive form fields and widget annotations differently, then tested precedence of default value vs annotation appearance across PDFium, PDF.js and Safari.
**Exploitation:** Social-engineering flow: send an invoice PDF that displays a low total in the approver's viewer (Safari/Preview) but a higher total when opened downstream in Chrome/Drive by accounting, or vice versa; annotation can also overwrite the whole page.
**Insight:** When a format has redundant representations (form field value vs annotation appearance stream), test each renderer's precedence rules; discrepancies between the viewer used for approval and the viewer used for processing enable fraud.

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

**PDFBox code creating field value and widget appearance**

```
PDDocument document = new PDDocument();
PDAcroForm acroForm = new PDAcroForm(document);
PDTextField field = new PDTextField(acroForm);
field.setValue("£399");
// Create and set custom appearance stream
PDFormXObject appearanceStream = new PDFormXObject(document);
...
appearanceContents.showText("£999");
```

