# Hunt Xss File

> File-borne expert of the xss split: the payload ships INSIDE a file the

- Skill: `encod3d-sec/hunt-xss-file` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx get-skill add encod3d-sec/hunt-xss-file`
- Raw SKILL.md: https://api.skillmd.com/api/skills/encod3d-sec/hunt-xss-file/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Encod3d-Sec (https://skillmd.com/u/encod3d-sec)
- Updated: 2026-11-16
- Page: https://skillmd.com/skills/encod3d-sec/hunt-xss-file

---


# Hunt: XSS - file-borne expert (microskill)

File-borne expert of the xss split: the payload ships INSIDE a file the
target stores and later serves. The verdict turns on the SERVING origin
and response headers, not on the upload filter - a perfectly filtered
upload still executes when it is served same-origin as `image/svg+xml`.

## Wiki

Hub: [[wiki/techniques/web/xss]] - qmd on hint only: "file upload xss
svg onload cdata pdf polyglot content type x-content-type-options".

## Paths (binding - shared with the mapper run)

    RUN=$ENG_DIR/hunt/xss/<host>          # SHARED with hunt-xss
    Experts write probes/xss-file*.jsonl into the mapper's $RUN tree.

## Step 1 - Serving-origin inventory

For every upload/download/download-proxy surface:

```
surface + file classes accepted
where the file is served back (path, domain)     <- THE verdict driver
response headers on a stored benign file:
  Content-Type (exact), X-Content-Type-Options, CSP, Content-Disposition
inline vs forced-download (Content-Disposition/preview modal)
same-origin? sandbox domain? CDN? auth-gated?
```

Record @ $RUN/raw/file-surfaces.md rows `surface | served-at | content-type | nosniff | verdict-inputs`.

Verdict table:

```
served same-origin, no nosniff, sniffable type ..... escalate (Step 3)
sandbox domain (e.g. files.target.com) ............ dead end for
   XSS (isolated origin) - pivot to open-redirect
   onto main origin instead
Content-Disposition: attachment always forced ..... header-injection
   or preview-modal paths only
SVG/HTML accepted AND served inline ................ highest priority
```

## Step 2 - Upload-filter bypass set (only when Step 1 escalates)

- [ ] SVG: rename/extension games, `image/svg+xml` via double extension
      or content-type confusion.
- [ ] Filename/metadata reflection: the stored FILENAME and EXIF/metadata
      echoed into the gallery/listing page = classic reflected slot.
- [ ] Polyglots (SVG+HTML, GIF+JS-header trick, PDF polyglot).

## Step 3 - Payload families per class

SVG (the workhorse - full HTML+JS inside):

```html
<svg xmlns="http://www.w3.org/2000/svg" onload="alert(window.origin)">
<svg xmlns="http://www.w3.org/2000/svg">
  <a xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="javascript:alert(1)">
  <text x="10" y="10">click</text></a></svg>
<svg><script><![CDATA[alert(1)]]></script></svg>   (CDATA survives XML parsers)
```

- [ ] HTML-in-SVG: foreignObject wrapping arbitrary markup.
- [ ] PDF: server-side PDF generation (headless Chrome / wkhtmltopdf)
      renders attacker HTML -> server-side XSS/SSRF-from-renderer; probe
      `<iframe src=...>`, `<link>`, and JS-execution canaries in the
      generated PDF (renderers executing JS = RCE-adjacent).
- [ ] Polyglot: file valid AS two types; browser picks by served
      Content-Type - test both renderings.

## Step 4 - Validation + exit

- [ ] `alert(window.origin)` executed from a stored file (screenshot the
      origin readout into targets/<eng>/poc/).
- [ ] Rows appended to $RUN/candidates.jsonl (class=file); pointer
      `XSS-FILE-DONE surfaces=<n> inline=<n> fired=<n>` appended to
      $ENG_DIR/hunt-xss-<host>.md; Deadends per surface (row cites the
      exact serving header combo that held).

Blocked implies research: before any Deadend is claimable on a held
row, (a) walk the shared arsenal (`hunt-xss/references/waf-bypass.md`)
rows for that control class, and (b) run one wiki query AND one
`mcp__wigolo__search` for `<file type> inline script execution <serving
header combo>`. Results, or a genuine null, land in `coverage-depth.md`.
"No research tried" is not a claimable state.

### Depth walk (mandatory)

Walk EVERY applicable row: every file-carrier field (name, archive entry, metadata) against every render layer. Record each
row in `$RUN/coverage-depth.md` as a table `| row | state | evidence |`
where state is `probed`, `blocked`, or `N/A`, and evidence is a probe
path or a Deadends.md line. A bare `probed` with no evidence reference
fails the completion gate.

## Validation

Proof = the uploaded file served from a same-origin (or same-site) executable context executing script - a stored-but-neutered file (forced download, sandboxed origin, sanitized) is not a finding.

## False Positives

- File stored but served with `Content-Disposition: attachment` or from a sandboxed/untrusted origin.
- Polyglot that parses only in an editor, never in the serving context the target actually uses.

## Cross-routing

- - hunt-upload (parent ladder) for the filter-bypass set; hunt-xss (mapper) when the serving context turns it into XSS; hunt-rce when the upload path lands in a server parse sink (deserialization, image libs).

## Attack surface

**APPROACH:** Treat every parsed filename/metadata field (upload name, archive entry, EXIF, PDF title) as reflected input into HTML contexts; test the render layer the file feeds (gallery, preview, search index), not just the upload response.
**AVOID:** An escaped name in one view is not the verdict - any unescaped render path (sort, filter, export) reopens it.

## Stop conditions

Every upload/download surface has a serving-origin verdict + header
capture; every deadend names the blocking header; nothing written into
skill dirs.

