Skip to content
RCE Disclosed report Intermediate CVE-2023-27533

CVE-2023-27533: Telnet option IAC injection

The curl library failed to escape the IAC (0xff) byte in telnet option values, allowing an attacker who controls those values to inject arbitrary TELNET commands. This could let the attacker execute unintended commands on the telnet server, potentially leading to OS command execution.

nyymi Follow

Originally disclosed on HackerOne

  • Triaged in 6 days
  • Fixed in 17 days
  • Disclosed after 19 days

Summary:

CURLOPT_TELNETOPTIONS allows setting various telnet options for telnet protocol. Due to missing encoding of "Interpret as Command" IAC (0xff) character, the attacker who can control these option values can escape out of the telnet subnegotiation and enter arbitrary TELNET commands (*) via the CURLOPT_TELNETOPTIONS options. TTYPE, XDISPLOC and NEW_ENV options are affected.

*) TELNET command refers to "TELNET COMMAND STRUCTURE" in RFC 854

Steps To Reproduce:

  1. curl --telnet-option NEW_ENV=a,b$(echo -ne "\xff\xf0INJECTED") telnet://server

When inspected with tcpdump:

20:57:34.454720 IP x.x.x.x.53864 > y.y.y.y.telnet: Flags [P.], seq 17:37, ack 22, win 2058, options [nop,nop,TS val 1459077881 ecr 3403052525], length 20 [telnet SB NEW-ENVIRON IS 0 0x61 0x1 0x62 SE]
        0x0000:  4502 0048 0000 4000 4006 265a XXXX XXXX   E..H..@.@.&ZXXXX
        0x0010:  YYYY YYYY d268 0017 12a4 daa2 6603 9cb6  YYYY.h......f...
        0x0020:  8018 080a f840 0000 0101 080a 56f7 c2f9  [email protected]...
        0x0030:  cad6 75ed fffa 2700 0061 0162 fff0 494e  ..u...'..a.b..IN
        0x0040:  4a45 4354 4544 fff0                      JECTED..

Remediation

  • Double encode "Interpret as Command" (IAC) (0xff) if it is encountered when constructing the suboption data to be sent.

Supporting Material/References:

Impact

Attacker being able to specify TTYPE, XDISPLOC or NEW_ENV values is able to inject unintended TELNET commands to the telnet connection. Depending on the use case of the telnet protocol, this may allow the attacker to inject commands or other controlling operations. The practical impact is context specific, but in worst case this could for example allow executing arbitrary OS commands on target system.

The original report as published on HackerOne, by nyymi. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 telnet option handling in curl did not double-encode the IAC (0xff) byte when constructing subnegotiation data, allowing injection of TELNET commands.

Impact

An attacker who can control the telnet option values could inject arbitrary TELNET commands, potentially leading to OS command execution on the target system, depending on the context.

What the attacker needed

Attacker controls telnet option values; curl used with telnet protocol

The fix

The fix is to double-encode the IAC (0xff) byte when constructing suboption data.

How it was found

  1. Run curl with a telnet option that includes an unescaped IAC byte followed by a command.
  2. Observe the telnet traffic with tcpdump to see the injected command in the subnegotiation.

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.

Telnet is an old protocol for remote terminal access. It uses special bytes to send commands, and one byte (0xff) means 'the next byte is a command'. If a program lets you set option values without escaping that byte, you can sneak in extra commands. Here, curl did not escape it, so an attacker who controls the option values could inject commands into the telnet session.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by nyymi

View all

51 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.