You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WASM: declared sha256 and fallback are never used — assets are trusted unverified #4025
sha256 appears exactly twice in index.ts -- both in doc comments:
71: * `{url, sha256, fallback}`. sha256 and fallback are parsed but NOT enforced
754: * @param {Object} manifest - path -> {url, sha256, fallback, size?}
So an asset fetched over the network is handed to the sketch unverified, while the correct digest sits in memory beside it. fbuild treats sha256 as mandatory precisely because its cache is content-addressed; the browser path takes the same declaration and ignores it.
fallback is in the same position: declared, parsed, never used on failure.
Why it matters more now
Assets now populate fl::getEmbeddedFs(), i.e. they are the filesystem the sketch reads. Corruption or a wrong-content URL is indistinguishable from correct data at runtime. SubtleCrypto.digest('SHA-256', ...) is available in any browser that can run this build, so the cost is a hash over bytes already in memory.
Fix
Verify sha256 after streaming an embedded asset; report a mismatch loudly.
Use fallback when the primary URL fails, which is the only reason it exists.
Research: hashing while streaming vs. after -- an 8.9MB asset is already fully buffered in FileData, so a second pass may be simpler than an incremental digest, but it doubles the peak walk.
Activity
docs(asset): stop documenting sha256/fallback as unenforced (#4149)