<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nedwill</id>
	<title>3dbrew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nedwill"/>
	<link rel="alternate" type="text/html" href="https://www.3dbrew.org/wiki/Special:Contributions/Nedwill"/>
	<updated>2026-04-16T03:09:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=3DS_Userland_Flaws&amp;diff=19255</id>
		<title>3DS Userland Flaws</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=3DS_Userland_Flaws&amp;diff=19255"/>
		<updated>2017-01-13T01:16:59Z</updated>

		<summary type="html">&lt;p&gt;Nedwill: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page lists vulnerabilities / exploits for 3DS applications and applets. Exploiting these initially results in ROP, from that ROP one can then for example try exploiting [[3DS_System_Flaws|system]] flaw(s).&lt;br /&gt;
&lt;br /&gt;
=Non-system applications=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Application name&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in app/system version&lt;br /&gt;
!  Last app/system version this flaw was checked for&lt;br /&gt;
!  Timeframe info related to this was added to wiki&lt;br /&gt;
!  Timeframe this vuln was discovered&lt;br /&gt;
!  Vuln discovered by&lt;br /&gt;
|-&lt;br /&gt;
| Cubic Ninja&lt;br /&gt;
| Map-data stack smash&lt;br /&gt;
| See [[Ninjhax|here]] regarding Ninjhax.&lt;br /&gt;
| None&lt;br /&gt;
| App: Initial version. System: [[10.4.0-29]].&lt;br /&gt;
| Ninjhax release&lt;br /&gt;
| July 2014&lt;br /&gt;
| [[User:smea|smea]]&lt;br /&gt;
|-&lt;br /&gt;
| The Legend of Zelda: Ocarina of Time 3D&lt;br /&gt;
| UTF-16 name string buffer overflow via unchecked u8 length field&lt;br /&gt;
| The u8 at offset 0x2C in the savefile is the character-length of the UTF-16 string at offset 0x1C. When copying this string, it&#039;s essentially a memory-copy with lenval*2, not a string-copy. This can be used to trigger buffer overflows at various locations depending on the string length.&lt;br /&gt;
* When value is &amp;gt;=0x6E it crashes when saving the saveslot, this causes a stack-smash however it normally crashes before it returns from the function which had the stack-frame overwritten.&lt;br /&gt;
* With value &amp;gt;=0x9A, it crashes via stack-smash in-game once any dialogs are opened(touching buttons on the touch-screen can trigger it too).&lt;br /&gt;
* Length value&amp;gt;=0xCD causes a crash while loading the saveslot, via a heap buffer overflow. This buf-overflow overwrites a heap memchunk following the allocated buffer. When the first 16-bits overwriting that heap memchunk is not the memchunk magic-number(0x7373), the mem-alloc code will just return a NULL ptr which later results in a crash. When the magic-number is valid, the mem-alloc code will continue to attempt to parse the memchunk, which may crash depending on the data which overwrote the memchunk. This heap code is separate from the CTRSDK heap code. Exploiting this doesn&#039;t seem to be possible: since the heap code actually verifies that the magic-number for the next/prev memchunk ptrs are correct(unlike CTRSDK), it&#039;s not possible to change those ptrs to useful arbitrary addresses outside of savedata(like with triggering a write to a c++ object ptr which later is used with a vtable func-call, this is what one would do with CTRSDK heap here).&lt;br /&gt;
&lt;br /&gt;
On March 11, 2015, an exploit using this vuln was released, that one was intended for warez/etc. The following exploit wasn&#039;t released before then mainly because doing so would (presumably) result in the vuln being fixed. The following old exploit was released on March 14, 2015: [https://github.com/yellows8/oot3dhax].&lt;br /&gt;
| None&lt;br /&gt;
| App: Initial version. System: [[10.6.0-31]].&lt;br /&gt;
| March 11, 2015&lt;br /&gt;
| Around October 22, 2012&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Super Smash Bros 3DS&lt;br /&gt;
| Buffer overflow in local-multiplayer beacon handling.&lt;br /&gt;
| See [[smashbroshax|here]].&lt;br /&gt;
| App: v1.1.3&lt;br /&gt;
| See [[smashbroshax|here]]. System: [[10.3.0-28]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| See [[smashbroshax|here]].&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Pokemon Super Mystery Dungeon&lt;br /&gt;
| Heap overflow within linear memory via unchecked save file length&lt;br /&gt;
| Pokemon Super Mystery Dungeon uses zlib compression for most of its save files, possibly due to the save files being larger than its predecessor, Gates to Infinity. When a save file is being prepared to be loaded and read from, only a 0x32000 large buffer is allocated for file reading, and a 0x3e800-large buffer for decompression is also allocated before the file is read. However, the game does not limit the size of the file read to this allocation bound, allowing for the file to overflow into the linear memory heap and into the next allocation. Since Pokemon Super Mystery Dungeon stores allocation memchunks directly before the allocation, overwriting the next memchunk with a corrupted one allows for arbitrary writes of linear heap pointers when the next buffer is allocated or arbitrary writes of any pointer within writable memory when the corrupted buffer is freed.&lt;br /&gt;
| None&lt;br /&gt;
| [[10.7.0-32]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| April 14, 2016&lt;br /&gt;
| [[User:Shinyquagsire23|Shiny Quagsire]]&lt;br /&gt;
|-&lt;br /&gt;
| VVVVVV&lt;br /&gt;
| Buffer overflow in XML save file array parsing&lt;br /&gt;
| VVVVVV utilizes several XML files (renamed with a .vvv extension) to store level save data, stats and settings. Within these XML files are several tags containing an array of data which, when parsed, is not properly checked to be of proper length for the tag being parsed from. This allows for an overflow of 16-bit array values from the location where the array is parsed. With unlock.vvv, XML data is parsed to the stack, and with level saves the heap. This allows for the pointer where the level save worldmap tag array should be parsed into to be overwritten with a stack address, allowing for ROP from within the XML array parsing function on the next level load.&lt;br /&gt;
| App: v1.1&lt;br /&gt;
| [[10.7.0-32]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| April 25, 2016&lt;br /&gt;
| [[User:Shinyquagsire23|Shiny Quagsire]]&lt;br /&gt;
|-&lt;br /&gt;
| Citizens of Earth&lt;br /&gt;
| Save file read stack smash&lt;br /&gt;
| Citizens of Earth also uses &amp;quot;XML&amp;quot; files for saves, which are actually entirely binary data (not XML at all) with no checksums. These files are read from the filesystem on to a fixed size stack buffer which leads to an incredibly trivial stack smash. When using the autosave slot for this, the save is parsed when the user selects &amp;quot;continue&amp;quot;. When using one of the dedicated save slots (1-3), the save is parsed shortly after the company splash screens fade. Note that the save is read quite high (descending) on the stack - when exploiting this, one would likely need to move SP due to almost instantly overflowing the physical stack.&lt;br /&gt;
| None&lt;br /&gt;
| [[10.7.0-32]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| May 5, 2016&lt;br /&gt;
| [[User:Dazzozo|Dazzozo]]&lt;br /&gt;
|-&lt;br /&gt;
| SmileBASIC 3.x&lt;br /&gt;
| Poor parameter validation on &amp;quot;BGSCREEN&amp;quot; command&lt;br /&gt;
| The SmileBASIC &amp;quot;BGSCREEN&amp;quot; command&#039;s second parameter is not properly validated as being within range.  As a result, one can set the screen size to an absurdly large value.  This means that the &amp;quot;BGGET&amp;quot; and &amp;quot;BGPUT&amp;quot; commands can then be used on out-of-range values to read and write a significant chunk of the interpreter&#039;s address space.&lt;br /&gt;
With a series of carefully-designed BGPUT commands, one can build a ROP chain and cause it to be executed.&lt;br /&gt;
| App: 3.3.2.&lt;br /&gt;
| System: [[11.0.0-33]].&lt;br /&gt;
| July 20, 2016&lt;br /&gt;
| Around June 26, 2016&lt;br /&gt;
| slackerSnail, 12Me12, incvoid&lt;br /&gt;
Exploited by MrNbaYoh and [[User:Plutooo|plutoo]].&lt;br /&gt;
|-&lt;br /&gt;
| The Legend of Zelda: Tri Force Heroes&lt;br /&gt;
| [[3DS_System_Flaws#General.2FCTRSDK|CTRSDK]] CTPK buffer overflow combined with game&#039;s usage of SpotPass&lt;br /&gt;
| During the very first screen displayed by the game during boot(&amp;quot;Loading...&amp;quot;), just seconds after title launch, the game loads CTPK from the [[BOSS_Services|stored]] SpotPass content. Hence, this game could be exploited via the vulnerable CTRSDK CTPK code &#039;&#039;if&#039;&#039; one could get custom SpotPass data into extdata somehow(ctr-httpwn &amp;gt;=v1.2 with bosshaxx allows this).&lt;br /&gt;
&lt;br /&gt;
The code for this runs from a thread separate from the main-thread, with the stack in linearmem heap. This SpotPass handling triggers before the game ever opens the regular savedata archive. The extdata is opened at some point before this: it opens a file for checking if it exists, then immediately closes it.&lt;br /&gt;
&lt;br /&gt;
The two SpotPass URLs for this have always(?) returned HTTP 404 as of November 2016. It appears these were intended for use as textures for additional costumes(and never got used publicly), but this wasn&#039;t tested.&lt;br /&gt;
&lt;br /&gt;
This is used by [https://github.com/yellows8/ctpkpwn ctpkpwn_tfh].&lt;br /&gt;
| None&lt;br /&gt;
| App: v2.1.0&lt;br /&gt;
| November 18, 2016&lt;br /&gt;
| November 14, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Pixel Paint&lt;br /&gt;
| Buffer overflow via unchecked extdata file length&lt;br /&gt;
| Pixel Paint loads pictures saved by the user from extdatas. The file is read to a fixed size buffer but the file length remains unchecked, so with a large enough file, one can overwrite pointers in memory and gain control of the execution flow.&lt;br /&gt;
| None&lt;br /&gt;
| App: Initial version. System: [[11.2.0-35]].&lt;br /&gt;
| December 27, 2016&lt;br /&gt;
| November 5, 2016&lt;br /&gt;
| [[User:Nba_Yoh|MrNbaYoh]]&lt;br /&gt;
|-&lt;br /&gt;
| Steel Diver : Sub Wars&lt;br /&gt;
| Heap overflow / arbitrary memcpy&lt;br /&gt;
| Savefile datas are stored as key/value pairs, a large enough string key makes the game overwrite a memcpy source/destination addresses and size arguments. So one can actually memcpy a rop on the stack and gain control of the execution flow.&lt;br /&gt;
| None&lt;br /&gt;
| System: [[11.2.0-35]].&lt;br /&gt;
| December 27, 2016&lt;br /&gt;
| Around July 15, 2016&lt;br /&gt;
| [[User:Nba_Yoh|MrNbaYoh]], Vegaroxas&lt;br /&gt;
|-&lt;br /&gt;
| 1001 Spikes&lt;br /&gt;
| Buffer overflow via unchecked array-indexes in XML savefile parsing&lt;br /&gt;
| The savefiles are stored as renamed .xml files, which contain several tags with attributes like &#039;array-index=&amp;quot;array-value&amp;quot;&#039;, where both of these are converted from ASCII strings to integers as signed-int32, and the array-value given blindly written to an array inside a structure using the (unchecked) index given. With several of these attributes, one can overwrite the stack starting from the stored lr of the function that does this parsing, and write a ROP chain there. Testing used the &amp;quot;LevelAttempts&amp;quot; tag which is the last such tag parsed in that function.&lt;br /&gt;
| None&lt;br /&gt;
| App: v1.2.0 (TMD v2096)&lt;br /&gt;
| December 27, 2016&lt;br /&gt;
| Around November 2, 2016&lt;br /&gt;
| [[User:Riley|Riley]]&lt;br /&gt;
|-&lt;br /&gt;
| Pokemon Omega Ruby/Alpha Sapphire&lt;br /&gt;
| Secret base team name heap overflow&lt;br /&gt;
| When the player wants to edit the team name, it is copied over the heap, however its length is not verified. So with a large enough team name one can overwrite some pointers and get two arbitrary jumps and then get control of the execution flow.&lt;br /&gt;
| None&lt;br /&gt;
| App: 1.4. System: [[11.2.0-35]].&lt;br /&gt;
| December 30, 2016&lt;br /&gt;
| June, 2016&lt;br /&gt;
| [[User:Nba_Yoh|MrNbaYoh]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Useless crashes / applications which were fuzzed==&lt;br /&gt;
* Pushmo (3DSWare), QR codes: level name is properly limited to 16 characters, game doesn&#039;t crash with a longer name. The only possible crashes are triggered by out-of-bounds array index values, these crashes are not exploitable due to the index value being 8bit.&lt;br /&gt;
&lt;br /&gt;
* [[Pyramids (3DSWare)]], QR codes: no strings. Only crashes are from out-of-bounds values (like background ID) and are not exploitable.&lt;br /&gt;
&lt;br /&gt;
* [[Pyramids 2 (3DSWare)]], QR codes: no strings. Only crashes are from out-of-bounds values (like background ID) and are not exploitable.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/yellows8/mm3d_re The Legend of Zelda: Majora&#039;s Mask 3D]&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;The Legend of Zelda: A Link Between Worlds&amp;quot; and &amp;quot;The Legend of Zelda: Tri Force Heroes&amp;quot;: these games don&#039;t crash at all when the entire save-file(minus constant header data) is overwritten with /dev/random output / 0xFF-bytes. All of the CRC32s were updated for this of course.  Note that this refers to the regular save file: Tri Force Heroes can be exploited via BOSS extdata - see above.&lt;br /&gt;
&lt;br /&gt;
* Pokemon Mystery Dungeon: Gates to Infinity has the same unchecked file bounds as Pokemon Super Mystery Dungeon, however since save compression was introduced in Pokemon Super Mystery Dungeon, it only allocates one buffer within the application heap instead of several within the linear heap, resulting in nothing to corrupt or overwrite even if the file&#039;s length is extended past its allocation.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Kid Icarus: Uprising&amp;quot;: Overwriting the entire savedata results in various crashes, nothing useful.&lt;br /&gt;
&lt;br /&gt;
* Savedata/extdata for &amp;quot;Super Smash Bros 3DS&amp;quot;: Overwriting the various files stored under savedata/extdata results in useless crashes.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;StarFox 64 3D&amp;quot;: Doesn&#039;t crash at all with the entire savedata overwritten.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Frogger 3D&amp;quot;: Overwriting a savefile with random-data results in *nothing* crashing.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Mutant Mudds&amp;quot;: Overwriting the savefile with random data results in a crash&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Animal Crossing: New Leaf&amp;quot;: Creating a QR code from random data results in a valid QR code and a random design. In some very rare cases(which aren&#039;t always reproducible?) a crash/etc may occur, but this isn&#039;t known to be useful.&lt;br /&gt;
&lt;br /&gt;
==Crashes needing investigation==&lt;br /&gt;
* Disney Infinity crashes when all savedata overwritten with /dev/urandom. No checksums. 0xFF bytes don&#039;t cause a crash.&lt;br /&gt;
&lt;br /&gt;
* Football Up Online / Soccer Up Online and Football Up 3D / Soccer Up 3D crash when teamname(UTF-16) length = 0x48 AND 0x20 null bytes are removed after just the name or if teamname length is way longer than 0x48.&lt;br /&gt;
&lt;br /&gt;
=System applications=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| 3DS [[System Settings]] DS profile string stack-smash&lt;br /&gt;
| Too long or corrupted strings (01Ah  2   Nickname length in characters     050h  2   Message length in characters) in the NVRAM DS user settings (System Settings-&amp;gt;Other Settings-&amp;gt;Profile-&amp;gt;Nintendo DS Profile) cause it to crash in 3DS-mode due to a stack-smash. The DSi is not vulnerable to this, DSi launcher(menu) and DSi System Settings will reset the NVRAM user-settings if the length field values are too long(same result as when the CRCs are invalid). TWL_FIRM also resets the NVRAM user-settings when the string-length(s) are too long.&lt;br /&gt;
| [[7.0.0-13]]&lt;br /&gt;
| [[7.0.0-13]]&lt;br /&gt;
| 2012&lt;br /&gt;
| [[User:Ichfly|Ichfly]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Nintendo 3DS Sound]]&lt;br /&gt;
| When a .m4a is loaded, the song name is copied to a 256 byte buffer. When the song name begins with a Unicode BOM marker, it memcpy&#039;s the tag using the user-provided length. This gives an arbitrary write which can be used to achieve ROP.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35]]&lt;br /&gt;
| June/July 2016&lt;br /&gt;
| [[User:nedwill|nedwill]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=System applets=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Introduced with version&lt;br /&gt;
!  Timeframe info related to this was added to wiki&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| Webkit/web-browser bugs&lt;br /&gt;
| spider has had at least three different code-execution exploits. Majority of them are use-after-free issues. See also [[browserhax|here]].&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &lt;br /&gt;
| 2013?&lt;br /&gt;
|&lt;br /&gt;
| A lot of people.&lt;br /&gt;
|-&lt;br /&gt;
| Old3DS/New3DS [[Internet_Browser|Browser-version-check]] bypass&lt;br /&gt;
| When the browser-version-check code runs where the savedata for it was never initialized(such as when the user used the &amp;quot;Initialize savedata&amp;quot; option), it will use base_timestamp=0 instead of the timestamp loaded from savedata. This is then used with &amp;quot;if(cur_timestamp - base_timestamp &amp;gt;= &amp;lt;24h timestamp&amp;gt;){Run browser-version-check HTTPS request code}&amp;quot;.&lt;br /&gt;
Hence, if the savedata was just initialized, and if the system datetime is set to before January 2, 2000, the browser-version-check will be skipped. This includes January 1, 2000, 00:00, because that&#039;s the epoch(timestamp value 0x0) used with this timestamp.&lt;br /&gt;
&lt;br /&gt;
See [http://yls8.mtheall.com/3dsbrowserhax.php here] for bypass usage instructions.&lt;br /&gt;
&lt;br /&gt;
This was fixed with [[10.7.0-32|10.7.0-32]], see [[Internet_Browser|here]] for details.&lt;br /&gt;
| [[10.7.0-32|10.7.0-32]]&lt;br /&gt;
| &lt;br /&gt;
| [[9.9.0-26|9.9.0-26]]&lt;br /&gt;
| February 25, 2016&lt;br /&gt;
| November 2, 2015 (Exactly one week after the browser version pages were initially updated server-side)&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Home Menu==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Introduced with version&lt;br /&gt;
!  Timeframe info related to this was added to wiki&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| bossbannerhax&lt;br /&gt;
| After successfully loading [[Extended_Banner|extended-banner]] data(done when selecting an icon), Home Menu attempts to load &amp;quot;[[CBMD]]&amp;quot; data into a 0x100000-byte heap buffer from the [[BOSS_Services|stored]] SpotPass content. When successful and the magic-number is CBMD, Home Menu then decompresses the exbanner sections into another fixed-size heap buffer, without checking the outsize at all. The main CBMD CGFX code with ExeFS checks the size, but this code doesn&#039;t(however this is exbanner &amp;quot;CBMD&amp;quot;, not a &amp;quot;normal&amp;quot; CBMD).&lt;br /&gt;
&lt;br /&gt;
Used with menuhax as of v3.2.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| [[1.0.0-0|1.0.0-0]]&lt;br /&gt;
| November 18, 2016&lt;br /&gt;
| December 23, 2014&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| sdiconhax&lt;br /&gt;
| This is basically the same as nandiconhax, the vulnerable SD/NAND functions are &#039;&#039;identical&#039;&#039; minus the file-buffer offsets. Exploitation is different due to different heap-buffer location though. Unlike nandiconhax, the icon buffer for SD is located in linearmem(with recent Home Menu versions at least). This is used by [[menuhax]].&lt;br /&gt;
| [[11.1.0-34|11.1.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| [[4.0.0-7|4.0.0-X]]&lt;br /&gt;
| July 27, 2016&lt;br /&gt;
| October 23, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[System_SaveData|NAND-savedata]] Launcher.dat icons (nandiconhax)&lt;br /&gt;
| The homemenu code processing the titleid list @ launcherdat+8 copies those titleIDs to another buffer, where the offset relative to that buffer is calculated using the corresponding s8/s16 entries. Those two values are not range checked at all. Hence, one can use this to write u64(s) with arbitrary values to before/after this allocated output buffer. See [[Home_Menu|here]] regarding Launcher.dat structure.&lt;br /&gt;
&lt;br /&gt;
This can be exploited(with Launcher.dat loading at startup at least) by using a s16 for the icon entry with value 0xFFEC(-20)(and perhaps more icons with similar s16 values to write multiple u64s). The result is that the u64 value is written to outbuf-0xA0, which overwrites object+0(vtable) and object+4(doesn&#039;t matter here) for an object that gets used a bit after the vulnerable function triggers. The low 32bits of the u64 can then be set to the address of controlled memory(either outbuf in regular heap or the entire launcherdat buffer in linearmem), for use as a fake vtable in order to get control of PC. From there one can begin ROP via vtable funcptrs to do a stack-pivot(r4=objectaddr at the time the above object gets used).&lt;br /&gt;
&lt;br /&gt;
Originally this vuln could only be triggered via Launcher.dat at Home Menu startup, right after Launcher.dat gets loaded + memory gets allocated, once the file-format version code is finished running. Starting with v9.6 this can be triggered when loading layouts from SD extdata as well. The vuln itself triggers before the layout data is written to Launcher.dat, but it doesn&#039;t seem to be possible to overwrite anything which actually gets used before the function which writes Launcher.dat into the layout gets called.&lt;br /&gt;
&lt;br /&gt;
Home Menu has some sort of fail-safe system(or at least on v9.7) when Home Menu crashes due to Launcher.dat(this also applies for other things with Home Menu): after crashing once, Home Menu resets Launcher.dat to a state where it no longer crashes anymore. However, note that any exploits using this which hang/etc without crashing will still brick the system. &#039;&#039;&#039;Hence, attempting anything with this on physnand without hw-nand-access isn&#039;t really recommended.&#039;&#039;&#039;&lt;br /&gt;
| [[11.1.0-34|11.1.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| [[4.0.0-7|4.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| May 14, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Theme-data decompression buffer overflow ([[menuhax|themehax]])&lt;br /&gt;
| The only func-call size parameter used by the theme decompression function is one for the compressed size, none for the decompressed size. The decompressed-size value from the LZ header is used by this function to check when to stop decompressing, but this function itself has nothing to verify the decompressed_size with. The code calling this function does not check or even use the decompressed size from the header either.&lt;br /&gt;
&lt;br /&gt;
This function is separate from the rest of the Home Menu code: the function used for decompressing themes is *only* used for decompressing themes, nothing else. There&#039;s a separate decompression function in Home Menu used for decompressing everything else.&lt;br /&gt;
&lt;br /&gt;
That other decompression function in Home Menu handles decompression size properly(decompressed size check for max buffer size is done by code calling the other function, not in the function itself). Unlike the other function, the theme function supports multiple LZ algorithms, but the one which actually gets used in official themes is the same one supported by the other function anyway.&lt;br /&gt;
&lt;br /&gt;
See also [[menuhax|here]].&lt;br /&gt;
&lt;br /&gt;
With [[10.2.0-28|10.2.0-X]] Home Menu, the only code change was that the following was added right after theme-load and before actual decompression: &amp;quot;if(&amp;lt;get_lzheader_decompressed_size&amp;gt;(compressed_buf) &amp;gt; 0x150000)&amp;lt;exit&amp;gt;;&amp;quot;. This fixed the vuln.&lt;br /&gt;
| [[10.2.0-28|10.2.0-X]]&lt;br /&gt;
| [[10.2.0-28|10.2.0-X]]&lt;br /&gt;
| &amp;lt;Old3DS/New3DS version which added initial theme support&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| December 22, 2014&lt;br /&gt;
| [[User:Yellows8|Yellows8]], [[User:Myria|Myria]] independently (~spring 2015)&lt;br /&gt;
|-&lt;br /&gt;
| Shuffle body-data buffer overflow ([[menuhax|shufflehax]])&lt;br /&gt;
| See [[menuhax|here]].&lt;br /&gt;
| [[10.6.0-31|10.6.0-X]]&lt;br /&gt;
| [[10.6.0-31|10.6.0-X]]&lt;br /&gt;
| [[9.3.0-21|9.3.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| January 3, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Extdata file-data loading buffer overflow&lt;br /&gt;
| The extdata file-reading code allocates a fixed-size heap buffer for the expected filesize, then reads the filedata into this buffer using the actual FS filesize. Before v5.0 the filesize used here wasn&#039;t validated, hence if the filesize is larger than alloc_size a buffer overflow would occur. &#039;&#039;After&#039;&#039; doing the file-read it does validate that the actual_readsize matches the alloc_size, but at this point the buffer overflow has already occurred.&lt;br /&gt;
&lt;br /&gt;
This affected at least the following: SaveData.dat and Cache.dat.&lt;br /&gt;
&lt;br /&gt;
This can be triggered with SaveData.dat by installing a &amp;lt;v4.0 Home Menu version, with Home Menu extdata from &amp;gt;=v4.0 still on SD. When this is done with v2.0 Home Menu, a kernelpanic occurs when processing an AM command(it appears a buffer ptr which is then passed to a command was overwritten with 0x0 - of course other SaveData.dat filesizes may result in different behaviour).&lt;br /&gt;
| [[5.0.0-11|5.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| [[2.0.0-2|2.0.0-X]]&lt;br /&gt;
| June 9, 2016&lt;br /&gt;
| June 9, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The icon data arrays used with {sd/nand}iconhax were added to SaveData.dat/Launcher.dat with [[4.0.0-7|4.0.0-X]], hence the vulnerable functions were added with that same version.&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;=v4.0 the SaveData.dat buffer is located in the regular heap. It&#039;s unknown when exactly it was moved to linearmem, which is where it&#039;s located with recent versions. It&#039;s located in linearmem for KOR &amp;gt;=v9.6 for example.&lt;br /&gt;
&lt;br /&gt;
The SaveData.dat/Launcher.dat icon vulns were fixed by doing various unsigned &amp;gt;=60/&amp;gt;=360 checks on the loaded values. When these checks fail, it just skips over handling this icon entry. Hence, the original value can&#039;t be negative / out-of-bounds any more.&lt;br /&gt;
&lt;br /&gt;
==Useless crashes==&lt;br /&gt;
Old3DS system web-browser:&lt;br /&gt;
* 2^32 characters long string(&#039;&#039;finally&#039;&#039; fixed with v10.6): this is similar to the vulnerability fixed [http://git.chromium.org/gitweb/?p=external/Webkit.git;a=commitdiff;h=ec471f16fbd1f879cb631f9b022fd16acd75f4d4 here], concat-large-strings-crash2.html triggers a crash which is about the same as the one triggered by a 2^32 string. Most of the time this vulnerability will cause a memory page permissions fault, since the WebKit code attempts to copy the string text data to the output buffer located in read-only [[CRO0|CRO]] heap memory. The only difference between a crash triggered by a 2^32 string and the concat-large-strings-crash2.html crash is at the former copies the string data using the original string length(like 1 text character for &amp;quot;x&amp;quot;, 4 for &amp;quot;xxxx&amp;quot;) while the latter attempts to copy &amp;gt;12MB. In some &#039;&#039;very&#039;&#039; rare cases a thread separate from the string data-copy thread will crash, this might be exploitable. However, this is mostly useless since it rarely crashes this way.&lt;br /&gt;
&lt;br /&gt;
* Trying to directly load a page via the browser &amp;quot;URL&amp;quot; option with [https://github.com/yellows8/3ds_browserhax_common webkitdebug] setup, causes a crash to trigger in oss.cro due to an use-after-free being caught with webkitdebug. This is presumably some sort of realloc() issue in the libcurl version used by the &amp;lt;={v10.2-v10.3} browser. This happens with *every* *single* *page* one tries to load via the &amp;quot;URL&amp;quot; option, but not when loading links on the current page, hence this is probably useless. A different use-after-free with realloc triggers with loading any page at all regardless of method too(libcurl probably).&lt;br /&gt;
&lt;br /&gt;
* This WebKit build has &#039;&#039;a lot&#039;&#039; of crash-trigger bugs that only happen with [https://github.com/yellows8/3ds_browserhax_common webkitdebug] completely setup(addr accesses near 0x0), with &#039;&#039;just&#039;&#039; trying to load any page at all.&lt;/div&gt;</summary>
		<author><name>Nedwill</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&amp;diff=19254</id>
		<title>3DS System Flaws</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&amp;diff=19254"/>
		<updated>2017-01-13T01:15:04Z</updated>

		<summary type="html">&lt;p&gt;Nedwill: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Exploits are used to execute unofficial code (homebrew) on the Nintendo 3DS. This page is a list of publicly known system flaws, for userland applications/applets flaws see [[3DS_Userland_Flaws|here]].&lt;br /&gt;
&lt;br /&gt;
=Stale / Rejected Efforts=&lt;br /&gt;
* Neimod has been working on a RAM dumping setup for a little while now. He&#039;s de-soldered the 3DS&#039;s RAM chip and hooked it and the RAM pinouts on the 3DS&#039; PCB up to a custom RAM dumping setup. A while ago he published photos showing his setup to be working quite well, with the 3DS successfully booting up. However, his flickr stream is now private along with most of his work.&lt;br /&gt;
&lt;br /&gt;
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.&lt;br /&gt;
&lt;br /&gt;
==Tips and info==&lt;br /&gt;
The 3DS uses the XN feature of the ARM11 processor. There&#039;s no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there&#039;s a [[SVC]] for this, but only [[RO_Services|RO-module]] has access to it). A usable userland exploit would still be useful: you could only do return-oriented-programming with it initially. From ROP one could then exploit system flaw(s), see below.&lt;br /&gt;
&lt;br /&gt;
SD card [[extdata]] and SD savegames can be attacked, for consoles where the console-unique [[Nand/private/movable.sed|movable.sed]] was dumped(accessing SD data is far easier by running code on the target 3DS however).&lt;br /&gt;
&lt;br /&gt;
=System flaws=&lt;br /&gt;
== Hardware ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed with hardware model/revision&lt;br /&gt;
!  Newest hardware model/revision this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| ARM9/ARM11 bootrom vectors point at uninitialized RAM&lt;br /&gt;
| ARM9&#039;s and ARM11&#039;s exception vectors are hardcoded to point at the CPU&#039;s internal memory (0x08000000 region for ARM9, AXIWRAM for ARM11). While the bootrom does set them up to point to an endless loop at some point during boot, it does not do so immediately. As such, a carefully-timed fault injection (via hardware) to trigger an exception (such as an invalid instruction) will cause execution to fall into ARM9 RAM. &lt;br /&gt;
Since RAM isn&#039;t cleared on boot (see below), one can immediately start execution of their own code here to dump bootrom, OTP, etc.&lt;br /&gt;
The ARM9 bootrom does the following at reset:  reset vector branches to another instruction, then branches to bootrom+0x8000. Hence, there&#039;s no way to know for certain when exactly the ARM9 exception-vector data stored in memory gets initialized.&lt;br /&gt;
&lt;br /&gt;
This requires *very* *precise* timing for triggering the hardware fault.&lt;br /&gt;
&lt;br /&gt;
It has been exploited by derrek to dump the ARM9 bootrom as of Summer 2015.&lt;br /&gt;
| None: all available 3DS models at the time of writing have the exact same ARM9/ARM11 bootrom for the unprotected areas.&lt;br /&gt;
| New3DS&lt;br /&gt;
| End of February 2014&lt;br /&gt;
| [[User:Derrek|derrek]], WulfyStylez (May 2015) independently&lt;br /&gt;
|-&lt;br /&gt;
| Missing AES key clearing&lt;br /&gt;
| The hardware AES engine does not clear keys when doing a hard reset/reboot.&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| August 2014&lt;br /&gt;
| Mathieulh/Others&lt;br /&gt;
|-&lt;br /&gt;
| No RAM clearing on reboots&lt;br /&gt;
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM/VRAM keeps its contents.&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| March 2014&lt;br /&gt;
| [[User:Derrek|derrek]]&lt;br /&gt;
|-&lt;br /&gt;
| 32bits of actual console-unique TWLNAND keydata&lt;br /&gt;
| On retail the 8-bytes at ARM9 address [[Memory_layout|0x01FFB808]] are XORed with hard-coded data, to generate the TWL console-unique keys, including TWLNAND. On Old3DS the high u32 is always 0x0, while on New3DS that u32 is always 0x2. On top of this, the lower u32&#039;s highest bit is always ORed. only 31 bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.&lt;br /&gt;
This allows one to easily bruteforce the TWL console-unique keydata with *just* data from TWLNAND. On DSi the actual console-unique data for key generation is 8-bytes(all bytes actually set).&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| 2012?&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| DSi / 3DS-TWL key-generator&lt;br /&gt;
| After using the key generator to generate the normal-key, you could overwrite parts of the normal-key with your own data and then recover the key-generator output by comparing the new crypto output with the original crypto output. From the normal-key outputs, you could deduce the TWL key-generator function.&lt;br /&gt;
This applies to the keyX/keyY too.&lt;br /&gt;
&lt;br /&gt;
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| 2011&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| 3DS key-generator&lt;br /&gt;
| The algorithm for generating the normal-keys for keyslots is cryptographically weak.  As a result, it is easily susceptible to differential cryptanalysis if the normal-key corresponding to any scrambler-generated keyslot is discovered.&lt;br /&gt;
&lt;br /&gt;
Several such pairs of matching normal-keys and KeyY values were found, leading to deducing the key-generator function.&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| February 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]], [[User:Plutooo|plutoo]]&lt;br /&gt;
|-&lt;br /&gt;
| FIRM partitions known-plaintext&lt;br /&gt;
| The [[Flash_Filesystem|FIRM partitions]] are encrypted with AES-CTR without a MAC. Since this works by XOR&#039;ing data with a static (per-console in this case) keystream, one can deduce the keystream of a portion of each FIRM partition if they have the actual FIRM binary stored in it.&lt;br /&gt;
&lt;br /&gt;
This can be paired with many exploits. For example, it allows minor FIRM downgrades (i.e. 10.4 to 9.6 or 9.5 to 9.4, but not 9.6 to 9.5).&lt;br /&gt;
&lt;br /&gt;
This can be somewhat addressed by having a FIRM header skip over previously used section offsets, but this would just air-gap newer FIRMs without fixing the core bug. This can also only be done a limited number of times due to the size of FIRM versus the size of the partitions.&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| &lt;br /&gt;
| Everyone&lt;br /&gt;
|-&lt;br /&gt;
| RSA keyslots don&#039;t clear exponent when setting modulus&lt;br /&gt;
| The [[RSA_Registers|RSA keyslots]] are set by boot ROM to have four private RSA keys.  The exponent value in the RSA registers is write-only and not readable.&lt;br /&gt;
&lt;br /&gt;
However, when setting a keyslot&#039;s modulus, the RSA hardware leaves the exponent alone.  This allows retrieving the exponent by doing a discrete logarithm of the output.&lt;br /&gt;
&lt;br /&gt;
By setting the modulus to a prime number whose modular multiplicative order is &amp;quot;smooth&amp;quot; (that is, p-1 is divisible by only small prime numbers), discrete logarithms can be calculated quickly using the [[wikipedia:Pohlig-Hellman algorithm|Pohlig-Hellman algorithm]].  If the prime chosen is greater than the modulus, but the same bit size, the discrete logarithm is the private exponent.&lt;br /&gt;
&lt;br /&gt;
This exploit&#039;s usefulness is limited: RSA keyslot 0 is only used in current firmware for deriving the 6.x save and 7.x NCCH keys, which were already known, and the other three keyslots are entirely unused.  Additionally, with a boot ROM dump, this exploit is moot; these private keys are located in the protected ARM9 boot ROM.&lt;br /&gt;
| None&lt;br /&gt;
| New3DS&lt;br /&gt;
| March 2016&lt;br /&gt;
| [[User:Myria|Myria]]&lt;br /&gt;
|-&lt;br /&gt;
| Boot9 AES keyinit function issues&lt;br /&gt;
| [[Bootloader|Boot9]] seems to have two bugs in the AES key-init function, see [[AES_Registers#AES_key-init|here]].&lt;br /&gt;
| None&lt;br /&gt;
| BootROM issue.&lt;br /&gt;
| 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ARM9 software ==&lt;br /&gt;
&lt;br /&gt;
=== arm9loader ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in [[FIRM]] system version&lt;br /&gt;
!  Last [[FIRM]] system version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Public disclosure timeframe&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| Generating the keysector console-unique keys with ITCM+Boot9&lt;br /&gt;
| [[Bootloader|Boot9]] decrypts the 0x100-byte [[OTP_Registers|OTP]] using AES-CBC with keydata stored in Boot9. If hash verification is successful, the plaintext of the first 0x90-bytes are copied into [[Memory_layout|ITCM]]. This is the &#039;&#039;exact&#039;&#039; &#039;&#039;same&#039;&#039; region hashed by arm9loader when generating the console-unique keys for decrypting the keysector, except arm9loader uses the raw encrypted OTP.&lt;br /&gt;
&lt;br /&gt;
Therefore, with the OTP keydata+IV from Boot9 you can: encrypt the 0x90-bytes from ITCM, then hash the output to get the console-unique keys for the system&#039;s keysector. This can even be done for Old3DS which doesn&#039;t have the arm9loader keysector officially.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unknown why arm9loader only used the first 0x90-bytes of OTP. Using more data from OTP would&#039;ve prevented this. Fixing this would require doing exactly that, but that would also mean updating the NAND keysector(which is dangerous).&lt;br /&gt;
| See description.&lt;br /&gt;
| None&lt;br /&gt;
| &lt;br /&gt;
| 2015&lt;br /&gt;
| January 6, 2017&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Rearrangable keys in the NAND keystore&lt;br /&gt;
| Due to the keystore being encrypted with AES-ECB, one can rearrange blocks and still have the NAND keystore decrypt in a deterministic way. &lt;br /&gt;
&lt;br /&gt;
Using 10.0 FIRM it is possible to rearrange keys such that ARM9 memory is executed. As such using existing ARM9 execution 10.0 FIRM can be written to NAND and a payload written to memory, with the payload to be executed post-K9L using an MCU reboot.&lt;br /&gt;
| arm9loaderhax given existing ARM9 code execution&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| Early 2016&lt;br /&gt;
| 27 September 2016&lt;br /&gt;
| Myria, [[User:Dark samus|dark_samus]]; mathieulh (independently); [[User:Plutooo|plutoo]] (independently) + others&lt;br /&gt;
|-&lt;br /&gt;
| Uncleared OTP hash keydata in console-unique 0x11 key-generation&lt;br /&gt;
| Kernel9Loader does not clear the [[SHA_Registers#SHA_HASH|SHA_HASH register]] after use. As a result, the data stored here as K9L hands over to Kernel9 is the hash of [[OTP_Registers|OTP data]] used to seed the [[FIRM#New_3DS_FIRM|console-unique NAND keystore decryption key]] set on keyslot 0x11.&lt;br /&gt;
&lt;br /&gt;
Retrieving this keydata and the [[Flash_Filesystem#0x12C00|NAND keystore]] of the same device allows calculating the decrypted New3DS NAND keystore (non-unique, common to all New3DS units), which contains AES normal keys, also set on keyslot 0x11, which are then used to derive all current [[AES_Registers#Keyslots|New3DS-only AES keyXs]] including the newer batch introduced in [[9.6.0-24#arm9loader|9.6.0-X]]. From there, it is trivial to perform the same key derivation in order to initialize those keys on any system version, and even on Old3DS.&lt;br /&gt;
&lt;br /&gt;
This can be performed by exploiting the &amp;quot;arm9loaderhax&amp;quot; vulnerability to obtain post-K9L code execution after an MCU reboot (the bootrom section-loading fail is not relevant here, this attack was performed without OTP data by brute-forcing keys), and using this to dump the SHA_HASH register. This attack works on any FIRM version shipping a vulnerable version of K9L, whereas OTP dumping required a boot of &amp;lt;[[3.0.0-6|3.0.0-X]].&lt;br /&gt;
&lt;br /&gt;
This attack results in obtaining the entire (0x200-bytes) NAND keystore - it was confirmed at a later date that this keystore is encrypted with the same key (by comparing the decrypted data from multiple units), and therefore using another key in this store will not remedy the issue as all keys are known (i.e. later, unused keys decrypt to the same 0x200-bytes constant with the same OTP hash). Later keys could have been encrypted differently but this is not the case. As a result of this, it is not possible for Nintendo to use K9L again in its current format for its intended purpose, though this was not news from the moment people dumped a New3DS OTP.&lt;br /&gt;
| Derivation of all New3DS keys generated via the NAND keystore (0x1B &amp;quot;Secure4&amp;quot; etc.)&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| ~April 2015, implemented in May 2015&lt;br /&gt;
| 13 January 2016&lt;br /&gt;
| [[User:WulfyStylez|WulfyStylez]], [[User:Dazzozo|Dazzozo]], [[User:Shinyquagsire23|shinyquagsire23]] (complimentary + implemented), [[User:Plutooo|plutoo]], Normmatt (discovered independently)&lt;br /&gt;
|-&lt;br /&gt;
| enhanced-arm9loaderhax&lt;br /&gt;
| See the 32c3 3ds talk.&lt;br /&gt;
Since this is a combination of a trick with the arm9-bootrom + arm9loaderhax, and since you have to manually write FIRM to the firm0/firm1 NAND partitions, this can&#039;t be completely fixed. Any system with existing ARM9 code execution and an OTP/OTP hash dump can exploit this. Additionally, by using the FIRM partition known-plaintext bug and bruteforcing the second entry in the keystore, this can currently be exploited on all New3DS systems without any other prerequisite hacks.&lt;br /&gt;
| arm9loaderhax which automatically occurs at hard-boot.&lt;br /&gt;
| See arm9loaderhax / description.&lt;br /&gt;
| See arm9loaderhax / description.&lt;br /&gt;
| Theorized around mid July, 2015. Later implemented+tested by [[User:Plutooo|plutoo]] and [[User:Derrek|derrek]].&lt;br /&gt;
| 32c3 3ds talk (December 27, 2015)&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Missing verification-block for the 9.6 keys (arm9loaderhax)&lt;br /&gt;
| Starting with [[9.6.0-24|9.6.0-X]] a new set of NAND-based keys were introduced. However, no verification block was added to verify that the new key read from NAND is correct. This was technically an issue from [[9.5.0-22|9.5.0-X]] with the original sector+0 keydata, however the below is only possible with [[9.6.0-24|9.6.0-X]] since keyslots 0x15 and 0x16 are generated from different 0x11 keyXs.&lt;br /&gt;
&lt;br /&gt;
Writing an incorrect key to NAND will cause arm9loader to decrypt the ARM9 kernel as garbage and then jump to it.&lt;br /&gt;
&lt;br /&gt;
This allows an hardware-based attack where you can boot into an older exploited firmware, fill all memory with NOP sleds/jump-instructions, and then reboot into executing garbage. By automating this process with various input keydata, eventually you&#039;ll find some garbage that jumps to your code.&lt;br /&gt;
&lt;br /&gt;
This gives very early ARM9 code execution (pre-ARM9 kernel). As such, it is possible to dump RSA keyslots with this and calculate the 6.x [[Savegames#6.0.0-11_Savegame_keyY|save]], and 7.x [[NCCH]] keys. This cannot be used to recover keys initialized by arm9loader itself. This is due to it wiping the area used for its stack during NAND sector decryption and keyslot init. &lt;br /&gt;
&lt;br /&gt;
Due to FIRMs on both Old and New 3DS using the same RSA data, this can be exploited on Old3DS as well, but only if one already has the actual plaintext normalkey from New3DS NAND sector 0x96 offset-0 and has dumped the OTP area of the Old3DS.&lt;br /&gt;
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key, access to uncleared OTP hash keydata&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| March, 2015&lt;br /&gt;
| &lt;br /&gt;
| [[User:Plutooo|plutoo]]&lt;br /&gt;
|-&lt;br /&gt;
| Uncleared New3DS keyslot 0x11&lt;br /&gt;
| Originally the New3DS [[FIRM]] arm9bin loader only cleared keyslot 0x11 when it gets executed at firmlaunch. This was fixed with [[9.5.0-22|9.5.0-X]] by completely clearing keyslot 0x11 immediately after the loader finishes using keyslot 0x11.&lt;br /&gt;
This means that any ARM9 code that can execute before the loader clears the keyslot at firmlaunch(including firmlaunch-hax) can get access to the uncleared keyslot 0x11, which then allows one to generate all &amp;lt;=v9.5 New3DS keyXs which are generated by keyslot 0x11.&lt;br /&gt;
&lt;br /&gt;
Therefore, to completely fix this the loader would have to generate more keys using different keyslot 0x11 keydata. This was done with [[9.6.0-24|9.6.0-X]].&lt;br /&gt;
| New3DS keyXs generation&lt;br /&gt;
| Mostly fixed with [[9.5.0-22|9.5.0-X]], completely fixed with new keys with [[9.6.0-24|9.6.0-X]].&lt;br /&gt;
| &lt;br /&gt;
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Process9 ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in [[FIRM]] system version&lt;br /&gt;
!  Last [[FIRM]] system version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Public disclosure timeframe&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| Leak of normal-key matching a key-scrambler key&lt;br /&gt;
| New 3DS firmware versions [[8.1.0-0 New3DS|8.1.0]] through [[9.2.0-20|9.2.0]] set the encryption key for [[Amiibo]] data using a hardcoded normal-key in Process9.  In firmware [[9.3.0-21|9.3.0]], Nintendo &amp;quot;fixed&amp;quot; this by using the key scrambler instead, by calculating the keyY value for keyslot 0x39 that results in the same normal-key, then hardcoding that keyY into Process9.&lt;br /&gt;
&lt;br /&gt;
Nintendo&#039;s fix is actually the problem: Nintendo revealed the normal-key matching an unknown keyX and a known keyY.  Combined with the key scrambler using an insecure scrambling algorithm (see &amp;quot;Hardware&amp;quot; above), the key scrambler function could be deduced.&lt;br /&gt;
| Deducing the keyX for keyslot 0x39 and the key scrambler algorithm&lt;br /&gt;
| New 3DS [[9.3.0-21|9.3.0-X]], sort of&lt;br /&gt;
| [[10.0.0-27|10.0.0-X]]&lt;br /&gt;
| Sometime in 2015 after the hardware key-generator was broken.&lt;br /&gt;
| 32c3 3ds talk (December 27, 2015)&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Leak of normal-key matching a key-generator key&lt;br /&gt;
| During the 3DS&#039; development (June/July 2010) Nintendo added support installing encrypted content ([[CIA]]). Common-key index1 was intended to be a [[AES|hardware generated key]]. However while they added code to generate the key in hardware, they forgot to remove the normal-key for index1 (used elsewhere, likely old debug code). Nintendo later removed the normal key sometime before the first non-prototype firmware release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Knowing the keyY and the normal-key for common-key index1, the devkit key-generator algorithm can be deduced (see &amp;quot;Hardware&amp;quot; above). Additionally the remaining devkit common-keys can be generated once the common-key keyX is recovered.&lt;br /&gt;
&lt;br /&gt;
Note the devkit key-generator was discovered to be the same as the retail key-generator.&lt;br /&gt;
| Deducing the keyX for keyslot 0x3D and hardware key-generator algorithm. Generate remaining devkit common-keys.&lt;br /&gt;
| pre-[[1.0.0-0|1.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| Shortly after the key-generator was revealed to be flawed at the 32c3 3ds talk&lt;br /&gt;
| January 20, 2016&lt;br /&gt;
| [[User:Jakcron|jakcron]]&lt;br /&gt;
|-&lt;br /&gt;
| safefirmhax&lt;br /&gt;
| SAFE_MODE_FIRM is almost never updated(even when NATIVE_FIRM is updated for vuln fixes), this can be noticed by &#039;&#039;just&#039;&#039; checking 3dbrew/ninupdates title-listings.&lt;br /&gt;
&lt;br /&gt;
The fix for firmlaunch-hax was only applied to NATIVE_FIRM in [[9.5.0-22|9.5.0-X]], leaving SAFE_FIRM exploitable. With ARM11-kernel execution, one can trigger FIRM-launch in to SAFE_FIRM, do Kernel9 &amp;lt;=&amp;gt; Kernel11 sync, PXI sync and then repeat the original attack on SAFE_FIRM instead.&lt;br /&gt;
| ARM9 code execution&lt;br /&gt;
| None&lt;br /&gt;
| &lt;br /&gt;
| 2012-2013?&lt;br /&gt;
| Wiki: January 2, 2017&lt;br /&gt;
| Everyone&lt;br /&gt;
|-&lt;br /&gt;
| ntrcardhax&lt;br /&gt;
| When reading the banner of a NTR title, Process9 relies on a hardware register to know when the banner was fully read.&lt;br /&gt;
However that register is shared between the ARM9 and the ARM11.&lt;br /&gt;
An attacker with k11 control can so make Process9 believe the banner continues forever and so trigger a buffer overflow.&lt;br /&gt;
With a custom banner for a NTR flashcart, this leads to code execution in Process9.&lt;br /&gt;
&lt;br /&gt;
This was fixed by adding bound checks on the read data.&lt;br /&gt;
| ARM9 code execution&lt;br /&gt;
| [[10.4.0-29|10.4.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| March 2015&lt;br /&gt;
| 32c3 3ds talk (December 27, 2015)&lt;br /&gt;
| [[User:Plutooo|plutoo]]&lt;br /&gt;
|-&lt;br /&gt;
| Title downgrading via [[Application_Manager_Services|AM]]([[Application_Manager_Services_PXI|PXI]])&lt;br /&gt;
| When a title is *already* installed, Process9 will compare the installed title-version with the title-version being installed. When the one being installed is older, Process9 would return an error.&lt;br /&gt;
&lt;br /&gt;
However, this can be bypassed by just deleting the title first via the service command(s) for that: with the title removed from the [[Title_Database]], Process9 can&#039;t compare the input title-version with anything. Hence, titles can be downgraded this way.&lt;br /&gt;
&lt;br /&gt;
[[11.0.0-33|11.0.0-X]] fixed this for key system titles (MSET, Home Menu, spider, ErrDisp, SKATER, NATIVE_FIRM, and every retail system module), by checking the version of the title to install against a hard-coded list of (titleID, minimumVersionRequired) pairs.&lt;br /&gt;
| Bypassing title version check at installation, which then allows downgrading any title.&lt;br /&gt;
| [[11.0.0-33|11.0.0-X]], for key system titles.&lt;br /&gt;
| NATIVE_FIRM / AM-sysmodule [[11.0.0-33|11.0.0-X]]&lt;br /&gt;
| ?&lt;br /&gt;
| &lt;br /&gt;
| ?&lt;br /&gt;
|-&lt;br /&gt;
| FAT FS code null-deref&lt;br /&gt;
| When FSFile:Read is used with a file which is corrupted on a FAT filesystem(in particular SD), Process9 can crash. This particular crash is caused by a function returning NULL instead of an actual ptr due to an error. The caller of that function doesn&#039;t check for NULL which then triggers a read based at NULL.&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;fsck.vfat -n -v -V &amp;lt;fat image backup&amp;gt;&amp;quot; output for the above crash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;...&lt;br /&gt;
Starting check/repair pass.&lt;br /&gt;
&amp;lt;FilePath0&amp;gt; and&lt;br /&gt;
&amp;lt;FilePath1&amp;gt;&lt;br /&gt;
 share clusters.&lt;br /&gt;
 Truncating second to 3375104 bytes.&lt;br /&gt;
&amp;lt;FilePath1&amp;gt;&lt;br /&gt;
 File size is 2787392 bytes, cluster chain length is 16384 bytes.&lt;br /&gt;
 Truncating file to 16384 bytes.&lt;br /&gt;
Checking for unused clusters.&lt;br /&gt;
Reclaimed 1 unused cluster (16384 bytes).&lt;br /&gt;
Checking free cluster summary.&lt;br /&gt;
Free cluster summary wrong (1404490 vs. really 1404491)&lt;br /&gt;
 Auto-correcting.&lt;br /&gt;
Starting verification pass.&lt;br /&gt;
Checking for unused clusters.&lt;br /&gt;
Leaving filesystem unchanged.&amp;lt;/pre&amp;gt;&lt;br /&gt;
| Useless null-based-read&lt;br /&gt;
| None&lt;br /&gt;
| [[9.6.0-24|9.6.0-X]]&lt;br /&gt;
| July 8-9, 2015&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| RSA signature padding checks&lt;br /&gt;
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].&lt;br /&gt;
The main 3DS RSA padding check code(non-certificate, including NATIVE_FIRM) uses the function used with the above to extract more padding + the actual hash from the additional padding. This isn&#039;t really a problem here because there&#039;s proper padding check code which is executed prior to this.&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[9.5.0-22|9.5.0-X]]&lt;br /&gt;
| March 2015&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[AMPXI:ValidateDSiWareSectionMAC]] [[AES_Registers|AES]] keyslot reuse&lt;br /&gt;
| When the input DSiWare section index is higher than &amp;lt;max number of DSiWare sections supported by this FIRM&amp;gt;, Process9 uses keyid 0x40 for calculating the AESMAC, which translates to keyslot 0x40. The result is that the keyslot is left at whatever was already selected before, since the AES selectkeyslot code will immediately  return when keyslot is &amp;gt;=0x40. However, actually exploiting this is difficult: the calculated AESMAC is never returned, this command just compares the calculated AESMAC with the input AESMAC(result-code depends on whether the AESMACs match). It&#039;s unknown whether a timing attack would work with this.&lt;br /&gt;
This is basically a different form of the pxips9 keyslot vuln, except with AESMAC etc.&lt;br /&gt;
| See description.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| March 15, 2015&lt;br /&gt;
| December 29, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| pxips9 [[AES_Registers|AES]] keyslot reuse&lt;br /&gt;
| This requires access to the [[Process_Services|ps:ps]]/pxi:ps9 services. One way to get access to this would be snshax on system-version &amp;lt;=10.1.0-X(see 32c3 3ds talk).&lt;br /&gt;
When an invalid key-type value is passed to any of the PS commands, Process9 will try to select keyslot 0x40. That aesengine_setkeyslot() code will then immediately return due to the invalid keyslot value. Since that function doesn&#039;t return any errors, Process9 will just continue to do crypto with whatever AES keyslot was selected before the PS command was sent.&lt;br /&gt;
| Reusing the previously used keyslot, for crypto with PS.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| Roughly the same time(same day?) as firmlaunch-hax.&lt;br /&gt;
| December 29, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| firmlaunch-hax: FIRM header ToCToU&lt;br /&gt;
| This can&#039;t be exploited from ARM11 userland.&lt;br /&gt;
During [[FIRM]] launch, the only FIRM header the ARM9 uses at all is stored in FCRAM, this is 0x200-bytes(the actual used FIRM RSA signature is read to the Process9 stack however). The ARM9 doesn&#039;t expect &amp;quot;anything&amp;quot; besides the ARM9 to access this data.&lt;br /&gt;
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.&lt;br /&gt;
| ARM9 code execution&lt;br /&gt;
| [[9.5.0-22]]&lt;br /&gt;
| &lt;br /&gt;
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Uninitialized data output for (PXI) command replies&lt;br /&gt;
| PXI commands for various services(including some [[Filesystem_services_PXI|here]] and many others) can write uninitialized data (like from ARM registers) to the command reply. This happens with stubbed commands, but this can also occur with certain commands when returning an error.&lt;br /&gt;
Certain ARM11 service commands have this same issue as well.&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[9.3.0-21|9.3.0-X]]&lt;br /&gt;
| ?&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions&lt;br /&gt;
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.&lt;br /&gt;
This would mean ARM11-kernelmode code / fs-module itself could directly use FSPXI to access SD card without ARM9 checking for SD access, but this is rather useless since a process is usually running with SD access(Home Menu for example) anyway.&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[9.3.0-21|9.3.0-X]]&lt;br /&gt;
| 2012&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[AMPXI:ExportDSiWare]] export path&lt;br /&gt;
| Process9 allocates memory on Process9 heap for the export path then verifies that the actual allocated size matches the input size. Then Process9 copies the input path from FCRAM to this buffer, and uses it with the Process9 FS openfile code, which use paths in the form of &amp;quot;&amp;lt;mountpoint&amp;gt;:/&amp;lt;path&amp;gt;&amp;quot;.&lt;br /&gt;
Process9 does not check the contents of this path at all before passing it to the FS code, besides writing a NUL-terminator to the end of the buffer.&lt;br /&gt;
| Exporting of DSiWare to arbitrary Process9 file-paths, such as &amp;quot;nand:/&amp;lt;path&amp;gt;&amp;quot; etc. This isn&#039;t really useful since the data which gets written can&#039;t be controlled.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.5.0-22]]&lt;br /&gt;
| April 2013&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[DSiWare_Exports]] [[CTCert]] verification&lt;br /&gt;
| Just like DSi originally did, 3DS verifies the APCert for DSiWare on SD with the CTCert also in the DSiWare .bin. On DSi this was fixed with with system-version 1.4.2 by verifying with the actual console-unique cert instead(stored in NAND), while on 3DS it&#039;s still not(?) fixed.&lt;br /&gt;
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.&lt;br /&gt;
| When the movable.sed keyY for the target 3DS is known and the target 3DS CTCert private-key is unknown, importing of modified DSiWare SD .bin files.&lt;br /&gt;
| Unknown, probably none.&lt;br /&gt;
| ?&lt;br /&gt;
| April 2013&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size&lt;br /&gt;
| The u8 REG_CTRCARDCNT transfer-size parameter for the [[Gamecard_Services_PXI]] read/write CTRCARD commands is used as an index for an array of u16 values. Before [[5.0.0-11|5.0.0-X]] this u8 value wasn&#039;t checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).&lt;br /&gt;
| Out-of-bounds read for a value which gets written to a register.&lt;br /&gt;
| [[5.0.0-11|5.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| 2013?&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[PXI_Registers|PXI]] cmdbuf buffer overrun&lt;br /&gt;
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn&#039;t verify the size of the incoming command before writing it to a C++ member variable. &lt;br /&gt;
| Probably ARM9 code execution&lt;br /&gt;
| [[5.0.0-11|5.0.0-11]]&lt;br /&gt;
| &lt;br /&gt;
| March 2015, original timeframe if any unknown&lt;br /&gt;
| &lt;br /&gt;
| [[User:Plutooo|plutoo]]/[[User:Yellows8|Yellows8]]/maybe others(?)&lt;br /&gt;
|-&lt;br /&gt;
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])&lt;br /&gt;
| When handling this command, Process9 allocates a 0x2800-byte heap buffer, then copies the 4 FCRAM input buffers to this heap buffer without checking the sizes at all(only the buffers with non-zero sizes are copied). Starting with [[5.0.0-11|5.0.0-X]], the total combined size of the input data must be &amp;lt;=0x2800.&lt;br /&gt;
| ARM9 code execution&lt;br /&gt;
| [[5.0.0-11|5.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| May 2013&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Process_Services_PXI|PS RSA]] commands buffer overflows&lt;br /&gt;
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9&#039;s .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads&#039; stacks. SignRsaSha256 also has a buf overflow, but this isn&#039;t exploitable.&lt;br /&gt;
The buffer for this is the buffer for the signature data. With v5.0, the signature buffer was moved to stack, with a check for the signature data size. When the signature data size is too large, Process9 uses [[SVC|svcBreak]].&lt;br /&gt;
| ARM9 code execution&lt;br /&gt;
| [[5.0.0-11|5.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| 2012&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[PXI_Registers|PXI]] pxi_id bad check&lt;br /&gt;
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:&lt;br /&gt;
* They used it as index to a lookup-table without checking the value at all.&lt;br /&gt;
* Another function verified that pxi_id &amp;lt; 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.&lt;br /&gt;
| Maybe ARM9 code execution&lt;br /&gt;
| [[3.0.0-5|3.0.0-5]]&lt;br /&gt;
|&lt;br /&gt;
| March 2015, originally 2012 for the first issue at least&lt;br /&gt;
| &lt;br /&gt;
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]], maybe others(?)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Kernel9 ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in [[FIRM]] system version&lt;br /&gt;
!  Last [[FIRM]] system version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9&lt;br /&gt;
| Old versions of Kernel9 never set bit1 of [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]]. This leaves the [[OTP Registers|0x10012000]]-region unprotected (this region should be locked early during boot!). Since it&#039;s never locked, you can dump it once you get ARM9 code execution.&lt;br /&gt;
&lt;br /&gt;
From [[3.0.0-5|3.0.0-X]] this was fixed by setting the bit in Kernel9 after poking some registers in that region. On New3DS arm9loader sets this bit instead of Kernel9, which is exploitable through a hardware + software vulnerability (see arm9loaderhax / description).&lt;br /&gt;
&lt;br /&gt;
This flaw resurged when it gained a new practical use: retrieving the OTP data for a New3DS console in order to decrypt the key data used in arm9loader (see enhanced-arm9loaderhax / description). This was performed by downgrading to a vulnerable system version. By accounting for differences in CTR-NAND crypto (0x05 -&amp;gt; 0x04, see partition encryption types [[Flash_Filesystem#NAND_structure|here]]), it is possible to boot a New3DS using Old3DS firmware 1.0-2.X and an Old3DS [[NCSD#NCSD_header|NCSD Header]] to retrieve the required OTP data using this flaw.&lt;br /&gt;
| Dumping of the [[OTP Registers|OTP]] area&lt;br /&gt;
| [[3.0.0-5|3.0.0-X]]&lt;br /&gt;
|&lt;br /&gt;
| February 2015&lt;br /&gt;
| [[User:Plutooo|plutoo]], Normmatt independently&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ARM11 software ==&lt;br /&gt;
=== Kernel11 ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in [[FIRM]] system version&lt;br /&gt;
!  Last [[FIRM]] system version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| fasthax&lt;br /&gt;
| When a KTimer is created in pulse mode, the kernel calls a virtual function to reset the timer each time it pulses. The scheduler is locked for that core to avoid race conditions, but another core can call CloseHandle on the timer and free it, leading to a UAF vtable call.&lt;br /&gt;
| See description.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| May 2016&lt;br /&gt;
| nedwill&lt;br /&gt;
|-&lt;br /&gt;
| ipctakeover&lt;br /&gt;
| When sending cmdreplies, it does not validate that the src_addr and src_size match the equivalent dst_addr and dst_size. With a modified addr/size specified in a cmdreply for an output buffer, the data-copy for the first/last pages could be used to overwrite data outside of the buffer specified by the original process.&lt;br /&gt;
&lt;br /&gt;
Used by ctr-httpwn as of v1.2, for &amp;quot;ipctakeover/bosshaxx&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This can be used to takeover processes where the process is using your service session. Like HTTPC -&amp;gt; BOSS, for bosshaxx above. NIM takeover can be done too(actual stack buffer overflow can trigger), etc.&lt;br /&gt;
| See description.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| November 26, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Using IPC input buffers as output buffers&lt;br /&gt;
| When sending cmdreplies, it does not validate that the cmdreply descriptor type matches the equivalent cmdreq descriptor type. This could be used by an exploited sysmodule to use what was intended as an input-buffer as an output-buffer, and also combine other IPC vuln(s) with this.&lt;br /&gt;
&lt;br /&gt;
Used by ctr-httpwn as of v1.2, for &amp;quot;ipctakeover/bosshaxx&amp;quot;.&lt;br /&gt;
| See description.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| November 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
|  [[SVC]] table too small&lt;br /&gt;
|  The table of function pointers for SVC&#039;s only contains entries up to 0x7D, but the biggest allowed SVC for the table is 0x7F. Thus, executing SVC7E or SVC7F would make the SVC-handler read after the buffer, and interpret some ARM instructions as function pointers.&lt;br /&gt;
&lt;br /&gt;
However, this would require patching the kernel .text or modifying SVC-access-control. Even if you could get these to execute, they would still jump to memory that isn&#039;t mapped as executable.&lt;br /&gt;
| &lt;br /&gt;
|  None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| 2012&lt;br /&gt;
| Everyone&lt;br /&gt;
|-&lt;br /&gt;
|  [[SVC|svcBackdoor (0x7B)]]&lt;br /&gt;
|  This backdoor allows executing SVC-mode code at the user-specified code-address. This is used by Process9, using this on the ARM11 (with NATIVE_FIRM) required patching the kernel .text or modifying SVC-access-control.&lt;br /&gt;
| See description&lt;br /&gt;
| [[11.0.0-33|11.0.0-X]] (deleted)&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
| Everyone&lt;br /&gt;
|-&lt;br /&gt;
| veryslowpidhax&lt;br /&gt;
| &#039;&#039;&#039;This is completely different from the kernelmode-code-execution vuln described in the below separate entry.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When updating the kernel global PID counter under [[SVC|svcCreateProcess]] the kernel does not check for wraparound to 0x0(the PID for the very first process). This only matters because [[Services|SM-module]] allows processes with PID value less than &amp;lt;total ARM11 FIRM modules&amp;gt; to access &#039;&#039;all&#039;&#039; services, without checking exheader service-access-control; and because Kernel11 checks for the PID to be 1 (loader) to use the input mem-region value on ControlMemory. This alone does not affect access the [[SVC|SVCs]] access table at all.&lt;br /&gt;
&lt;br /&gt;
Inlined ldrex+strex code is used for updating the above counter. [[11.2.0-35|11.2.0-X]] had changes for similar code, but it was only for dedicated ldrex+strex functions(mainly for kernel objects) and hence this PID code was not affected.&lt;br /&gt;
&lt;br /&gt;
With launching+terminating a sysmodule repeatedly with this via ns:s, it would take weeks to finish(if not at least about a month?).&lt;br /&gt;
| Access to all [[Services_API|services]], ControlMemory on any given mem-region.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| 2012 maybe?&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
|  slowhax/waithax&lt;br /&gt;
|  svcWaitSynchronizationN does not decrement the references to valid handles in an array before returning an error when it encounters an invalid handle. This allows one to (slowly) overflow the reference count for a handle object to zero.&lt;br /&gt;
| ARM11 kernel-mode code execution&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| 2016&lt;br /&gt;
| nedwill, [[User:Derrek|derrek]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory&lt;br /&gt;
| The ARM11 kernel-mode 0xEFF00000/0xDFF00000 virtual-memory(size 0x100000) is mapped to phys-mem 0x1FF00000(entire DSP-mem + entire AXIWRAM), with permissions RW-. This is used during ARM11 kernel startup for loading the FIRM-modules from the FIRM section located in DSP-mem, this never seems to be used after that, however. This is never unmapped either.&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| memchunkhax2.1&lt;br /&gt;
| Nintendo&#039;s fix for memchunkhax2 in [[10.4.0-29|10.4.0-X]] did not fix the GPU case: one may cause the requisite ToCToU race using gspwn, bypassing the new validation.&lt;br /&gt;
derrek&#039;s original 32c3 presentation for memchunkhax2 commented that a GPU-based attack was possible, but would be difficult.  However, memchunkhax2.1 showed that it was possible to do fairly reliably.&lt;br /&gt;
| ARM11 kernel code execution&lt;br /&gt;
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.&lt;br /&gt;
| [[11.0.0-33|11.0.0-X]]&lt;br /&gt;
|&lt;br /&gt;
| [[User:Derrek|derrek]], aliaspider&lt;br /&gt;
|-&lt;br /&gt;
| memchunkhax2&lt;br /&gt;
| When allocating a block of memory, the &amp;quot;next&amp;quot; pointer of the [[Memory_Management#MemoryBlockHeader|memchunkhdr]] is accessed without being checked after being mapped to userland.&lt;br /&gt;
This allows a race condition, where the process can change the next pointer just before it&#039;s accessed. By pointing the next pointer to a crafted memchunckhdr in the kernel SlabHeap, some of the SlabHeap is allocated to the calling process, allowing to change vtables of kernel objects. &lt;br /&gt;
| ARM11 kernel code execution&lt;br /&gt;
| [[10.4.0-29|10.4.0-X]] (partially, see memchunkhax2.1)&lt;br /&gt;
| [[10.4.0-29|10.4.0-X]]&lt;br /&gt;
|&lt;br /&gt;
| [[User:Derrek|derrek]]&lt;br /&gt;
|-&lt;br /&gt;
| heaphax&lt;br /&gt;
| Can change the size of free memchunk structures stored in FCRAM using DMA, which leads to the ability to allocate memory chunks over already-allocated memory. This can be used in the SYSTEM region to allocate RW memory over any part of the NS system module, which is enough to take it over.&lt;br /&gt;
| Code execution with access to all of NS&#039;s privileges. (including downgrading) Code execution within any applet.&lt;br /&gt;
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.&lt;br /&gt;
| [[11.0.0-33|11.0.0-X]]&lt;br /&gt;
| April 2015 ?&lt;br /&gt;
| smea&lt;br /&gt;
|-&lt;br /&gt;
| snshax&lt;br /&gt;
| Can force creation of Safe NS process into gspwn-able memory, allowing for takeover.&lt;br /&gt;
| Code execution with access to all of NS&#039;s privileges. (including downgrading)&lt;br /&gt;
| [[10.1.0-27|10.1.0-X]]&lt;br /&gt;
| [[10.1.0-27|10.1.0-X]]&lt;br /&gt;
| April 2015 ?&lt;br /&gt;
| smea&lt;br /&gt;
|-&lt;br /&gt;
|  AffinityMask/processorid validation&lt;br /&gt;
|  With [[10.0.0-27|10.0.0-X]] the following functions were updated: svcGetThreadAffinityMask, svcGetProcessAffinityMask, svcSetProcessAffinityMask, and svcCreateThread. The code changes for all but svcCreateThread are identical.&lt;br /&gt;
The original code with the first 3 did the following: &lt;br /&gt;
* if(u32_processorcount &amp;gt; ~0x80000001)return 0xe0e01bfd;&lt;br /&gt;
* if(s32_processorcount &amp;gt; &amp;lt;total_cores&amp;gt;)return 0xd8e007fd;&lt;br /&gt;
The following code replaced the above:&lt;br /&gt;
* if(u32_processorcount &amp;gt;= &amp;lt;total_cores+1&amp;gt;)return 0xd8e007fd;&lt;br /&gt;
In theory the latter should catch everything that the former did, so it&#039;s unknown if this was really a security issue.&lt;br /&gt;
&lt;br /&gt;
The svcCreateThread changes with [[10.0.0-27|10.0.0-X]] definitely did fix a security issue.&lt;br /&gt;
* Original code: &amp;quot;if(s32_processorid &amp;gt; &amp;lt;total_cores&amp;gt;)return 0xd8e007fd;&amp;quot;&lt;br /&gt;
* New code: &amp;quot;if(s32_processorid &amp;gt;= &amp;lt;total_cores&amp;gt; || s32_processorid &amp;lt;= -4)return 0xd8e007fd;&amp;quot;&lt;br /&gt;
This fixed an off-by-one issue: if one would use processorid=total_cores, which isn&#039;t actually a valid value, svcCreateThread would accept that value on &amp;lt;[[10.0.0-27|10.0.0-X]]. This results in data being written out-of-bounds(baseaddr = arrayaddr + entrysize*processorid), which has the following result:&lt;br /&gt;
* Old3DS: Useless kernel-mode crash due to accessing unmapped memory.&lt;br /&gt;
* New3DS: uncontrolled data write into a kernel-mode L1 MMU-table. This isn&#039;t really useful: the data can&#039;t be controlled, and the data which gets overwritten is all-zero anyway(this isn&#039;t anywhere near MMU L1 entries for actually mapped memory).&lt;br /&gt;
The previous version also allowed large negative s32_processorid values(negative processorid values are special values not actual procids), but it appears using values like that won&#039;t actually do anything(meaning no crash) besides the thread not running / thread not running for a while(besides triggering a kernelpanic with certain s32_processorid value(s)).&lt;br /&gt;
| Nothing useful&lt;br /&gt;
|  [[10.0.0-27|10.0.0-X]]&lt;br /&gt;
| [[10.0.0-27|10.0.0-X]]&lt;br /&gt;
| svcCreateThread issue: May 31, 2015. The rest: September 8, 2015, via v9.6-&amp;gt;v10.0 ARM11-kernel code-diff.&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| memchunkhax&lt;br /&gt;
| The kernel originally did not validate the data stored in the FCRAM kernel heap [[Memchunkhdr|memchunk-headers]] for free-memory at all. Exploiting this requires raw R/W access to these memchunk-headers, like physical-memory access with gspwn.&lt;br /&gt;
&lt;br /&gt;
There are &#039;&#039;multiple&#039;&#039; ways to exploit this, but the end-result for most of these is the same: overwrite code in AXIWRAM via the 0xEFF00000/0xDFF00000 kernel virtual-memory mapping.&lt;br /&gt;
&lt;br /&gt;
This was fixed in [[9.3.0-21|9.3.0-X]] by checking that the memchunk(including size, next, and prev ptrs) is located within the currently used heap memory. The kernel may also check that the next/prev ptrs are valid compared to other memchunk-headers basically. When any of these checks fail, kernelpanic() is called.&lt;br /&gt;
| When combined with other flaws: ARM11-kernelmode code execution&lt;br /&gt;
| [[9.3.0-21|9.3.0-21]]&lt;br /&gt;
| &lt;br /&gt;
| February 2014&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs&lt;br /&gt;
| The ARM11-kernel did access the &#039;key&#039; field of [[KLinkedListNode|KLinkedListNode]] objects, which are located on the SlabHeap, after freeing them. Thus, triggering an allocation of a new [[KLinkedListNode|KLinkedListNode]] object at the right time could result in a type-confusion. Pseudo-code:&lt;br /&gt;
SlabHeap_free(KLinkedListNode);&lt;br /&gt;
KObject *obj = KLinkedListNode-&amp;gt;key;  // the object there might have changed!&lt;br /&gt;
This bug appeared all over the place.&lt;br /&gt;
| ARM11-kernelmode code exec maybe&lt;br /&gt;
| [[8.0.0-18|8.0.0-18]]&lt;br /&gt;
| &lt;br /&gt;
| April 2015&lt;br /&gt;
| [[User:Derrek|derrek]]&lt;br /&gt;
|-&lt;br /&gt;
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions&lt;br /&gt;
| Originally the ARM11-kernel didn&#039;t check permissions for PXI input/output buffers for commands. Starting with [[6.0.0-11|6.0.0]] PXI input/output buffers must have RW permissions, otherwise kernelpanic is triggered.&lt;br /&gt;
| &lt;br /&gt;
| [[6.0.0-11|6.0.0-11]]&lt;br /&gt;
| &lt;br /&gt;
| 2012&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SVC|svcStartInterProcessDma]]&lt;br /&gt;
| For svcStartInterProcessDma, the kernel code had the following flaws:&lt;br /&gt;
&lt;br /&gt;
* Originally the ARM11-kernel read the input DmaConfig structure directly in kernel-mode(ldr(b/h) instructions), without checking whether the DmaConfig address is readable under userland. This was fixed by copying that structure to the SVC-mode stack, using the ldrbt instruction.&lt;br /&gt;
&lt;br /&gt;
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.&lt;br /&gt;
&lt;br /&gt;
* The kernel now also checks whether the srcaddr/dstaddr (+size) is within userland memory (0x20000000), the kernel now (with [[6.0.0-11]]) returns an error when the address is beyond userland memory. Using an address &amp;gt;=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr-&amp;gt;physaddr conversion). &lt;br /&gt;
| &lt;br /&gt;
| [[6.0.0-11]]&lt;br /&gt;
| &lt;br /&gt;
| DmaConfig issue: unknown. The rest: 2014&lt;br /&gt;
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] independently&lt;br /&gt;
|-&lt;br /&gt;
| [[SVC|svcControlMemory]] Parameter checks&lt;br /&gt;
| For svcControlMemory the parameter check had these two flaws:&lt;br /&gt;
&lt;br /&gt;
* The allowed range for addr0, addr1, size parameters depends on which MemoryOperation is being specified. The limitation for GSP heap was only checked if op=(u32)0x10003. By setting a random bit in op that has no meaning (like bit17?), op would instead be (u32)0x30003, and the range-check would be less strict and not accurate. However, the kernel doesn&#039;t actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn&#039;t actually useful. This was fixed in the kernel by just checking for the LINEAR bit, instead of comparing the entire MemoryOperation value with 0x10003.&lt;br /&gt;
&lt;br /&gt;
* Integer overflows on (addr0+size) are now checked that previously weren&#039;t (this also applies to most other address checks elsewhere in the kernel).&lt;br /&gt;
&lt;br /&gt;
| &lt;br /&gt;
| [[5.0.0-11]]&lt;br /&gt;
| &lt;br /&gt;
|&lt;br /&gt;
| [[User:Plutooo|plutoo]]&lt;br /&gt;
|-&lt;br /&gt;
| [[RPC_Command_Structure|Command]] request/response buffer overflow&lt;br /&gt;
| Originally the kernel did not check the word-values from the command-header. Starting with [[5.0.0-11]], the kernel will trigger a kernelpanic() when the total word-size of the entire command(including the cmd-header) is larger than 0x40-words (0x100-bytes). This allows overwriting threadlocalstorage+0x180 in the destination thread. However, since the data written there would be translate parameters (such as header-words + buffer addresses), exploiting this would likely be very difficult, if possible at all.&lt;br /&gt;
&lt;br /&gt;
If the two words at threadlocalstorage+0x180 could be overwritten with controlled data this way, one could then use a command with a buffer-header of &amp;lt;nowiki&amp;gt;((size&amp;lt;&amp;lt;14) | 2)&amp;lt;/nowiki&amp;gt; to write arbitrary memory to any RW userland memory in the destination process.&lt;br /&gt;
| &lt;br /&gt;
| [[5.0.0-11]]&lt;br /&gt;
| &lt;br /&gt;
| v4.1 FIRM -&amp;gt; v5.0 code diff&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SVC|SVC stack allocation overflows]]&lt;br /&gt;
| &lt;br /&gt;
* Syscalls that allocate a variable-length array on stack, only checked bit31 before multiplying by 4/16 (when calculating how much memory to allocate). If a large integer was passed as input to one of these syscalls, an integer overflow would occur, and too little memory would have been allocated on stack resulting in a buffer overrun. &lt;br /&gt;
* The alignment (size+7)&amp;amp;~7 calculation before allocation was not checked for integer overflow.&lt;br /&gt;
&lt;br /&gt;
This might allow for ARM11 kernel code-execution.&lt;br /&gt;
&lt;br /&gt;
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)&lt;br /&gt;
| &lt;br /&gt;
| [[5.0.0-11]]&lt;br /&gt;
| &lt;br /&gt;
| v4.1 FIRM -&amp;gt; v5.0 code diff&lt;br /&gt;
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] complementary&lt;br /&gt;
|-&lt;br /&gt;
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions&lt;br /&gt;
| svcControlMemory with MemoryOperation=MAP allows mapping the already-mapped process virtual-mem at addr1, to addr0. The lowest address permitted for addr1 is 0x00100000. Originally the ARM11 kernel didn&#039;t check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.&lt;br /&gt;
| &lt;br /&gt;
| [[4.1.0-8]]&lt;br /&gt;
| &lt;br /&gt;
| 2012&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[RPC_Command_Structure|Command]] input/output buffer permissions&lt;br /&gt;
| Originally the ARM11 kernel didn&#039;t check memory permissions for the input/output buffers for commands. Starting with [[4.0.0-7]] the ARM11 kernel will trigger a kernelpanic() if the input/output buffers don&#039;t have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.&lt;br /&gt;
| &lt;br /&gt;
| [[4.0.0-7]]&lt;br /&gt;
| &lt;br /&gt;
| 2012&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions&lt;br /&gt;
| Originally the kernel only checked the first page(0x1000-bytes) of the src/dst buffers, for svcReadProcessMemory and svcWriteProcessMemory. There is no known retail processes which have access to these SVCs.&lt;br /&gt;
| &lt;br /&gt;
| [[4.0.0-7]]&lt;br /&gt;
| &lt;br /&gt;
| 2012?&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== [[FIRM]] Sysmodules ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in [[FIRM]] system version&lt;br /&gt;
!  Last [[FIRM]] system version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| [[Services|&amp;quot;srv:pm&amp;quot;]] process registration&lt;br /&gt;
| Originally any process had access to the port &amp;quot;srv:pm&amp;quot;. The PID&#039;s used for the (un)registration commands are not checked either. This allowed any process to re-register itself with &amp;quot;srv:pm&amp;quot;, and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.&lt;br /&gt;
&lt;br /&gt;
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] &amp;quot;srv:pm&amp;quot; is now a service instead of a globally accessible port. Only processes with PID&#039;s less than 6 (in other words: fs, ldr, sm, pm, pxi modules) have access to it. With [[7.0.0-13]] there can only be one session for &amp;quot;srv:pm&amp;quot; open at a time(this is used by pm module), svcBreak will be executed if more sessions are opened by the processes which can access this.&lt;br /&gt;
&lt;br /&gt;
This flaw was needed for exploiting the &amp;lt;=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don&#039;t have access to those service(s).&lt;br /&gt;
| Access to arbitrary services&lt;br /&gt;
| [[7.0.0-13]]&lt;br /&gt;
| &lt;br /&gt;
| 2012&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| FSDIR null-deref&lt;br /&gt;
| [[Filesystem_services|FS]]-module may crash in some cases when handling directory reading. The trigger seems to be due to using [[FSDir:Close]] without closing the dir-handle afterwards?(Perhaps this is caused by out-of-memory?) This seems to be useless since it&#039;s just a null-deref.&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[9.6.0-24|9.6.0-X]]&lt;br /&gt;
| May 19(?)-20, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Standalone Sysmodules ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in system-module system-version&lt;br /&gt;
!  Last system-module system-version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Timeframe this was added to wiki&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| AM stack/.bss infoleak via [[AM:ReadTwlBackupInfo]]([[AM:ReadTwlBackupInfoEx|Ex]])&lt;br /&gt;
| After writing the output-info structure to stack, it then copies that structure to the output buffer ptr using the size from the command. The size is not checked. This could be used to read data from the AM-service-thread stack handling the command + .bss.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This was not tested on hardware.&#039;&#039;&#039;&lt;br /&gt;
| Stack/.bss reading&lt;br /&gt;
| None&lt;br /&gt;
| [[10.0.0-27]](AM v9217)&lt;br /&gt;
| Roughly October 17, 2016&lt;br /&gt;
| October 25, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[MVD_Services|MVD]]: Stack buffer overflow with [[MVDSTD:SetupOutputBuffers]].&lt;br /&gt;
| The input total_entries is not validated when initially processing the input entry-list. This fixed-size input entry-list is copied to stack from the command request. The loop for processing this initializes a global table, the converted linearmem-&amp;gt;physaddrs used there are also copied to stack(0x8-bytes of physaddrs per entry).&lt;br /&gt;
&lt;br /&gt;
If total_entries is too large, MVD-sysmodule will crash due to reading unmapped memory following the stack(0x10000000). Afterwards if the out-of-bounds total_entries is smaller than that, it will crash due accessing address 0x0, hence this useless.&lt;br /&gt;
| MVD-sysmodule crash.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.0.0-20]]&lt;br /&gt;
| April 22, 2016 (Tested on the 25th)&lt;br /&gt;
| April 25, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[NWM_Services|NWM]]: Using CTRSDK heap with UDS sharedmem from the user-process.&lt;br /&gt;
| See the HTTP-sysmodule section below.&lt;br /&gt;
&lt;br /&gt;
CTRSDK heap is used with the sharedmem from [[NWMUDS:InitializeWithVersion]]. Buffers are allocated/freed under this heap using [[NWMUDS:Bind]] and [[NWMUDS:Unbind]].&lt;br /&gt;
&lt;br /&gt;
Hence, overwriting sharedmem with gspwn then using [[NWMUDS:Unbind]] results in the usual controlled CTRSDK memchunk-header write, similar to HTTP-sysmodule.&lt;br /&gt;
&lt;br /&gt;
This could be done by creating an UDS network, without any other nodes on the network.&lt;br /&gt;
&lt;br /&gt;
Besides CTRSDK memchunk-headers, there are no addresses stored under this sharedmem.&lt;br /&gt;
| ROP under NWM-module.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.0.0-20|9.0.0-X]]&lt;br /&gt;
| April 10, 2016&lt;br /&gt;
| April 16, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[DLP_Services|DLP]]: Out-of-bounds memory access during spectator [[Download_Play|data-frame]] checksum calculation&lt;br /&gt;
| DLP doesn&#039;t validate the frame_size when receiving spectator data-frames at all, unlike non-spectator data-frames. The actual spectator data-frame parsing code doesn&#039;t use that field either. However, the data-frame checksum calculation code called during checksum verification does use the frame_size for loading the size of the framebuf.&lt;br /&gt;
&lt;br /&gt;
Hence, using a large frame_size like 0xFFFF will result in the checksum calculation code reading data out-of-bounds. This isn&#039;t really useful, you could trigger a remote local-WLAN DLP-sysmodule crash while a 3DS system is scanning for DLP networks(due to accessing unmapped memory), but that&#039;s about all(trying to infoleak with this likely isn&#039;t useful either).&lt;br /&gt;
| DLP-sysmodule crash, handled by dlplay system-application by a &amp;quot;connection interrupted&amp;quot; error eventually then a fatal-error via ErrDisp.&lt;br /&gt;
| None&lt;br /&gt;
| [[10.0.0-27|10.0.0-X]]&lt;br /&gt;
| April 8, 2016 (Tested on the 10th)&lt;br /&gt;
| April 10, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[DLP_Services|DLP]]: Out-of-bounds output data writing during spectator sysupdate titlelist [[Download_Play|data-frame]] handling&lt;br /&gt;
| The total_entries and out_entryindex fields for the titlelist DLP spectator data-frames are not validated. This is parsed during DLP network scanning. Hence, the specified titlelist data can be written out-of-bounds using the specified out_entryindex and total_entries. A crash will occur while reading the input data-frame titlelist if total_entries is larger than 0x27A, due to accessing unmapped memory.&lt;br /&gt;
&lt;br /&gt;
There&#039;s not much non-zero data to overwrite following the output buffer(located in sharedmem), any ptrs are located in sharedmem. Overwriting certain ptr(s) are only known to cause a crash when attempting to use the DLP-client shutdown service-command.&lt;br /&gt;
&lt;br /&gt;
There&#039;s no known way to exploit the above crash, since the linked-list code involves writes zeros(with a controlled start ptr).&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[10.0.0-27|10.0.0-X]]&lt;br /&gt;
| April 8-9, 2016&lt;br /&gt;
| April 10, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[IR_Services|IR]]: Stack buffer overflow with custom hardware&lt;br /&gt;
| Originally IR sysmodule used the read value from the I2C-IR registers TXLVL and RXLVL without validating them at all. See [[10.6.0-31|here]] for the fix. This is the size used for reading the data-recv FIFO, etc. The output buffer for reading is located on the stack.&lt;br /&gt;
&lt;br /&gt;
This should be exploitable if one could successfully setup the custom hardware for this and if the entire intended sizes actually get read from I2C.&lt;br /&gt;
| ROP under IR sysmodule.&lt;br /&gt;
| [[10.6.0-31|10.6.0-31]]&lt;br /&gt;
| &lt;br /&gt;
| February 23, 2016 (Unknown if it was noticed before then)&lt;br /&gt;
| February 23, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[HTTP_Services|HTTP]]: Using CTRSDK heap with sharedmem from the user-process.&lt;br /&gt;
| The data from httpcAddPostDataAscii and other commands is stored under a CTRSDK heap. That heap is the sharedmem specified by the user-process via the HTTPC Initialize command.&lt;br /&gt;
Normally this sharedmem isn&#039;t accessible to the user-process once the sysmodule maps it, hence using it is supposed to be &amp;quot;safe&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This isn&#039;t the case due to gspwn however. Since CTRSDK heap code is so insecure in general, one can use gspwn to locate the HTTPC sharedmem + read/write it, then trigger a mem-write under the sysmodule. This can then be used to get ROP going under HTTP-sysmodule.&lt;br /&gt;
&lt;br /&gt;
This is exploited by [https://github.com/yellows8/ctr-httpwn/ctr-httpwn ctr-httpwn].&lt;br /&gt;
| ROP under HTTP sysmdule.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.6.0-24|9.6.0-X]] (Latest sysmodule version as of [[10.7.0-32|10.7.0-32]])&lt;br /&gt;
| Late 2015&lt;br /&gt;
| March 22, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[NIM_Services|NIM]]: Downloading old title-versions from eShop&lt;br /&gt;
| Multiple NIM service commands(such as [[NIMS:StartDownload]]) use a title-version value specified by the user-process, NIM does not validate that this input version matches the latest version available via SOAP. Therefore, when combined with AM(PXI) [[#Process9|title-downgrading]] via deleting the target eShop title with System Settings Data Management(if the title was already installed), this allows downloading+installing any title-version from eShop &#039;&#039;if&#039;&#039; it&#039;s still available from CDN.&lt;br /&gt;
The easiest way to exploit this is to just patch the eShop system-application code using these NIM commands(ideally the code which loads the title-version).&lt;br /&gt;
&lt;br /&gt;
Originally this was tested with a debugging-system via modded-FIRM, eventually smea implemented it in HANS for the 32c3 release.&lt;br /&gt;
| Downloading old title-versions from eShop&lt;br /&gt;
| None&lt;br /&gt;
| [[10.0.0-27|10.0.0-X]]&lt;br /&gt;
| October 24, 2015 (Unknown when exactly the first eShop title downgrade was actually tested, maybe November)&lt;br /&gt;
| January 7, 2016 (Same day Ironfall v1.0 was removed from CDN via the main-CXI files)&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SPI_Services|SPI]] service out-of-bounds write&lt;br /&gt;
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.&lt;br /&gt;
| &lt;br /&gt;
| None&lt;br /&gt;
| [[9.5.0-22]]&lt;br /&gt;
| March 2015&lt;br /&gt;
| &lt;br /&gt;
| [[User:Plutooo|plutoo]]&lt;br /&gt;
|-&lt;br /&gt;
| [[NFC_Services|NFC]] module service command buf-overflows&lt;br /&gt;
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it&#039;s unknown if there&#039;s more commands with similar issues: &amp;quot;nfc:dev&amp;quot; &amp;lt;0x000C....&amp;gt; and &amp;quot;nfc:s&amp;quot; &amp;lt;0x0037....&amp;gt;.&lt;br /&gt;
Since both of these commands are stubbed in the Old3DS NFC module from the very first version(those just return an error), these issues only affect the New3DS NFC module.&lt;br /&gt;
&lt;br /&gt;
There&#039;s no known retail titles which have access to either of these services.&lt;br /&gt;
| ROP under NFC module.&lt;br /&gt;
| New3DS: None&lt;br /&gt;
| New3DS: [[9.5.0-22]]&lt;br /&gt;
| December 2014?&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[News_Services|NEWSS]] service command notificationID validation failure&lt;br /&gt;
| This module does not validate the input notificationID for &amp;lt;nowiki&amp;gt;&amp;quot;news:s&amp;quot;&amp;lt;/nowiki&amp;gt; service commands. This is an out-of-bounds array index bug. For example, [[NEWSS:SetNotificationHeader]] could be used to exploit news module: this copies the input data(size is properly checked) to: out = newsdb_savedata+0x10 + (someu32array[notificationID]*0x70).&lt;br /&gt;
| ROP under news module.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.7.0-25|9.7.0-X]]&lt;br /&gt;
| December 2014&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[NWMUDS:DecryptBeaconData]] heap buffer overflow&lt;br /&gt;
| input_size = 0x1E * &amp;lt;value the u8 from input_[[NWM_Services|networkstruct]]+0x1D&amp;gt;. Then input_tag0 is copied to a heap buffer. When input_size is larger than 0xFA-bytes, it will then copy input_tag1 to &amp;lt;end_address_of_previous_outbuf&amp;gt;, with size=input_size-0xFA.&lt;br /&gt;
&lt;br /&gt;
This can be triggered by either using this command directly, or by boadcasting a wifi beacon which triggers it while a 3DS system running the target process is in range, when the process is scanning for hosts to connect to. Processes will only pass tag data to this command when the wlancommID and other thing(s) match the values for the process.&lt;br /&gt;
&lt;br /&gt;
There&#039;s no known way to actually exploit this for getting ROP under NWM-module, at the time of originally adding this to the wiki. This is because the data which gets copied out-of-bounds *and* actually causes crash(es), can&#039;t be controlled it seems(with just broadcasting a beacon at least). It&#039;s unknown whether this could be exploited from just using NWMUDS service-cmd(s) directly.&lt;br /&gt;
| Without any actual way to exploit this: NWM-module DoS, resulting in process termination(process crash). This breaks *everything* involving wifi comms, a reboot is required to recover from this.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.0.0-20]]&lt;br /&gt;
| ~September 23, 2014(see the [[NWMUDS:DecryptBeaconData]] page history)&lt;br /&gt;
| August 3, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[HID_Services|HID]] module shared-mem&lt;br /&gt;
| HID module does not validate the index values in [[HID_Shared_Memory|sharedmem]](just changes index to 0 when index == maxval when updating), therefore large values will result in HID module writing HID data to arbitrary addresses.&lt;br /&gt;
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.3.0-21]]&lt;br /&gt;
| 2014?&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| gspwn&lt;br /&gt;
| GSP module does not validate addresses given to the GPU. This allows a user-mode application/applet to read/write to a large part of physical FCRAM using GPU DMA. From this, you can overwrite the .text segment of the application you&#039;re running under, and gain real code-execution from a ROP-chain. Normally applets&#039; .text([[Home Menu]], [[Internet Browser]], etc) is located beyond the area accessible by the GPU, except for [[RO_Services|CROs]] used by applets([[Internet Browser]] for example).&lt;br /&gt;
&lt;br /&gt;
FCRAM is gpu-accessible up to physaddr 0x26800000 on Old3DS, and 0x2DC00000 on New3DS. This is BASE_memregion_start(aka SYSTEM_memregion_end)-0x400000 with the default memory-layout on Old3DS/New3DS.&lt;br /&gt;
| User-mode code execution.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.6.0-24|9.6.0-X]]&lt;br /&gt;
| Early 2014&lt;br /&gt;
| &lt;br /&gt;
| smea, [[User:Yellows8|Yellows8]]/others before then&lt;br /&gt;
|-&lt;br /&gt;
| rohax&lt;br /&gt;
| Using gspwn, it is possible to overwrite a loaded [[CRO0]]/[[CRR0]] after its RSA-signature has been validated. Badly validated [[CRO0]] header leads to arbitrary read/write of memory in the ro-process. This gives code-execution in the ro module, who has access to [[SVC|syscalls]] 0x70-0x72, 0x7D.&lt;br /&gt;
&lt;br /&gt;
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.&lt;br /&gt;
| Memory-mapping syscalls.&lt;br /&gt;
| [[9.3.0-21]]&lt;br /&gt;
| [[9.4.0-21]]&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| smea, [[User:Plutooo|plutoo]] joint effort&lt;br /&gt;
|-&lt;br /&gt;
| Region free&lt;br /&gt;
| Only [[Home Menu]] itself checks gamecards&#039; region when launching them. Therefore, any application launch that is done directly with [[NS]] without signaling Home Menu to launch the app, will result in region checks being bypassed.&lt;br /&gt;
This essentially means launching the gamecard with the [[NS_and_APT_Services|&amp;quot;ns:s&amp;quot;]] service. The main way to exploit this is to trigger a FIRM launch with an application specified, either with a normal FIRM launch or a hardware [[NSS:RebootSystem|reboot]].&lt;br /&gt;
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation&lt;br /&gt;
| None&lt;br /&gt;
| Last tested with [[10.1.0-27|10.1.0-X]].&lt;br /&gt;
| June(?) 2014&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[NWM_Services|NWM]] service-cmd state null-ptr deref&lt;br /&gt;
| The NWMUDS service command code loads a ptr from .data, adds an offset to that, then passes that as the state address for the actual command-handler function. The value of the ptr loaded from .data is not checked, therefore this will cause crashes due to that being 0x0 when NWMUDS was not properly initialized.&lt;br /&gt;
It&#039;s unknown whether any NWM services besides NWMUDS have this issue.&lt;br /&gt;
| This is rather useless since it&#039;s only a crash caused by a state ptr based at 0x0.&lt;br /&gt;
| None&lt;br /&gt;
| [[9.0.0-20]]&lt;br /&gt;
| 2013?&lt;br /&gt;
| &lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== General/CTRSDK ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Successful exploitation result&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| [[NWM_Services|UDS]] beacon additional-data buffer overflow&lt;br /&gt;
| Originally CTRSDK did not validate the UDS additional-data size before using that size to copy the additional-data to a [[NWM_Services|networkstruct]]. This was eventually fixed.&lt;br /&gt;
This was discovered while doing code RE with an old dlp-module version. It&#039;s unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unknown if there&#039;s any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can&#039;t be exploited with this).&lt;br /&gt;
&lt;br /&gt;
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.&lt;br /&gt;
| Perhaps ROP, very difficult if possible with anything at all&lt;br /&gt;
| ?&lt;br /&gt;
| &lt;br /&gt;
| September(?) 2014&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| CTPK buffer overflow&lt;br /&gt;
| At offset 0x20 in CTPK is an array for each texture, each entry is 0x20-bytes. This contains a wordindex(entry+0x18) for some srcdata relative to CTPK+0, and an u8 wordsize(entry+0x14) for this data. The CTRSDK function handling this doesn&#039;t validate the size, when copying srcdata using this size to the output buffer. Applications usually have the output buffer on the stack, hence stack buffer overflow.&lt;br /&gt;
&lt;br /&gt;
While CTPK(*.ctpk) are normally only loaded from RomFS, some application(s) load from elsewhere too.&lt;br /&gt;
| ROP under the target application.&lt;br /&gt;
| None?&lt;br /&gt;
| &amp;quot;[SDK+NINTENDO:CTR_SDK-11_4_0_200_none]&amp;quot;&lt;br /&gt;
| November 14, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nedwill</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=3DS_Userland_Flaws&amp;diff=19253</id>
		<title>3DS Userland Flaws</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=3DS_Userland_Flaws&amp;diff=19253"/>
		<updated>2017-01-13T01:05:59Z</updated>

		<summary type="html">&lt;p&gt;Nedwill: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page lists vulnerabilities / exploits for 3DS applications and applets. Exploiting these initially results in ROP, from that ROP one can then for example try exploiting [[3DS_System_Flaws|system]] flaw(s).&lt;br /&gt;
