Repository navigation
Escape IAC bytes in telnet server output - #2175
Open
neeraj1235476 wants to merge 1 commit into
Open
neeraj1235476 wants to merge 1 commit into
neeraj1235476 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_ConnectionStdout.writeincontrib/telnet/server.pyencodes the output and sends the bytes as is, but RFC 854 requires a 0xFF data byte to be sent asIAC IAC. With a single-byte encoding (TelnetServer(encoding="latin-1"), cp1252, ...) a"ÿ"in printed text goes out as a bare IAC, so the client parses it and the following bytes as a telnet command. For example, a chat message containing"ÿü�"broadcast withsend_above_promptreaches other clients asIAC WONT ECHO. They switch to local echo, so a lateris_passwordprompt shows what they type.Double IAC in the encoded bytes inside
_ConnectionStdout.write, which everyVt100_Outputof a connection writes through, so callers printing untrusted text don't need to know about telnet framing. The negotiation commands in_initialize_telnetgo straight to the socket and are unaffected.tests/test_telnet.pycovers it (fails before, passes after).