wxt-dev / wxt-dev/wxt

zip.includeSources does not behave intuitively, can lead to data leak

Open
#2,059 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

contribution welcome good first issue
Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Setup
// wxt.config.ts
export default defineConfig({
  zip: {
    includeSources: ['entrypoints/**'],
  },
})

Repo tree:

entrypoints/foo.ts
entrypoints/bar.js
cache/secrets/abc
super-secret-file
.gitignore
Expected behavior
$ wxt zip:firefox
$ zipinfo .output/*sources.zip
entrypoints/foo.ts
entrypoints/bar.js
Current non-intuitive, dangerously leaky behavior
$ wxt zip:firefox
$ zipinfo .output/*sources.zip
entrypoints/foo.ts
entrypoints/bar.js
cache/secrets/abc
super-secret-file
Hacky workaroud

I should not have to do this, but that's how I worked around this bug:

export default defineConfig({
  zip: {
    excludeSources: ['**'],
    includeSources: ['entrypoints/**'],
  },
})

I'll point out that this usually not how an allowlist/denylist behaves. The "accepted", safe, intuitive behavior is the following:

  • Nothing configured: default behavior, today "Hidden files, node_modules, and tests are ignored". I'd personally vote for a more advanced "respect .Xignore" support for a bunch of popular VCSes, like what ripgrep does, but that's a stretch.
  • Only allowlist provided (include): takes precedence since the user went through the trouble of customizing this setting; only what's "included" is included; not what happens, and what this bug is about.
  • Only denlist provided (exclude): takes precedence, everything is included except what's denied.
  • Both allowlist & denylist provided: only what passes the allowlist, then filter out further according to denylist. Though I accept that the opposite (first denylist, then force-allowlist), which is WXT's current behavior ("[includeSources] overrides excludeSources; if a file matches both lists, it is included in the ZIP") is acceptable albeit annoying.

Pointers:

Reproduction

repro.zip

Steps to reproduce
$ mkdir /tmp/repro && cd /tmp/repro
$ unzip /tmp/repro.zip
$ npm install
$ npm run zip:firefox
$ zipinfo .output/*sources.zip
System Info
System:
    OS: Linux 6.18 cpe:/o:nixos:nixos:26.05 26.05 (Yarara)
    CPU: irrelevant
    Memory: irrelevant
    Container: Yes
    Shell: 5.3.9 - /bin/bash
  Binaries:
    Node: 24.13.0 - node
    Yarn: 1.22.22 - yarn
    npm: 11.6.2 - npm
    pnpm: 10.28.0 - pnpm
  npmPackages:
    wxt: ^0.20.6 => 0.20.13
Used Package Manager

pnpm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by unpacking repro.zip and running npm run zip:firefox, then inspect the zip:firefox entry point and the includeSources handling referenced by wxt.config.ts. Reproduce the archive contents with zipinfo and trace how includeSources and excludeSources are combined. Done means an includeSources-only configuration produces a sources ZIP containing only matching entrypoints while preserving the documented default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, release
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.