match
The telnet suboption parser in libcurl checks the return value of sscanf incorrectly, so an environment value with only one field leaves the second buffer unchanged and creates uninitialised gaps in the output buffer. An attacker who controls the telnet options and can see the traffic could leak stack contents from the application.
Originally disclosed on HackerOne
- Disclosed after 39 days
Steps To Reproduce:
lib/telnet.c suboption function incorrecly checks for the sscanf return value. Instead of checking that 2 elements are parsed, the code also continues if just one element matches: if(sscanf(v->data, "%127[^,],%127s", varname, varval)) { As such it is possible to construct environment values that don't update the varval buffer and instead use the previous value. In combination of advancing in the temp buffer by strlen(v->data) + 1, this means that there will be uninitialized gaps in the generated output temp buffer. These gaps will contain whatever stack contents from previous operation of the application. Fortunately the environment is controlled by the client and not the server. As such this vulnerability can't be exploited by the server. Practical exploitation is limited by the following requirements: attacker is able to control the environment passed to libcurl via CURLOPT_TELNETOPTIONS ("NEW_ENV=xxx,yyy") and control xxx and yyy in the curl_slist entries) attacker is able to either inspect the network traffic of the telnet connection or to select the server/port the connection is established to When both are true the attacker is able to some content of the stack. Note however that for this leak to be meaningful, some confidential or sensitive information would need to be leaked. This could happen if some key or other sensitive material (that is otherwise out of the reach of the attacker, due to for example setuid + dropping of privileges, or for example only being able to execute the command remotely in a limited fashion, for example php curl, or similar) would thus become visible fully, or partially. The leak is limited to maximum about half of the 2048 byte temp buffer. Steps To Reproduce: Run telnet service tcpdump -i lo -X -s 65535 port 23 Execute
Impact
lib/telnet.c suboption function incorrecly checks for the sscanf return value. Instead of checking that 2 elements are parsed, the code also continues if just one element matches: if(sscanf(v->data, "%127[^,],%127s", varname, varval)) { As such it is possible to construct environment values that don't update the varval buffer and instead use the previous value. In combination of advancing in the temp buffer by strlen(v->data) + 1, this means that there will be uninitialized gaps in the generated output temp buffer. These gaps will contain whatever stack contents from previous operation of the application. Fortunately the environment is controlled by the client and not the server. As such this vulnerability can't be exploited by the server. Practical exploitation is limited by the following requirements: attacker is able to control the environment passed to libcurl via CURLOPT_TELNETOPTIONS ("NEW_ENV=xxx,yyy") and control xxx and yyy in the curl_slist entries) attacker is able to either inspect the network traffic of the telnet connection or to select the server/port the connection is established to When both are true the attacker is able to some content of the stack. Note however that for this leak to be meaningful, some confidential or sensitive information would need to be leaked. This could happen if some key or other sensitive material (that is otherwise out of the reach of the attacker, due to for example setuid + dropping of privileges, or for example only being able to execute the command remotely in a limited fashion, for example php curl, or similar) would thus become visible fully, or partially. The leak is limited to maximum about half of the 2048 byte temp buffer. Steps To Reproduce: Run telnet service tcpdump -i lo -X -s 65535 port 23 Execute
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code treats any non-zero sscanf return as success instead of requiring that both fields were parsed, so varval keeps its previous contents and the output buffer is advanced past uninitialised bytes.
Impact
An attacker who controls the telnet options and can inspect the traffic or choose the server could leak up to about half of the 2048-byte temporary buffer, which may expose sensitive material such as keys.
What the attacker needed
Control of telnet options; ability to inspect traffic or pick server
How it was found
- Run a telnet service.
- Capture traffic on the loopback interface for port 23.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A program reads a setting that should have two parts separated by a comma, but it accepts input with only one part. The second part is then left with whatever old data was in memory, and that old data gets sent out. Someone who controls the input and can watch the network could see pieces of memory that were not meant to be shared.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.