Skip to content

🔒 fix(vercel): clamp PORT environment variable in generated server.ts - #103

Open
undivisible wants to merge 1 commit into
mainfrom
security/clamp-port-538728546974447352
Open

undivisible wants to merge 1 commit into
mainfrom
security/clamp-port-538728546974447352

Conversation

@undivisible

@undivisible undivisible commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 What: Clamps the process.env.PORT variable in the generated server.ts file for the Vercel adapter to fall within the valid port range (0-65535).
⚠️ 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.
🛡️ Solution: Replaced Number(process.env.PORT) || 0 with Math.max(0, Math.min(65535, Number(process.env.PORT) || 0)) when generating the Bun.serve options 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.ts no longer passes process.env.PORT straight into Bun.serve. It now clamps the parsed value to 0–65535 before starting the server, so invalid or out-of-range PORT values fall back to a safe bound instead of risking startup failures from bad env input.

Reviewed by Cursor Bugbot for commit 68b8aa7. Configure here.

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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

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