[Browser][Security] Deploy strict CSP, Trusted Types, and wallet intent protection - #89
Merged
barry01-hash merged 1 commit intoJul 22, 2026
Conversation
0takuc0mrade
marked this pull request as ready for review
July 22, 2026 00:33
Contributor
|
Nice contribution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #74.
This establishes a strict browser security baseline for EduVault without adding runtime dependencies:
unsafe-evaland inline-script fallbacks, enables Trusted Types, and allowlists script, connection, frame, form, image, and media targetsWhy
EduVault renders creator-controlled metadata while wallet and session authorization are available in the same browser context. The previous static CSP allowed inline scripts and
unsafe-eval, allowed broad remote targets, and did not bind wallet prompts to independently verified transaction intent. An injected payload or modified XDR could therefore operate with too much browser trust.Impact
Next.js pages are rendered dynamically so each response can receive a unique nonce. Existing React style attributes remain supported, wallet popups remain compatible through
same-origin-allow-popups, and remote media is restricted to the configured IPFS/avatar gateways. Transactions without a complete matching intent now fail before invoking the wallet.Existing session cookies were already
HttpOnly,SameSite=Strict, path/lifetime scoped, secure in production, and refresh-token rotation was already present, so this PR documents that behavior instead of refactoring the auth routes.Validation
npm run buildnpm test -- --run— 118 tests passednode --test tests/browser/security.test.mjsusing production Next.js and headless Chromenpm run scan:secretsnpm run audit:depsat the repository's critical thresholdgit diff --checkExisting repository checks
The repository-wide lint command still encounters pre-existing parse errors in the backup scripts. The full raw Node backend runner also retains pre-existing module-resolution/dependency failures involving the
@/libalias and undeclareddotenv; all touched backend suites pass directly.