Caching messes up content filtering

Open
#137 16 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@jupenur is already working on this.

Since May 19, 2026.

Assessment

This issue has not been assessed yet.

Description

Firefox can cache resources in a way that makes their content invisible to filterResponseData. There is an attempt to address that problem here, but it's not working as intended: https://github.com/freedomofpress/webcat/blob/88fca91fd3cb3e417e8c68a142c665b6f343b60b/extension/src/webcat/response.ts#L270-L277

Some of the buggy behavior can be reproduced on https://integrity-error.demo.webcat.tech/corrupted-image/:

  1. Loading the URL normally will often* result in no integrity error. The image will be silently blocked from loading.
  2. Shift-reloading the page seems to always result in an integrity error -- as it should, since it bypasses caches.
  3. Directly typing https://integrity-error.demo.webcat.tech/corrupted-image/image.png to the URL bar similarly will mostly* result in no integrity error, but the image will not be displayed.
  4. Shift-reloading the image URL has a similar effect to shift-reloading the page.
  5. Disabling the extension and shift-reloading the page (or the image) allows the bad image to poison the cache. If you then re-enable WEBCAT and reload the page, the bad image will be rendered in-page.
  6. Most importantly, loading the image URL directly also renders the image, bypassing validation. If the image were an SVG, it could most likely execute scripts, but this has not been tested.

* The behavior is not consistent, it might take a few tries to repro.

It also seems like the code will not work correctly in the happy-path case of a valid image whose hash is in the manifest: because of caching, the filter may see a zero-length response and write a zero-length response, despite the cache contents being valid.

Dominant language
TypeScript
Stars
116
Forks
12
Avg merge
1d 5h
Merged PRs (30d)
10

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from freedomofpress/webcat

All issues in freedomofpress/webcat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.