&lt;br /&gt;
=Non-system applications=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Application name&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in app/system version&lt;br /&gt;
!  Last app/system version this flaw was checked for&lt;br /&gt;
!  Timeframe info related to this was added to wiki&lt;br /&gt;
!  Timeframe this vuln was discovered&lt;br /&gt;
!  Vuln discovered by&lt;br /&gt;
|-&lt;br /&gt;
| Cubic Ninja&lt;br /&gt;
| Map-data stack smash&lt;br /&gt;
| See [[Ninjhax|here]] regarding Ninjhax.&lt;br /&gt;
| None&lt;br /&gt;
| App: Initial version. System: [[10.4.0-29]].&lt;br /&gt;
| Ninjhax release&lt;br /&gt;
| July 2014&lt;br /&gt;
| [[User:smea|smea]]&lt;br /&gt;
|-&lt;br /&gt;
| The Legend of Zelda: Ocarina of Time 3D&lt;br /&gt;
| UTF-16 name string buffer overflow via unchecked u8 length field&lt;br /&gt;
| The u8 at offset 0x2C in the savefile is the character-length of the UTF-16 string at offset 0x1C. When copying this string, it&#039;s essentially a memory-copy with lenval*2, not a string-copy. This can be used to trigger buffer overflows at various locations depending on the string length.&lt;br /&gt;
* When value is &amp;gt;=0x6E it crashes when saving the saveslot, this causes a stack-smash however it normally crashes before it returns from the function which had the stack-frame overwritten.&lt;br /&gt;
* With value &amp;gt;=0x9A, it crashes via stack-smash in-game once any dialogs are opened(touching buttons on the touch-screen can trigger it too).&lt;br /&gt;
* Length value&amp;gt;=0xCD causes a crash while loading the saveslot, via a heap buffer overflow. This buf-overflow overwrites a heap memchunk following the allocated buffer. When the first 16-bits overwriting that heap memchunk is not the memchunk magic-number(0x7373), the mem-alloc code will just return a NULL ptr which later results in a crash. When the magic-number is valid, the mem-alloc code will continue to attempt to parse the memchunk, which may crash depending on the data which overwrote the memchunk. This heap code is separate from the CTRSDK heap code. Exploiting this doesn&#039;t seem to be possible: since the heap code actually verifies that the magic-number for the next/prev memchunk ptrs are correct(unlike CTRSDK), it&#039;s not possible to change those ptrs to useful arbitrary addresses outside of savedata(like with triggering a write to a c++ object ptr which later is used with a vtable func-call, this is what one would do with CTRSDK heap here).&lt;br /&gt;
&lt;br /&gt;
On March 11, 2015, an exploit using this vuln was released, that one was intended for warez/etc. The following exploit wasn&#039;t released before then mainly because doing so would (presumably) result in the vuln being fixed. The following old exploit was released on March 14, 2015: [https://github.com/yellows8/oot3dhax].&lt;br /&gt;
| None&lt;br /&gt;
| App: Initial version. System: [[10.6.0-31]].&lt;br /&gt;
| March 11, 2015&lt;br /&gt;
| Around October 22, 2012&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Super Smash Bros 3DS&lt;br /&gt;
| Buffer overflow in local-multiplayer beacon handling.&lt;br /&gt;
| See [[smashbroshax|here]].&lt;br /&gt;
| App: v1.1.3&lt;br /&gt;
| See [[smashbroshax|here]]. System: [[10.3.0-28]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| See [[smashbroshax|here]].&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Pokemon Super Mystery Dungeon&lt;br /&gt;
| Heap overflow within linear memory via unchecked save file length&lt;br /&gt;
| Pokemon Super Mystery Dungeon uses zlib compression for most of its save files, possibly due to the save files being larger than its predecessor, Gates to Infinity. When a save file is being prepared to be loaded and read from, only a 0x32000 large buffer is allocated for file reading, and a 0x3e800-large buffer for decompression is also allocated before the file is read. However, the game does not limit the size of the file read to this allocation bound, allowing for the file to overflow into the linear memory heap and into the next allocation. Since Pokemon Super Mystery Dungeon stores allocation memchunks directly before the allocation, overwriting the next memchunk with a corrupted one allows for arbitrary writes of linear heap pointers when the next buffer is allocated or arbitrary writes of any pointer within writable memory when the corrupted buffer is freed.&lt;br /&gt;
| None&lt;br /&gt;
| [[10.7.0-32]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| April 14, 2016&lt;br /&gt;
| [[User:Shinyquagsire23|Shiny Quagsire]]&lt;br /&gt;
|-&lt;br /&gt;
| VVVVVV&lt;br /&gt;
| Buffer overflow in XML save file array parsing&lt;br /&gt;
| VVVVVV utilizes several XML files (renamed with a .vvv extension) to store level save data, stats and settings. Within these XML files are several tags containing an array of data which, when parsed, is not properly checked to be of proper length for the tag being parsed from. This allows for an overflow of 16-bit array values from the location where the array is parsed. With unlock.vvv, XML data is parsed to the stack, and with level saves the heap. This allows for the pointer where the level save worldmap tag array should be parsed into to be overwritten with a stack address, allowing for ROP from within the XML array parsing function on the next level load.&lt;br /&gt;
| App: v1.1&lt;br /&gt;
| [[10.7.0-32]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| April 25, 2016&lt;br /&gt;
| [[User:Shinyquagsire23|Shiny Quagsire]]&lt;br /&gt;
|-&lt;br /&gt;
| Citizens of Earth&lt;br /&gt;
| Save file read stack smash&lt;br /&gt;
| Citizens of Earth also uses &amp;quot;XML&amp;quot; files for saves, which are actually entirely binary data (not XML at all) with no checksums. These files are read from the filesystem on to a fixed size stack buffer which leads to an incredibly trivial stack smash. When using the autosave slot for this, the save is parsed when the user selects &amp;quot;continue&amp;quot;. When using one of the dedicated save slots (1-3), the save is parsed shortly after the company splash screens fade. Note that the save is read quite high (descending) on the stack - when exploiting this, one would likely need to move SP due to almost instantly overflowing the physical stack.&lt;br /&gt;
| None&lt;br /&gt;
| [[10.7.0-32]].&lt;br /&gt;
| Time of exploit release.&lt;br /&gt;
| May 5, 2016&lt;br /&gt;
| [[User:Dazzozo|Dazzozo]]&lt;br /&gt;
|-&lt;br /&gt;
| SmileBASIC 3.x&lt;br /&gt;
| Poor parameter validation on &amp;quot;BGSCREEN&amp;quot; command&lt;br /&gt;
| The SmileBASIC &amp;quot;BGSCREEN&amp;quot; command&#039;s second parameter is not properly validated as being within range.  As a result, one can set the screen size to an absurdly large value.  This means that the &amp;quot;BGGET&amp;quot; and &amp;quot;BGPUT&amp;quot; commands can then be used on out-of-range values to read and write a significant chunk of the interpreter&#039;s address space.&lt;br /&gt;
With a series of carefully-designed BGPUT commands, one can build a ROP chain and cause it to be executed.&lt;br /&gt;
| App: 3.3.2.&lt;br /&gt;
| System: [[11.0.0-33]].&lt;br /&gt;
| July 20, 2016&lt;br /&gt;
| Around June 26, 2016&lt;br /&gt;
| slackerSnail, 12Me12, incvoid&lt;br /&gt;
Exploited by MrNbaYoh and [[User:Plutooo|plutoo]].&lt;br /&gt;
|-&lt;br /&gt;
| The Legend of Zelda: Tri Force Heroes&lt;br /&gt;
| [[3DS_System_Flaws#General.2FCTRSDK|CTRSDK]] CTPK buffer overflow combined with game&#039;s usage of SpotPass&lt;br /&gt;
| During the very first screen displayed by the game during boot(&amp;quot;Loading...&amp;quot;), just seconds after title launch, the game loads CTPK from the [[BOSS_Services|stored]] SpotPass content. Hence, this game could be exploited via the vulnerable CTRSDK CTPK code &#039;&#039;if&#039;&#039; one could get custom SpotPass data into extdata somehow(ctr-httpwn &amp;gt;=v1.2 with bosshaxx allows this).&lt;br /&gt;
&lt;br /&gt;
The code for this runs from a thread separate from the main-thread, with the stack in linearmem heap. This SpotPass handling triggers before the game ever opens the regular savedata archive. The extdata is opened at some point before this: it opens a file for checking if it exists, then immediately closes it.&lt;br /&gt;
&lt;br /&gt;
The two SpotPass URLs for this have always(?) returned HTTP 404 as of November 2016. It appears these were intended for use as textures for additional costumes(and never got used publicly), but this wasn&#039;t tested.&lt;br /&gt;
&lt;br /&gt;
This is used by [https://github.com/yellows8/ctpkpwn ctpkpwn_tfh].&lt;br /&gt;
| None&lt;br /&gt;
| App: v2.1.0&lt;br /&gt;
| November 18, 2016&lt;br /&gt;
| November 14, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Pixel Paint&lt;br /&gt;
| Buffer overflow via unchecked extdata file length&lt;br /&gt;
| Pixel Paint loads pictures saved by the user from extdatas. The file is read to a fixed size buffer but the file length remains unchecked, so with a large enough file, one can overwrite pointers in memory and gain control of the execution flow.&lt;br /&gt;
| None&lt;br /&gt;
| App: Initial version. System: [[11.2.0-35]].&lt;br /&gt;
| December 27, 2016&lt;br /&gt;
| November 5, 2016&lt;br /&gt;
| [[User:Nba_Yoh|MrNbaYoh]]&lt;br /&gt;
|-&lt;br /&gt;
| Steel Diver : Sub Wars&lt;br /&gt;
| Heap overflow / arbitrary memcpy&lt;br /&gt;
| Savefile datas are stored as key/value pairs, a large enough string key makes the game overwrite a memcpy source/destination addresses and size arguments. So one can actually memcpy a rop on the stack and gain control of the execution flow.&lt;br /&gt;
| None&lt;br /&gt;
| System: [[11.2.0-35]].&lt;br /&gt;
| December 27, 2016&lt;br /&gt;
| Around July 15, 2016&lt;br /&gt;
| [[User:Nba_Yoh|MrNbaYoh]], Vegaroxas&lt;br /&gt;
|-&lt;br /&gt;
| 1001 Spikes&lt;br /&gt;
| Buffer overflow via unchecked array-indexes in XML savefile parsing&lt;br /&gt;
| The savefiles are stored as renamed .xml files, which contain several tags with attributes like &#039;array-index=&amp;quot;array-value&amp;quot;&#039;, where both of these are converted from ASCII strings to integers as signed-int32, and the array-value given blindly written to an array inside a structure using the (unchecked) index given. With several of these attributes, one can overwrite the stack starting from the stored lr of the function that does this parsing, and write a ROP chain there. Testing used the &amp;quot;LevelAttempts&amp;quot; tag which is the last such tag parsed in that function.&lt;br /&gt;
| None&lt;br /&gt;
| App: v1.2.0 (TMD v2096)&lt;br /&gt;
| December 27, 2016&lt;br /&gt;
| Around November 2, 2016&lt;br /&gt;
| [[User:Riley|Riley]]&lt;br /&gt;
|-&lt;br /&gt;
| Pokemon Omega Ruby/Alpha Sapphire&lt;br /&gt;
| Secret base team name heap overflow&lt;br /&gt;
| When the player wants to edit the team name, it is copied over the heap, however its length is not verified. So with a large enough team name one can overwrite some pointers and get two arbitrary jumps and then get control of the execution flow.&lt;br /&gt;
| None&lt;br /&gt;
| App: 1.4. System: [[11.2.0-35]].&lt;br /&gt;
| December 30, 2016&lt;br /&gt;
| June, 2016&lt;br /&gt;
| [[User:Nba_Yoh|MrNbaYoh]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Useless crashes / applications which were fuzzed==&lt;br /&gt;
* Pushmo (3DSWare), QR codes: level name is properly limited to 16 characters, game doesn&#039;t crash with a longer name. The only possible crashes are triggered by out-of-bounds array index values, these crashes are not exploitable due to the index value being 8bit.&lt;br /&gt;
&lt;br /&gt;
* [[Pyramids (3DSWare)]], QR codes: no strings. Only crashes are from out-of-bounds values (like background ID) and are not exploitable.&lt;br /&gt;
&lt;br /&gt;
* [[Pyramids 2 (3DSWare)]], QR codes: no strings. Only crashes are from out-of-bounds values (like background ID) and are not exploitable.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/yellows8/mm3d_re The Legend of Zelda: Majora&#039;s Mask 3D]&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;The Legend of Zelda: A Link Between Worlds&amp;quot; and &amp;quot;The Legend of Zelda: Tri Force Heroes&amp;quot;: these games don&#039;t crash at all when the entire save-file(minus constant header data) is overwritten with /dev/random output / 0xFF-bytes. All of the CRC32s were updated for this of course.  Note that this refers to the regular save file: Tri Force Heroes can be exploited via BOSS extdata - see above.&lt;br /&gt;
&lt;br /&gt;
* Pokemon Mystery Dungeon: Gates to Infinity has the same unchecked file bounds as Pokemon Super Mystery Dungeon, however since save compression was introduced in Pokemon Super Mystery Dungeon, it only allocates one buffer within the application heap instead of several within the linear heap, resulting in nothing to corrupt or overwrite even if the file&#039;s length is extended past its allocation.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Kid Icarus: Uprising&amp;quot;: Overwriting the entire savedata results in various crashes, nothing useful.&lt;br /&gt;
&lt;br /&gt;
* Savedata/extdata for &amp;quot;Super Smash Bros 3DS&amp;quot;: Overwriting the various files stored under savedata/extdata results in useless crashes.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;StarFox 64 3D&amp;quot;: Doesn&#039;t crash at all with the entire savedata overwritten.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Frogger 3D&amp;quot;: Overwriting a savefile with random-data results in *nothing* crashing.&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Mutant Mudds&amp;quot;: Overwriting the savefile with random data results in a crash&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;Animal Crossing: New Leaf&amp;quot;: Creating a QR code from random data results in a valid QR code and a random design. In some very rare cases(which aren&#039;t always reproducible?) a crash/etc may occur, but this isn&#039;t known to be useful.&lt;br /&gt;
&lt;br /&gt;
==Crashes needing investigation==&lt;br /&gt;
* Disney Infinity crashes when all savedata overwritten with /dev/urandom. No checksums. 0xFF bytes don&#039;t cause a crash.&lt;br /&gt;
&lt;br /&gt;
* Football Up Online / Soccer Up Online and Football Up 3D / Soccer Up 3D crash when teamname(UTF-16) length = 0x48 AND 0x20 null bytes are removed after just the name or if teamname length is way longer than 0x48.&lt;br /&gt;
&lt;br /&gt;
=System applications=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| 3DS [[System Settings]] DS profile string stack-smash&lt;br /&gt;
| Too long or corrupted strings (01Ah  2   Nickname length in characters     050h  2   Message length in characters) in the NVRAM DS user settings (System Settings-&amp;gt;Other Settings-&amp;gt;Profile-&amp;gt;Nintendo DS Profile) cause it to crash in 3DS-mode due to a stack-smash. The DSi is not vulnerable to this, DSi launcher(menu) and DSi System Settings will reset the NVRAM user-settings if the length field values are too long(same result as when the CRCs are invalid). TWL_FIRM also resets the NVRAM user-settings when the string-length(s) are too long.&lt;br /&gt;
| [[7.0.0-13]]&lt;br /&gt;
| [[7.0.0-13]]&lt;br /&gt;
| 2012&lt;br /&gt;
| [[User:Ichfly|Ichfly]]&lt;br /&gt;
|-&lt;br /&gt;
| [[Nintendo 3DS Sound]]&lt;br /&gt;
| &amp;quot;A heap overflow in tag processing leads to code execution when a specially- crafted m4a file is loaded by Nintendo 3DS Sound.&amp;quot; (description from soundhax&#039;s github readme)&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35]]&lt;br /&gt;
| June/July 2016&lt;br /&gt;
| [[User:nedwill|nedwill]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=System applets=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Introduced with version&lt;br /&gt;
!  Timeframe info related to this was added to wiki&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| Webkit/web-browser bugs&lt;br /&gt;
| spider has had at least three different code-execution exploits. Majority of them are use-after-free issues. See also [[browserhax|here]].&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
| &lt;br /&gt;
| 2013?&lt;br /&gt;
|&lt;br /&gt;
| A lot of people.&lt;br /&gt;
|-&lt;br /&gt;
| Old3DS/New3DS [[Internet_Browser|Browser-version-check]] bypass&lt;br /&gt;
| When the browser-version-check code runs where the savedata for it was never initialized(such as when the user used the &amp;quot;Initialize savedata&amp;quot; option), it will use base_timestamp=0 instead of the timestamp loaded from savedata. This is then used with &amp;quot;if(cur_timestamp - base_timestamp &amp;gt;= &amp;lt;24h timestamp&amp;gt;){Run browser-version-check HTTPS request code}&amp;quot;.&lt;br /&gt;
Hence, if the savedata was just initialized, and if the system datetime is set to before January 2, 2000, the browser-version-check will be skipped. This includes January 1, 2000, 00:00, because that&#039;s the epoch(timestamp value 0x0) used with this timestamp.&lt;br /&gt;
&lt;br /&gt;
See [http://yls8.mtheall.com/3dsbrowserhax.php here] for bypass usage instructions.&lt;br /&gt;
&lt;br /&gt;
This was fixed with [[10.7.0-32|10.7.0-32]], see [[Internet_Browser|here]] for details.&lt;br /&gt;
| [[10.7.0-32|10.7.0-32]]&lt;br /&gt;
| &lt;br /&gt;
| [[9.9.0-26|9.9.0-26]]&lt;br /&gt;
| February 25, 2016&lt;br /&gt;
| November 2, 2015 (Exactly one week after the browser version pages were initially updated server-side)&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Home Menu==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  Summary&lt;br /&gt;
!  Description&lt;br /&gt;
!  Fixed in version&lt;br /&gt;
!  Last version this flaw was checked for&lt;br /&gt;
!  Introduced with version&lt;br /&gt;
!  Timeframe info related to this was added to wiki&lt;br /&gt;
!  Timeframe this was discovered&lt;br /&gt;
!  Discovered by&lt;br /&gt;
|-&lt;br /&gt;
| bossbannerhax&lt;br /&gt;
| After successfully loading [[Extended_Banner|extended-banner]] data(done when selecting an icon), Home Menu attempts to load &amp;quot;[[CBMD]]&amp;quot; data into a 0x100000-byte heap buffer from the [[BOSS_Services|stored]] SpotPass content. When successful and the magic-number is CBMD, Home Menu then decompresses the exbanner sections into another fixed-size heap buffer, without checking the outsize at all. The main CBMD CGFX code with ExeFS checks the size, but this code doesn&#039;t(however this is exbanner &amp;quot;CBMD&amp;quot;, not a &amp;quot;normal&amp;quot; CBMD).&lt;br /&gt;
&lt;br /&gt;
Used with menuhax as of v3.2.&lt;br /&gt;
| None&lt;br /&gt;
| [[11.2.0-35|11.2.0-X]]&lt;br /&gt;
| [[1.0.0-0|1.0.0-0]]&lt;br /&gt;
| November 18, 2016&lt;br /&gt;
| December 23, 2014&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| sdiconhax&lt;br /&gt;
| This is basically the same as nandiconhax, the vulnerable SD/NAND functions are &#039;&#039;identical&#039;&#039; minus the file-buffer offsets. Exploitation is different due to different heap-buffer location though. Unlike nandiconhax, the icon buffer for SD is located in linearmem(with recent Home Menu versions at least). This is used by [[menuhax]].&lt;br /&gt;
| [[11.1.0-34|11.1.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| [[4.0.0-7|4.0.0-X]]&lt;br /&gt;
| July 27, 2016&lt;br /&gt;
| October 23, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| [[System_SaveData|NAND-savedata]] Launcher.dat icons (nandiconhax)&lt;br /&gt;
| The homemenu code processing the titleid list @ launcherdat+8 copies those titleIDs to another buffer, where the offset relative to that buffer is calculated using the corresponding s8/s16 entries. Those two values are not range checked at all. Hence, one can use this to write u64(s) with arbitrary values to before/after this allocated output buffer. See [[Home_Menu|here]] regarding Launcher.dat structure.&lt;br /&gt;
&lt;br /&gt;
This can be exploited(with Launcher.dat loading at startup at least) by using a s16 for the icon entry with value 0xFFEC(-20)(and perhaps more icons with similar s16 values to write multiple u64s). The result is that the u64 value is written to outbuf-0xA0, which overwrites object+0(vtable) and object+4(doesn&#039;t matter here) for an object that gets used a bit after the vulnerable function triggers. The low 32bits of the u64 can then be set to the address of controlled memory(either outbuf in regular heap or the entire launcherdat buffer in linearmem), for use as a fake vtable in order to get control of PC. From there one can begin ROP via vtable funcptrs to do a stack-pivot(r4=objectaddr at the time the above object gets used).&lt;br /&gt;
&lt;br /&gt;
Originally this vuln could only be triggered via Launcher.dat at Home Menu startup, right after Launcher.dat gets loaded + memory gets allocated, once the file-format version code is finished running. Starting with v9.6 this can be triggered when loading layouts from SD extdata as well. The vuln itself triggers before the layout data is written to Launcher.dat, but it doesn&#039;t seem to be possible to overwrite anything which actually gets used before the function which writes Launcher.dat into the layout gets called.&lt;br /&gt;
&lt;br /&gt;
Home Menu has some sort of fail-safe system(or at least on v9.7) when Home Menu crashes due to Launcher.dat(this also applies for other things with Home Menu): after crashing once, Home Menu resets Launcher.dat to a state where it no longer crashes anymore. However, note that any exploits using this which hang/etc without crashing will still brick the system. &#039;&#039;&#039;Hence, attempting anything with this on physnand without hw-nand-access isn&#039;t really recommended.&#039;&#039;&#039;&lt;br /&gt;
| [[11.1.0-34|11.1.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| [[4.0.0-7|4.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| May 14, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Theme-data decompression buffer overflow ([[menuhax|themehax]])&lt;br /&gt;
| The only func-call size parameter used by the theme decompression function is one for the compressed size, none for the decompressed size. The decompressed-size value from the LZ header is used by this function to check when to stop decompressing, but this function itself has nothing to verify the decompressed_size with. The code calling this function does not check or even use the decompressed size from the header either.&lt;br /&gt;
&lt;br /&gt;
This function is separate from the rest of the Home Menu code: the function used for decompressing themes is *only* used for decompressing themes, nothing else. There&#039;s a separate decompression function in Home Menu used for decompressing everything else.&lt;br /&gt;
&lt;br /&gt;
That other decompression function in Home Menu handles decompression size properly(decompressed size check for max buffer size is done by code calling the other function, not in the function itself). Unlike the other function, the theme function supports multiple LZ algorithms, but the one which actually gets used in official themes is the same one supported by the other function anyway.&lt;br /&gt;
&lt;br /&gt;
See also [[menuhax|here]].&lt;br /&gt;
&lt;br /&gt;
With [[10.2.0-28|10.2.0-X]] Home Menu, the only code change was that the following was added right after theme-load and before actual decompression: &amp;quot;if(&amp;lt;get_lzheader_decompressed_size&amp;gt;(compressed_buf) &amp;gt; 0x150000)&amp;lt;exit&amp;gt;;&amp;quot;. This fixed the vuln.&lt;br /&gt;
| [[10.2.0-28|10.2.0-X]]&lt;br /&gt;
| [[10.2.0-28|10.2.0-X]]&lt;br /&gt;
| &amp;lt;Old3DS/New3DS version which added initial theme support&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| December 22, 2014&lt;br /&gt;
| [[User:Yellows8|Yellows8]], [[User:Myria|Myria]] independently (~spring 2015)&lt;br /&gt;
|-&lt;br /&gt;
| Shuffle body-data buffer overflow ([[menuhax|shufflehax]])&lt;br /&gt;
| See [[menuhax|here]].&lt;br /&gt;
| [[10.6.0-31|10.6.0-X]]&lt;br /&gt;
| [[10.6.0-31|10.6.0-X]]&lt;br /&gt;
| [[9.3.0-21|9.3.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| January 3, 2015&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|-&lt;br /&gt;
| Extdata file-data loading buffer overflow&lt;br /&gt;
| The extdata file-reading code allocates a fixed-size heap buffer for the expected filesize, then reads the filedata into this buffer using the actual FS filesize. Before v5.0 the filesize used here wasn&#039;t validated, hence if the filesize is larger than alloc_size a buffer overflow would occur. &#039;&#039;After&#039;&#039; doing the file-read it does validate that the actual_readsize matches the alloc_size, but at this point the buffer overflow has already occurred.&lt;br /&gt;
&lt;br /&gt;
This affected at least the following: SaveData.dat and Cache.dat.&lt;br /&gt;
&lt;br /&gt;
This can be triggered with SaveData.dat by installing a &amp;lt;v4.0 Home Menu version, with Home Menu extdata from &amp;gt;=v4.0 still on SD. When this is done with v2.0 Home Menu, a kernelpanic occurs when processing an AM command(it appears a buffer ptr which is then passed to a command was overwritten with 0x0 - of course other SaveData.dat filesizes may result in different behaviour).&lt;br /&gt;
| [[5.0.0-11|5.0.0-X]]&lt;br /&gt;
| &lt;br /&gt;
| [[2.0.0-2|2.0.0-X]]&lt;br /&gt;
| June 9, 2016&lt;br /&gt;
| June 9, 2016&lt;br /&gt;
| [[User:Yellows8|Yellows8]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The icon data arrays used with {sd/nand}iconhax were added to SaveData.dat/Launcher.dat with [[4.0.0-7|4.0.0-X]], hence the vulnerable functions were added with that same version.&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;=v4.0 the SaveData.dat buffer is located in the regular heap. It&#039;s unknown when exactly it was moved to linearmem, which is where it&#039;s located with recent versions. It&#039;s located in linearmem for KOR &amp;gt;=v9.6 for example.&lt;br /&gt;
&lt;br /&gt;
The SaveData.dat/Launcher.dat icon vulns were fixed by doing various unsigned &amp;gt;=60/&amp;gt;=360 checks on the loaded values. When these checks fail, it just skips over handling this icon entry. Hence, the original value can&#039;t be negative / out-of-bounds any more.&lt;br /&gt;
&lt;br /&gt;
==Useless crashes==&lt;br /&gt;
Old3DS system web-browser:&lt;br /&gt;
* 2^32 characters long string(&#039;&#039;finally&#039;&#039; fixed with v10.6): this is similar to the vulnerability fixed [http://git.chromium.org/gitweb/?p=external/Webkit.git;a=commitdiff;h=ec471f16fbd1f879cb631f9b022fd16acd75f4d4 here], concat-large-strings-crash2.html triggers a crash which is about the same as the one triggered by a 2^32 string. Most of the time this vulnerability will cause a memory page permissions fault, since the WebKit code attempts to copy the string text data to the output buffer located in read-only [[CRO0|CRO]] heap memory. The only difference between a crash triggered by a 2^32 string and the concat-large-strings-crash2.html crash is at the former copies the string data using the original string length(like 1 text character for &amp;quot;x&amp;quot;, 4 for &amp;quot;xxxx&amp;quot;) while the latter attempts to copy &amp;gt;12MB. In some &#039;&#039;very&#039;&#039; rare cases a thread separate from the string data-copy thread will crash, this might be exploitable. However, this is mostly useless since it rarely crashes this way.&lt;br /&gt;
&lt;br /&gt;
* Trying to directly load a page via the browser &amp;quot;URL&amp;quot; option with [https://github.com/yellows8/3ds_browserhax_common webkitdebug] setup, causes a crash to trigger in oss.cro due to an use-after-free being caught with webkitdebug. This is presumably some sort of realloc() issue in the libcurl version used by the &amp;lt;={v10.2-v10.3} browser. This happens with *every* *single* *page* one tries to load via the &amp;quot;URL&amp;quot; option, but not when loading links on the current page, hence this is probably useless. A different use-after-free with realloc triggers with loading any page at all regardless of method too(libcurl probably).&lt;br /&gt;
&lt;br /&gt;
* This WebKit build has &#039;&#039;a lot&#039;&#039; of crash-trigger bugs that only happen with [https://github.com/yellows8/3ds_browserhax_common webkitdebug] completely setup(addr accesses near 0x0), with &#039;&#039;just&#039;&#039; trying to load any page at all.&lt;/div&gt;</summary>
		<author><name>Nedwill</name></author>
	</entry>
</feed>