Skip to content

test(js): pin the Chrome shape of a blob URL and its synchronous store - #782

Merged
SGavrl merged 2 commits into
h4ckf0r0day:mainfrom
ntdatt812:fix/751-blob-object-url
Oct 27, 2026
Merged

SGavrl merged 2 commits into
h4ckf0r0day:mainfrom
ntdatt812:fix/751-blob-object-url

Conversation

@ntdatt812

@ntdatt812 ntdatt812 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What

This PR no longer changes behaviour. main already mints Chrome-shaped blob URLs — @963s landed that in #804 (c9e4c9f) while this was open, and the production half of what I had here is redundant. Rebased onto it and narrowed to the two tests that fix landed without.

Why

create_object_url_rejects_non_blob_input (SEC-503 / #820) covers the rejection half well, but the accepted half only asserts the scheme:

URL.createObjectURL(new Blob(['hello'])).startsWith('blob:')

The form #751 was filed about — blob:obscura/<base36> — satisfies that too, so the assertion cannot tell the fixed shape from the bug. The shape is the whole point of #751: a page that reads a blob URL back (a Worker's scriptURL, an anchor href, new URL(u).origin, a CSP report) saw the engine's name, and the base36 token failed every UUID parser.

Two paths in the merged fix also have no coverage: the source is stored synchronously so a Worker constructed from the URL in the same tick can read it — the async blob.text().then() store is what broke AWS WAF's proof-of-work worker — and revokeObjectURL has to remove the entry again.

Testing

Run in a Linux container on rustc 1.98, against main's implementation:

cargo nextest run -p obscura-js -E 'test(a_blob_url) + test(create_object_url_rejects_non_blob_input)'
    PASS obscura-js runtime::tests::a_blob_url_is_chrome_shaped
    PASS obscura-js runtime::tests::a_blob_url_is_stored_synchronously_and_revocation_removes_it
    PASS obscura-js runtime::tests::create_object_url_rejects_non_blob_input
3 tests run: 3 passed, 385 skipped

To show the new tests earn their place rather than restating a green build, I reintroduced the exact bug — const id = 'blob:obscura/' + Math.random().toString(36).slice(2); at the mint site — and re-ran the same three:

    FAIL obscura-js runtime::tests::a_blob_url_is_chrome_shaped
       left:  "origin": "blob:obscura/mgrloud2qak", "uuid": false, "names_the_engine": true
       right: "origin": "blob:http://example.com/", "uuid": true,  "names_the_engine": false
    PASS obscura-js runtime::tests::a_blob_url_is_stored_synchronously_and_revocation_removes_it
    PASS obscura-js runtime::tests::create_object_url_rejects_non_blob_input
3 tests run: 2 passed, 1 failed, 385 skipped

That is the gap: the existing test stays green while the URL names the engine again.

@ntdatt812
ntdatt812 force-pushed the fix/751-blob-object-url branch from 601194e to 979bbf0 Compare August 31, 2026 10:47
The existing coverage asserts only the scheme --
URL.createObjectURL(new Blob(['hello'])).startsWith('blob:') -- which the
'blob:obscura/<base36>' form h4ckf0r0day#751 was filed about also satisfies, so it
cannot tell the fixed shape from the bug it replaced.

Pin the shape itself: blob:<document origin>/<v4 UUID>, unique per call,
naming no engine, with File accepted as a Blob and Chrome's two
TypeErrors verbatim for missing and non-Blob input.

Cover the two paths the fix has and the tests do not: the source is in
the store by the time createObjectURL returns, so a Worker built from the
URL in the same tick can read it, and revokeObjectURL removes it again.
@ntdatt812
ntdatt812 force-pushed the fix/751-blob-object-url branch from 979bbf0 to f5b32ff Compare September 6, 2026 15:20
@ntdatt812 ntdatt812 changed the title fix(js): mint Chrome-shaped blob URLs and reject non-Blob input test(js): pin the Chrome shape of a blob URL and its synchronous store Sep 6, 2026
@963s

963s commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

right, the accepted half didn't pin the shape past the prefix — these two fill that cleanly.

@SGavrl
SGavrl merged commit 9bf18a9 into h4ckf0r0day:main Oct 27, 2026
3 checks passed
whyparv pushed a commit to whyparv/obscura that referenced this pull request Nov 17, 2026
…-url

test(js): pin the Chrome shape of a blob URL and its synchronous store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants