Fix security issues and bugs across Rust and TypeScript - #21
Merged
Merged
Conversation
…erflow, frame size validation, stack overflow, JSON parse safety, CORS scope, and rate limiter atomicity. Generated with [Indent](https://indent.com) Co-Authored-By: Indent <noreply@indent.com>
Coverage
|
|
🔗 Preview: https://blit-n46d5v50d-indent.vercel.app |
Generated with [Indent](https://indent.com) Co-Authored-By: Indent <noreply@indent.com>
jsegaran
approved these changes
Apr 16, 2026
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
constant_time_eq: The early return on length mismatch leaked whether passphrase/token lengths matched. Fixed ininteractive.rs,gateway/lib.rs, andwebserver/config.rsby folding the length difference into the comparison byte and always comparingmin(len_a, len_b)bytes.interactive.rsincluded the plaintext passphrase, which was then forwarded to the browser client. Removed the passphrase from the error format string.width * height * 4was computed asu32arithmetic inserver/lib.rs, which overflows for large surfaces. Cast tousizebefore multiplication.webrtc.tsparsed frame length headers without an upper bound, allowing a malicious peer to cause unboundedreadBufgrowth. Added the same 16 MiB cap used inmux.tsandwebtransport.ts.btoa(String.fromCharCode(...array)): The spread operator hits the call stack limit for large payloads. Replaced with a loop-based approach inwebrtc-share.tsandpassphrase-crypto.ts.JSON.parseon WebSocket messages: TwoJSON.parsecalls inwebrtc-share.tssignaling handlers were not wrapped in try-catch, causing unhandled exceptions on malformed messages. Added error handling.*.vercel.apporigin (anyone can deploy to Vercel). Replaced withblit.sh/*.blit.sh.INCR+EXPIREindemo.tswere separate Redis calls. If the process crashed between them, the key would persist forever, permanently blocking that IP. Replaced with a Lua script for atomicity.Motivation
Security hardening and bug fixes identified via an audit of the Rust and TypeScript codebases.
Testing
These are targeted, low-risk fixes to existing code paths. Each fix addresses a specific, well-understood issue. The constant-time comparison, frame size validation, and JSON parse safety fixes are straightforward defensive changes. The CORS and rate limiter fixes affect the demo server only.
Tag
@indentto continue the conversation here.