LOW: Container log tail parameter not validated — passed directly to Docker API #24

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

Bug

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

Severity: LOW

Description

The tail query parameter is read from user input and passed directly to the Docker API without validation:

tail := request.URL.Query().Get("tail")
if tail == "" {
    tail = defaultLogTail
}
logs, logsErr := h.docker.ContainerLogs(request.Context(), containerInfo.ID, tail)

While Docker's API likely handles invalid values gracefully, the parameter should be validated as a positive integer to ensure predictable behavior and prevent potential edge cases (e.g., passing "all" to dump the entire log history, which could be a DoS vector for containers with large log files).

Suggested Fix

tail := request.URL.Query().Get("tail")
if tail == "" {
    tail = defaultLogTail
} else if _, err := strconv.Atoi(tail); err != nil {
    tail = defaultLogTail
}
## Bug **File:** `internal/handlers/app.go`, `HandleAppLogs()` **Severity:** LOW ### Description The `tail` query parameter is read from user input and passed directly to the Docker API without validation: ```go tail := request.URL.Query().Get("tail") if tail == "" { tail = defaultLogTail } logs, logsErr := h.docker.ContainerLogs(request.Context(), containerInfo.ID, tail) ``` While Docker's API likely handles invalid values gracefully, the parameter should be validated as a positive integer to ensure predictable behavior and prevent potential edge cases (e.g., passing `"all"` to dump the entire log history, which could be a DoS vector for containers with large log files). ### Suggested Fix ```go tail := request.URL.Query().Get("tail") if tail == "" { tail = defaultLogTail } else if _, err := strconv.Atoi(tail); err != nil { tail = defaultLogTail } ```
Owner

do it. also clamp it to max 500.

do it. also clamp it to max 500.
sneak closed this issue 2026-02-16 06:51:35 +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#24
No description provided.