Skip to content

Fix security issues and bugs across Rust and TypeScript - #21

Merged
pcarrier merged 2 commits into
mainfrom
indent-2026-04-15-security-fixes
Apr 16, 2026
Merged

pcarrier merged 2 commits into
mainfrom
indent-2026-04-15-security-fixes

Conversation

@pcarrier

@pcarrier pcarrier commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Timing side-channel in constant_time_eq: The early return on length mismatch leaked whether passphrase/token lengths matched. Fixed in interactive.rs, gateway/lib.rs, and webserver/config.rs by folding the length difference into the comparison byte and always comparing min(len_a, len_b) bytes.
  • Passphrase leaked in error messages: WebRTC connection errors in interactive.rs included the plaintext passphrase, which was then forwarded to the browser client. Removed the passphrase from the error format string.
  • Integer overflow in PNG size calculation: width * height * 4 was computed as u32 arithmetic in server/lib.rs, which overflows for large surfaces. Cast to usize before multiplication.
  • Missing frame size check in WebRTC data channel transport: webrtc.ts parsed frame length headers without an upper bound, allowing a malicious peer to cause unbounded readBuf growth. Added the same 16 MiB cap used in mux.ts and webtransport.ts.
  • Stack overflow in btoa(String.fromCharCode(...array)): The spread operator hits the call stack limit for large payloads. Replaced with a loop-based approach in webrtc-share.ts and passphrase-crypto.ts.
  • Unchecked JSON.parse on WebSocket messages: Two JSON.parse calls in webrtc-share.ts signaling handlers were not wrapped in try-catch, causing unhandled exceptions on malformed messages. Added error handling.
  • Overly broad CORS allowlist: The demo server allowed any *.vercel.app origin (anyone can deploy to Vercel). Replaced with blit.sh / *.blit.sh.
  • Non-atomic rate limiter: The INCR + EXPIRE in demo.ts were 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.

Open in Indent
Tag @indent to continue the conversation here.

…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>
@pcarrier pcarrier added the indent label Apr 15, 2026 — with indent-zero
@github-actions

Copy link
Copy Markdown

Coverage

Crate Lines Functions Regions
alacritty-driver 59.7% (529/886) 62.5% (40/64) 59.8% (754/1261)
browser 0.0% (0/807) 0.0% (0/65) 0.0% (0/1370)
cli 34.2% (1072/3132) 44.3% (152/343) 36.0% (1929/5356)
compositor 1.2% (93/7956) 2.3% (8/347) 1.4% (146/10664)
fonts 76.8% (486/633) 85.5% (47/55) 77.9% (922/1183)
gateway 25.3% (355/1405) 27.6% (35/127) 18.8% (442/2353)
proxy 18.4% (150/815) 21.1% (24/114) 20.4% (260/1273)
remote 71.9% (1940/2699) 81.9% (186/227) 74.5% (3674/4929)
server 18.6% (1904/10232) 33.3% (215/645) 20.0% (3198/16014)
ssh 1.9% (7/374) 3.2% (1/31) 0.7% (4/613)
webrtc-forwarder 0.6% (15/2555) 0.5% (1/185) 0.8% (33/4300)
webserver 54.1% (442/817) 64.7% (75/116) 58.6% (839/1432)
Total 21.6% (6993/32311) 33.8% (784/2319) 24.0% (12201/50748)

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

🔗 Preview: https://blit-n46d5v50d-indent.vercel.app

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@pcarrier
pcarrier merged commit 45e8790 into main Apr 16, 2026
12 of 13 checks passed
@pcarrier
pcarrier deleted the indent-2026-04-15-security-fixes branch April 16, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants