Fixed 512-byte stack buffer for SSH user@host can truncate silently #115

Closed
opened 2026-07-21 16:20:42 +02:00 by TapTap · 1 comment
Owner

Description

char ssh_user[512] in transport_ssh.c:121 is used with snprintf for user@host. The code checks needed >= sizeof(ssh_user) and prints a warning but continues execution with a truncated string. The execvp("ssh", ...) call will use the truncated user@host, potentially connecting to the wrong host or user, or failing mysteriously.

Location

src/shared/transport_ssh.c:121-128

How to trigger

Specify a very long username or hostname in the SSH destination (e.g., user@very.long.hostname.that.exceeds.512.bytes.example.com:/path). The local buffer truncates the string silently.

Suggested Fix

Use dynamically allocated buffer with asprintf() or malloc() + snprintf() instead of the fixed 512-byte stack buffer. Fail with an error message on truncation rather than continuing with truncated data.

Severity

medium

Category

security

Sub-Agent

security-screener (SC-4)


This issue was automatically generated by the issue-creator agent.

## Description `char ssh_user[512]` in `transport_ssh.c:121` is used with `snprintf` for `user@host`. The code checks `needed >= sizeof(ssh_user)` and prints a warning but continues execution with a truncated string. The `execvp("ssh", ...)` call will use the truncated user@host, potentially connecting to the wrong host or user, or failing mysteriously. ## Location src/shared/transport_ssh.c:121-128 ## How to trigger Specify a very long username or hostname in the SSH destination (e.g., `user@very.long.hostname.that.exceeds.512.bytes.example.com:/path`). The local buffer truncates the string silently. ## Suggested Fix Use dynamically allocated buffer with `asprintf()` or `malloc()` + `snprintf()` instead of the fixed 512-byte stack buffer. Fail with an error message on truncation rather than continuing with truncated data. ## Severity medium ## Category security ## Sub-Agent security-screener (SC-4) --- _This issue was automatically generated by the issue-creator agent._
Author
Owner

Fixed in PR #148 — merged into main on 2026-07-29. See #148

Fixed in PR #148 — merged into main on 2026-07-29. See https://gitea.tap-tap.win/TapTap/FastSync/pulls/148
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#115