🔒 fix(vercel): clamp PORT environment variable in generated server.ts - #103
undivisible wants to merge 1 commit into
Conversation
Clamps the dynamically injected PORT environment variable in the Vercel adapter's generated server.ts entry point to ensure it falls within the valid port range of 0 to 65535, mitigating potential vulnerabilities when passing an unchecked environment variable directly to `Bun.serve`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_e8e50c99-a03e-499c-93df-658b48f5f05e) |
🎯 What: Clamps the
⚠️ Risk: Passing an unvalidated environment variable directly as a port number can lead to an unhandled rejection/exception if the environment variable evaluates to an out-of-bounds number or is manipulated, which could cause application startup to fail or present an avenue for tampering.
process.env.PORTvariable in the generatedserver.tsfile for the Vercel adapter to fall within the valid port range (0-65535).🛡️ Solution: Replaced
Number(process.env.PORT) || 0withMath.max(0, Math.min(65535, Number(process.env.PORT) || 0))when generating theBun.serveoptions to guarantee a valid port.PR created automatically by Jules for task 538728546974447352 started by @undivisible
Note
Low Risk
Small change to generated local server bootstrap only; no auth, data, or production routing logic affected.
Overview
The Vercel adapter’s generated
server.tsno longer passesprocess.env.PORTstraight intoBun.serve. It now clamps the parsed value to 0–65535 before starting the server, so invalid or out-of-rangePORTvalues fall back to a safe bound instead of risking startup failures from bad env input.Reviewed by Cursor Bugbot for commit 68b8aa7. Configure here.