fix: security hardening — file upload, JWT, CORS, headers#3975
Open
devrel-ditto wants to merge 1 commit intoava-labs:masterfrom
Open
fix: security hardening — file upload, JWT, CORS, headers#3975devrel-ditto wants to merge 1 commit intoava-labs:masterfrom
devrel-ditto wants to merge 1 commit intoava-labs:masterfrom
Conversation
…+ headers - Add MIME type allowlist to file upload endpoint (images, PDFs, videos only) - Remove full token payload from JWT validation response (return sub only) - Add security headers: HSTS, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy - Scope CORS on /api/* to build.avax.network origin with Vary: Origin Resolves ava-labs#3972, ava-labs#3974, ava-labs#3973, ava-labs#3967
|
@devrel-ditto is attempting to deploy a commit to the Ava Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Batch security fix addressing 4 issues. All changes are minimal and low-risk.
Changes
1. File upload MIME type validation (#3972)
Adds an allowlist of accepted file types to
POST /api/file:png,jpeg,gif,webp,svg+xmlpdfmp4,quicktimeRejects uploads with unrecognized MIME types to prevent storage of executable content (HTML, JS, etc.) on public blob storage.
2. JWT validation response trimming (#3974)
POST /api/validate-jwt-tokenno longer returns the full decoded tokenpayload. Response now contains onlyvalidandsubfields.3. CORS scoping on API routes (#3973)
Restricts
Access-Control-Allow-Originon/api/*routes tohttps://build.avax.network(was*). AddsVary: Originheader to prevent cache poisoning.4. Security headers (#3967)
Adds standard security headers for all routes:
Strict-Transport-Security: 2-year max-age with preloadX-Content-Type-Options: nosniffX-Frame-Options: DENYReferrer-Policy: strict-origin-when-cross-originPermissions-Policy: deny camera, microphone, geolocationTesting
.htmlfile to verify rejectionpayloadfield will need updating (check if any exist)Risk
Low. The CORS change is the most impactful — if external sites legitimately consume
/api/*, they will break. Worth auditing before merge.Resolves #3967, #3972, #3973, #3974
Supersedes #3968