Nothing stops the owner of the service to run arbitrary JavaScript in Users' browser.
Nothing stops the owner of the service to run arbitrary JavaScript in Users' browser.
- Include in a header comment: the build URL, Git SHA-1 of the commit, and other metadata
- Sign the bundle using public/secret key cryptography
Having the build URL and sources URL help with discoverability and transparency, while integrity can be verified with the signature.
Adversary models now shift from the bundle provider to the CI/CD platform that runs the build, and any PKI used for the public key for signature verification. If the public key is versioned with the code, it can help reduce trust to a single entity (where the code is stored).
[1] https://developer.mozilla.org/en-US/docs/Web/Security/Subres...
Alternatively, it would be possible to create a service worker that uses a local copy and makes much more of a deal about files changing - it could always confirm changes with the user before allowing a change. Security sensitive apps should probably be doing this.
Even native app packagers and languages can suffer from this when loading libraries dynamically (from search-path or symlink manipulation for example).