Notepad++ · Report #495382
No SearchEngine sanatizing can lead to command injection
Validstatus
mediumseverity
99upvotes
6 Jun 2019disclosed
How it was found
Information:
Summary: Notepad++ is vulnerable to a command injection vulnerability.
Debug Info: Notepad++ v7.6.3 (32-bit) Build time : Jan 27 2019 - 17:20:30 Path : C:\Program Files (x86)\Notepad++\notepad++.exe Admin mode : ON Local Conf mode : OFF OS : Windows 10 (64-bit) Plugins : none
Description:
When launching the web browser with the defined SearchEngine, the specified URL is directly passed as a command to ShellExecute. However since there is no check, one can put commands in that field instead of URLs.
Relevant piece of code in NppCommands.cpp:
case IDM_EDIT_SEARCHONINTERNET:
{
if (_pEditView->execute(SCI_GETSELECTIONS) != 1) // Multi-Selection || Column mode || no selection
return;
const NppGUI & nppGui = (NppParameters::getInstance())->getNppGUI();
generic_string url;
if (nppGui._searchEngineChoice == nppGui.se_custom)
{
if (nppGui._searchEngineCustom.empty())
{
url = TEXT("https://www.google.com/search?q=$(CURRENT_WORD)");
}
else
{
url = nppGui._searchEngineCustom.c_str();
}
}
else if (nppGui._searchEngineChoice == nppGui.se_duckDuckGo)
{
url = TEXT("https://duckduckgo.com/?q=$(CURRENT_WORD)");
}
else if (nppGui._searchEngineChoice == nppGui.se_google)
{
url = TEXT("https://www.google.com/search?q=$(CURRENT_WORD)");
}
else if (nppGui._searchEngineChoice == nppGui.se_bing)
{
url = TEXT("https://www.bing.com/search?q=$(CURRENT_WORD)");
}
else if (nppGui._searchEngineChoice == nppGui.se_yahoo)
{
url = TEXT("https://search.yahoo.com/search?q=$(CURRENT_WORD)");
}
Command cmd(url.c_str());
cmd.run(_pPublicInterface->getHSelf());
}
Steps To Reproduce:
- Go to
Settings->Search Enginein the text box writecmd /K echo boom - Click on
Edit->On Selection->Search on Internet - A command prompt is launched and
echo boomis executed
Impact
Arbitrary commands execution.