Skip to content

fix: path traversal, CORS, cache cap, __dirname, error pages, cookie order#1193

Open
yetval wants to merge 1 commit intoUseInterstellar:mainfrom
yetval:main
Open

fix: path traversal, CORS, cache cap, __dirname, error pages, cookie order#1193
yetval wants to merge 1 commit intoUseInterstellar:mainfrom
yetval:main

Conversation

@yetval
Copy link
Copy Markdown
Contributor

@yetval yetval commented Mar 29, 2026

Summary

Security fixes

  • Fix path traversal in Masqr.js via Host header — validate with allowlist regex, use path.basename() instead of incomplete normalize().replace()

Bug fixes

  • Fix __dirname using process.cwd() instead of import.meta.url (ESM module — wrong dir when launched from different cwd)
  • Fix mime.getType() returning null for unknown extensions (now falls back to application/octet-stream)
  • Fix MasqFail() calls not being awaited
  • Fix cookieParser registered after route handlers — moved before routes so Masqr can read cookies on /e/*
  • Fix 500 error handler incorrectly serving 404.html — now serves 500.html
  • Fix CORS for bare-server routes — headers now set on raw http.Server handler; Express middleware never ran on those routes

Reliability

  • Cap in-memory asset cache at CACHE_MAX_ENTRIES (default 1000, env-configurable) to prevent OOM under adversarial traffic
  • Add defensive headersSent guard in asset proxy error handler

Error pages

  • Add static/500.html
  • Replace Failed.html nginx placeholder with proper license-validation-failed page

Credentials

  • Remove hardcoded default password from config.js — credentials now read from BASIC_AUTH_USERS env var (user:pass CSV)
  • Usernames only logged at startup (passwords no longer printed)

Notes

  • Masqr remains opt-in via MASQR=true env var
  • COOKIE_SECRET env var required at startup when MASQR=true

@yetval yetval changed the title fixes index.js and Masqr.js security fixes: Masqr.js hardening, cache cap, credentials, error pages Apr 12, 2026
@yetval yetval changed the title security fixes: Masqr.js hardening, cache cap, credentials, error pages fix: keep only confirmed bug fixes Apr 16, 2026
@yetval yetval changed the title fix: keep only confirmed bug fixes fix: path traversal, CORS, cache cap, __dirname, error pages, cookie order Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant