From WikiChip
Editing mirc/msl injection

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 399: Line 399:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
= Injection via server command =
 
 
IRC servers accept strings containing $crlf $lf or $cr and will execute text following the line-ending as a 2nd server command using whatever permissions belong to your nick at that time.
 
<pre>
 
//msg #channel message $crlf mode #home +o Mallory
 
</pre>
 
When the server  receives this message from mIRC, it uses the $crlf to split this into 2 commands. The first command displays the message to #channel, and the 2nd command tells the server to give @op status in channel #home to Mallory. If you do not have permissions in #home to give @ops, or if a nick Mallory is not in that channel, nothing happens. But if both are true, then you have just given op status to Mallory.
 
 
This method can only tell the server to execute commands recognized by the server. It does not know any mIRC-only /commands or $identifiers, and the 2nd command is executed even if the 1st command is invalid, such as #channel not existing. This means echoing such a string is no danger, because /echo will not send any string to a server, and it will not execute them either.
 
 
This exploit cannot be achieved by responding to an ON TEXT command, because the server cannot display a message to a channel which contains an embedded $cr and/or $lf.
 
 
However, this exploit can take advantage of scripts which send text to channels which can contain them. Examples could include the above examples of an evaluated command inside a $decode string, or can be accomplished by a script which messages the title/description or other content from a webpage that the attacker controls. Another method can be 'now playing' scripts which message text to channel describing information about the mp3 song that is either beginning or ending. While it's common for fields like $sound(filename.mp3).comment to contain $cr's, they generally are not displayed in channel messages. However, it's also possible for Album or Title to also contain them.
 
 
In addition to executing commands to give @op privileges to someone, the malicious commands could include things like making you drop your nickserv account at some ircd's. Also, they can induce you to execute commands which have a future effect, such as adding a nick to a chanserv access list, or a command to add Mallory's certificate fingerprint to your nickserv account, which would allow them to take channel actions in the future, or to login your nickserv account any time in the future, even if you change your nickserv password. While those would almost certainly trigger a confirmation message from chanserv or nickserv, those messages often go into the status window, and would often be unseen, especially if they happened while your keyboard is unattended.
 
 
To defend against such an exploit, any command sent to the server (not only a channel message) containing text that could come from a source which contains line-ending characters should be sanitized to remove/disable them.
 
 
<pre>
 
$remove(string,$cr,$lf)
 
</pre>
 
This sanitizing would cause both strings to be combined as a single string, so if the first message is a plausible channel message, the hidden message is displayed as part of the channel message
 
 
However, this is not sufficient if the first server command is able to cause damage even if combined with additional text, such as when the first command is the give-them-@ops command. The better defense is to halt the server command if the string contains a $cr and/or $lf that shouldn't be there:
 
 
<pre>
 
if ($cr isin $replace(string,$lf,$cr)) { echo -a string exploit attempt: $2 | halt }
 
</pre>
 

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)