Skip to content

NULL pointer dereference in handleFaupCommand via malformed input #302

Description

@zagers

Security Vulnerability: NULL Pointer Dereference (Medium)

Description

In handleFaupCommand, strtok(NULL, "\t") can return NULL when a client sends a field name without a corresponding value. The NULL pointer is then passed to atof(), which is undefined behavior and typically causes a segfault/crash.

Location

net_io.c:1138-1175

Vulnerable Code

msg_field = strtok(p, "\t");
while (msg_field != NULL) {
    if (!strcmp(msg_field, "upload_rate_multiplier")) {
        msg_field = strtok(NULL, "\t");
        multiplier = atof(msg_field);  // msg_field could be NULL!

Attack Vector

A client connected to the FAUP command port sends:

upload_rate_multiplier\t

(with a tab but no value). strtok returns NULL, atof(NULL) crashes.

Same issue exists for upload_unknown_commb at line 1166.

Impact

  • Denial of service via crash
  • Any connected client can trigger this

Suggested Fix

Check msg_field != NULL after each strtok(NULL, ...) call:

msg_field = strtok(NULL, "\t");
if (msg_field == NULL)
    break;
multiplier = atof(msg_field);

Metadata

Metadata

Assignees

No one assigned

    Labels

    LLMhas LLM-generated content, treat with extreme suspicion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions