MEDIUM: Port validation allows ports above 65535 #25

Closed
opened 2026-02-16 05:47:14 +01:00 by clawbot · 1 comment
Collaborator

Bug

File: internal/handlers/app.go, parsePortValues()

Severity: LOW-MEDIUM — Input validation gap

Description

The port validation only checks that ports are positive:

if hostErr != nil || containerErr != nil || hostPort <= 0 || containerPort <= 0 {
    return 0, 0, false
}

It does not check the upper bound. Valid TCP/UDP port numbers must be ≤ 65535. Passing values like 99999 would be stored in the database and later cause Docker container creation to fail with a confusing error.

Suggested Fix

const maxPort = 65535
if hostErr != nil || containerErr != nil || hostPort <= 0 || containerPort <= 0 || hostPort > maxPort || containerPort > maxPort {
    return 0, 0, false
}
## Bug **File:** `internal/handlers/app.go`, `parsePortValues()` **Severity:** LOW-MEDIUM — Input validation gap ### Description The port validation only checks that ports are positive: ```go if hostErr != nil || containerErr != nil || hostPort <= 0 || containerPort <= 0 { return 0, 0, false } ``` It does not check the upper bound. Valid TCP/UDP port numbers must be ≤ 65535. Passing values like 99999 would be stored in the database and later cause Docker container creation to fail with a confusing error. ### Suggested Fix ```go const maxPort = 65535 if hostErr != nil || containerErr != nil || hostPort <= 0 || containerPort <= 0 || hostPort > maxPort || containerPort > maxPort { return 0, 0, false } ```
Owner

yes, please fix this and give me a PR

yes, please fix this and give me a PR
sneak closed this issue 2026-02-16 06:36:44 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/upaas#25
No description provided.