Skip to content
RCE Disclosed report Intermediate

No SearchEngine sanatizing can lead to command injection

The custom search engine setting in Notepad++ was passed directly to ShellExecute without validation, so a value that is a command rather than a URL would be run as a command. An attacker who can set that field could execute arbitrary commands on the machine.

mrnbayoh Follow

Originally disclosed on HackerOne

Medium 5.0 View original
  • Triaged in 19 hours
  • Fixed in 21 days
  • Paid in 15 days
  • Disclosed after 4 months

##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:

  1. Go to Settings->Search Engine in the text box write cmd /K echo boom
  2. Click on Edit->On Selection->Search on Internet
  3. A command prompt is launched and echo boom is executed

Impact

Arbitrary commands execution.

The original report as published on HackerOne, by mrnbayoh. 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 custom search engine string was passed to ShellExecute as a command without validating that it was a URL.

Impact

Arbitrary commands could be executed, though the attacker must first be able to change the search engine setting.

What the attacker needed

Ability to change the search engine setting

How it was found

  1. Open the Search Engine settings under Settings.
  2. Enter a command instead of a URL in the custom text box.
  3. Select some text and choose Search on Internet from the Edit menu.
  4. A command prompt opens and the command runs.

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.

Notepad++ lets you choose which website it opens when you search for selected text. The program took whatever was typed in that setting and handed it to Windows to run, without checking it was a web address. Because Windows will happily run a command too, someone could put a command there and it would execute.

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 mrnbayoh

View all

6 more disclosed reports, best first.

More from Notepad++

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.