Skip to content
Memory corruption Disclosed report Advanced

[Wii U/3DS/Switch] Improper bounds check in StationURL in all NEX clients leading to remote crash/RCE

The StationURL formatting routine writes parameters into a fixed-size stack buffer without accounting for how much has already been written, so a long key, value or many parameters overflow the buffer. Because StationURLs are relayed between clients via the server, a remote user could send an oversized value to another client and trigger the overflow, leading to a crash or possible code execution.

jonbarrow Follow

Originally disclosed on HackerOne

  • Triaged in 12 days
  • Disclosed after 2.1 years

Summary by the program

Summary by the researcher

nn::nex::StationURL::Format performs unsafe string formatting which lacks bounds checks. The StationURL is formatted to a string using code such as this:

C++
nn::nex::StationURL::Format() {
	wchar_t url[1024];
	uint offset = 0;
	uint written = 0;
	bool writeDelimiter = false;

	/* normalParams is a std::map<nn::nex::String, nn::nex::String> */
	for (auto param = normalParams.begin(); param != normalParams.end(); param++) {
		if (writeDelimiter) {
			written = swprintf(url + offset, 1024, L";");
			offset += written;
		}

		written = swprintf(url + offset, 1024, L"%ls%ls%ls", param->first, L"=", param->second);
		offset += written;
		writeDelimiter = true;
	}

	SetURL(url)
}

The calls to swprintf do not take into account the number of bytes already written into the url buffer, which can lead to a stack overflow given either a large enough number of parameters or a parameter with a large enough key/value. Since StationURLs are shared between clients, often using the server as a middleman, a remote user could send a large enough value through to another client, trigger this overflow

The original report as published on HackerOne, by jonbarrow. 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 formatting loop passes the full buffer size to each swprintf call instead of the remaining space, so cumulative writes exceed the 1024-element buffer.

Impact

A remote user could crash another client and potentially achieve code execution, though the text only states this as a possibility.

What the attacker needed

Ability to send StationURL data to a peer; victim client processes the crafted URL

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.

A program stores text in a fixed-size box on the stack, a small scratch area of memory. The formatting code keeps adding pieces of text to that box but never checks how full it already is, so a long enough piece spills over into neighbouring memory. Since these URL-like strings are passed between players through the game server, one player could send a crafted string that makes another player's console crash or possibly run attacker code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from Nintendo

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.