Skip to content

Conversation

@OxBat
Copy link

@OxBat OxBat commented Jan 27, 2026

Summary

I identified a critical robustness issue in TelnetAppender where logging a message shorter than 4 characters (e.g., "OK", "404") triggers an infinite loop, causing 100% CPU usage on the worker thread.

Technical Analysis

The vulnerability is caused by a logic mismatch between the memory allocation strategy in TelnetAppender and the safety requirements of the UTF8CharsetEncoder.

  1. Vulnerable Allocation (telnetappender.cpp):
    The buffer is allocated dynamically based strictly on message length:
    size_t bytesSize = msg.size() * 2;

For a 2-byte message ("Hi"), the allocated buffer is 4 bytes.

  1. Blocker Guard (charsetencoder.cpp): The UTF8CharsetEncoder enforces a safety check requiring at least 8 bytes of remaining space:
    if (out.remaining() >= 8) { ... }

If the buffer is smaller, it returns APR_SUCCESS without consuming input or advancing the iterator.

  1. The Infinite Loop: TelnetAppender receives a success code but detects the message hasn't been fully processed (msgIter != msg.end()). It retries the loop indefinitely with the same insufficient buffer, creating a deadlock.

Remediation
This patch modifies TelnetAppender::append to enforce a minimum buffer allocation (1024 bytes). This ensures the buffer always satisfies the encoder's requirements, preventing the infinite loop regardless of the input message length.

Threat Model Context
While this requires an untrusted log event, it results in a high-severity availability impact (Thread Hang).

Enforce a minimum buffer size allocation to satisfy UTF8CharsetEncoder requirements
and prevent infinite retry loops when logging short messages.
@rm5248
Copy link
Contributor

rm5248 commented Jan 27, 2026

Thanks for your contribution. Since you have opened several PRs, would you mind signing an ICLA if you have not done so already?

@OxBat
Copy link
Author

OxBat commented Jan 28, 2026 via email

@OxBat
Copy link
Author

OxBat commented Jan 29, 2026

@rm5248
Just a quick update. I received the confirmation from the ASF Secretary today. My ICLA is officially filed and recorde. ty

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.

2 participants