https://www.3dbrew.org/w/api.php?action=feedcontributions&user=Derrek&feedformat=atom3dbrew - User contributions [en]2024-03-29T09:38:46ZUser contributionsMediaWiki 1.35.8https://www.3dbrew.org/w/index.php?title=11.8.0-41&diff=2079711.8.0-412018-08-03T20:42:57Z<p>Derrek: </p>
<hr />
<div>The Old3DS+New3DS 11.8.0-41 system update was released on July 30, 2018. This Old3DS+New3DS update was released for the following regions: USA, EUR, JPN, CHN, KOR, and TWN.<br />
<br />
Security flaws fixed: <fill this in manually later, see the updatedetails page from the ninupdates-report page(s) once available for now>.<br />
<br />
==Change-log==<br />
[https://en-americas-support.nintendo.com/app/answers/detail/a_id/667/p/430/c/267 Official] USA change-log:<br />
* Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience<br />
<br />
==System Titles==<br />
<fill this in (manually) later><br />
<br />
=== Process9 ===<br />
Actual code changed in Process9.<br />
<br />
pxi:am9 command 0x6d0184 was added, see [[AMPXI:ExportTicketWrapped]]<br />
<br />
The anti-downgrade list was updated (versions bumped and new titles were added, such as TWL_FIRM).<br />
<br />
=== AM ===<br />
New am:net command 0x8290184 was added, see [[AMNet:ExportTicketWrapped]]. This is used by nim.<br />
<br />
=== Friends ===<br />
fpdver version string bumped to 0xC<br />
<br />
=== nim ===<br />
Added 2 new strings in the codebin: "X-Authentication-Key" and "X-Authentication-Data".<br />
<br />
Now uses [[AMNet:ExportTicketWrapped]] during code related to downloading contents(?) (function at 0x143B9C; its caller at 0x123ABC uses amnet:Begin/ResumeImportContent)<br />
<br />
If ExportTicketWrapped succeeded, then the new http headers are passed: "X-Authentication-Key" set to base64(wrapped_aes_key) and "X-Authentication-Data" set to base64(crypted_ticket).<br />
<br />
This (when activated server-side) would prevent downloading crypted contents entirely without a valid ticket.<br />
<br />
==See Also==<br />
System update report(s):<br />
* [https://yls8.mtheall.com/ninupdates/reports.php?date=07-30-18_08-00-36&sys=ctr]<br />
* [https://yls8.mtheall.com/ninupdates/reports.php?date=07-30-18_08-00-40&sys=ktr]</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=207083DS System Flaws2018-06-06T15:41:16Z<p>Derrek: good old boot9 code exec vuln</p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there'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.<br />
<br />
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).<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Fixed with hardware model/revision<br />
! Newest hardware model/revision this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| ARM9/ARM11 bootrom vectors point at uninitialized RAM<br />
| ARM9's and ARM11's exception vectors are hardcoded to point at the CPU'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. <br />
Since RAM isn't cleared on boot (see below), one can immediately start execution of their own code here to dump bootrom, OTP, etc.<br />
The ARM9 bootrom does the following at reset: reset vector branches to another instruction, then branches to bootrom+0x8000. Hence, there's no way to know for certain when exactly the ARM9 exception-vector data stored in memory gets initialized.<br />
<br />
This requires *very* *precise* timing for triggering the hardware fault.<br />
<br />
It has been exploited by derrek to dump the ARM9 bootrom as of Summer 2015.<br />
| None: all available 3DS models at the time of writing have the exact same ARM9/ARM11 bootrom for the unprotected areas.<br />
| New3DS<br />
| End of February 2014<br />
| [[User:Derrek|derrek]], WulfyStylez (May 2015) independently<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
| None<br />
| New3DS<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No RAM clearing on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM/VRAM keeps its contents.<br />
| None<br />
| New3DS<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| 32bits of actual console-unique TWLNAND keydata<br />
| 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's highest bit is always ORed. only 31 bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.<br />
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).<br />
| None<br />
| New3DS<br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| None<br />
| New3DS<br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| 3DS key-generator<br />
| 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.<br />
<br />
Several such pairs of matching normal-keys and KeyY values were found, leading to deducing the key-generator function.<br />
| None<br />
| New3DS<br />
| February 2015<br />
| [[User:Yellows8|Yellows8]], [[User:Plutooo|plutoo]]<br />
|-<br />
| FIRM partitions known-plaintext<br />
| The [[Flash_Filesystem|FIRM partitions]] are encrypted with AES-CTR without a MAC. Since this works by XOR'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.<br />
<br />
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).<br />
However it is most commonly used to install arbitrary FIRMs (usually boot9strap), thanks to sighax.<br />
<br />
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.<br />
| None<br />
| New3DS<br />
| <br />
| Everyone<br />
|-<br />
| RSA keyslots don't clear exponent when setting modulus<br />
| 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.<br />
<br />
However, when setting a keyslot's modulus, the RSA hardware leaves the exponent alone. This allows retrieving the exponent by doing a discrete logarithm of the output.<br />
<br />
By setting the modulus to a prime number whose modular multiplicative order is "smooth" (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.<br />
<br />
This exploit'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.<br />
| None<br />
| New3DS<br />
| March 2016<br />
| [[User:Myria|Myria]]<br />
|-<br />
| Boot9 AES keyinit function issues<br />
| [[Bootloader|Boot9]] seems to have two bugs in the AES key-init function, see [[AES_Registers#AES_key-init|here]].<br />
| None<br />
| BootROM issue.<br />
| 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[CONFIG11_Registers#CFG11_GPUPROT|CFG11_GPUPROT]] allowing acccess to AXIWRAM/FCRAM-BASE-memregion<br />
| [[CONFIG11_Registers#CFG11_GPUPROT|CFG11_GPUPROT]] can be configured by anything with access to it to allow the GPU to access the entire AXIWRAM+FCRAM. For example, this is an issue for any sysmodule that gets exploited and has access to this register memory-page(include one that's listed below).<br />
<br />
See also "kernelhax via gspwn" below.<br />
| None<br />
| New3DS<br />
| February 7, 2017<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| sighax: Boot9 improper PKCS #1 v1.5 signature validation<br />
| The [[Flash_Filesystem|FIRM partitions]] are signed with RSA-2048 using SHA-256 and PKCS #1 v1.5 padding. Boot9, however, does improper validation of the padding in three ways:<br />
# Boot9 permits block type 02, meant for encrypted messages, to be used for signatures. Only 01, for signatures, should have been permitted. As a result, a signature block is not required to have a long string of FF bytes as padding, but rather any random values suffice. While correct for encryption, this severely lessens security of signatures.<br />
# Boot9 does not require that the length of the padding fill out the signature block completely. As a result, there is considerable freedom in the layout of a signature.<br />
# Boot9 fails to do bounds checking in its parsing of the DER-encoded hash algorithm type and hash value; the length values given in DER are permitted to point outside the signature block.<br />
Flaw 3 allows the DER encoding to be such that boot9 believes that the signature's hash value is outside the range of the block itself, somewhere on the stack. This can be pointed at the correct hash value it computes. Boot9 then memcmp's the calculated hash against itself, and thinks that the hash is valid.<br />
<br />
When all three flaws are combined, a brute force in a reasonable amount of time can find a signature that passes all checks.<br />
| None<br />
| New3DS<br />
| July 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| Boot9 FIRM loading doesn't blacklist memory-mapped I/O<br />
| [[Bootloader|Boot9]]'s FIRM loading blacklists Boot9 data regions, but forgets to do other important regions, including Memory-mapped I/O. Combined with sighax, by loading a malicious FIRM section to MMIO, one can get Boot9/Boot11 code execution. <br />
| None<br />
| New3DS<br />
| 2015(?)<br />
| [[User:Derrek|derrek]] (2015?), [[User:Normmatt|Normmatt]] and [[User:SciresM|SciresM]] independently (January 2017).<br />
|-<br />
| "superhax": Boot9 FIRM loading blacklist check is flawed<br />
| Boot9 only makes sure the '''start''' and '''end''' address of each section is not covered by a blacklisted region. Thus, it is possible to overwrite blacklisted regions (e.g. ARM9 Exception Vectors) by choosing a FIRM section range that encloses an entire blacklisted region. The vulnerable code looks like this: if(blRegions[i].start <= sectionStart && blRegions[i].end > sectionStart <nowiki>||</nowiki> blRegions[i].start <= sectionEnd && blRegions[i].end > sectionEnd) return false; // failure<br />
| None<br />
| New3DS<br />
| August 2015<br />
| [[User:Plutoo|plutoo]], [[User:Yellows8|yellows8]]<br />
|}<br />
<br />
== ARM9 software ==<br />
<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Public disclosure timeframe<br />
! Discovered by<br />
|-<br />
| Generating the keysector console-unique keys with ITCM+Boot9<br />
| [[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 ''exact'' ''same'' region hashed by arm9loader when generating the console-unique keys for decrypting the keysector, except arm9loader uses the raw encrypted OTP.<br />
<br />
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's keysector. This can even be done for Old3DS which doesn't have the arm9loader keysector officially.<br />
<br />
It's unknown why arm9loader only used the first 0x90-bytes of OTP. Using more data from OTP would've prevented this. Fixing this would require doing exactly that, but that would also mean updating the NAND keysector(which is dangerous).<br />
| See description.<br />
| None<br />
| <br />
| 2015<br />
| January 6, 2017<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Rearrangable keys in the NAND keystore<br />
| Due to the keystore being encrypted with AES-ECB, one can rearrange blocks and still have the NAND keystore decrypt in a deterministic way. <br />
<br />
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.<br />
| arm9loaderhax given existing ARM9 code execution<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| Early 2016<br />
| 27 September 2016<br />
| Myria, [[User:Dark samus|dark_samus]]; mathieulh (independently); [[User:Plutooo|plutoo]] (independently) + others<br />
|-<br />
| Uncleared OTP hash keydata in console-unique 0x11 key-generation<br />
| 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.<br />
<br />
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.<br />
<br />
This can be performed by exploiting the "arm9loaderhax" 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 <[[3.0.0-6|3.0.0-X]].<br />
<br />
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.<br />
| Derivation of all New3DS keys generated via the NAND keystore (0x1B "Secure4" etc.)<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| ~April 2015, implemented in May 2015<br />
| 13 January 2016<br />
| [[User:WulfyStylez|WulfyStylez]], [[User:Dazzozo|Dazzozo]], [[User:Shinyquagsire23|shinyquagsire23]] (complimentary + implemented), [[User:Plutooo|plutoo]], Normmatt (discovered independently)<br />
|-<br />
| enhanced-arm9loaderhax<br />
| See the 32c3 3ds talk.<br />
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'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.<br />
| arm9loaderhax which automatically occurs at hard-boot.<br />
| See arm9loaderhax / description.<br />
| See arm9loaderhax / description.<br />
| Theorized around mid July, 2015. Later implemented+tested by [[User:Plutooo|plutoo]] and [[User:Derrek|derrek]].<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Missing verification-block for the 9.6 keys (arm9loaderhax)<br />
| 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.<br />
<br />
Writing an incorrect key to NAND will cause arm9loader to decrypt the ARM9 kernel as garbage and then jump to it.<br />
<br />
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'll find some garbage that jumps to your code.<br />
<br />
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. <br />
<br />
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.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key, access to uncleared OTP hash keydata<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| March, 2015<br />
| <br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Public disclosure timeframe<br />
! Discovered by<br />
|-<br />
| Leak of normal-key matching a key-scrambler key<br />
| 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 "fixed" 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.<br />
<br />
Nintendo'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 "Hardware" above), the key scrambler function could be deduced.<br />
| Deducing the keyX for keyslot 0x39 and the key scrambler algorithm<br />
| New 3DS [[9.3.0-21|9.3.0-X]], sort of<br />
| [[10.0.0-27|10.0.0-X]]<br />
| Sometime in 2015 after the hardware key-generator was broken.<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Leak of normal-key matching a key-generator key<br />
| During the 3DS' 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.<br />
<br />
<br />
Knowing the keyY and the normal-key for common-key index1, the devkit key-generator algorithm can be deduced (see "Hardware" above). Additionally the remaining devkit common-keys can be generated once the common-key keyX is recovered.<br />
<br />
Note the devkit key-generator was discovered to be the same as the retail key-generator.<br />
| Deducing the keyX for keyslot 0x3D and hardware key-generator algorithm. Generate remaining devkit common-keys.<br />
| pre-[[1.0.0-0|1.0.0-X]]<br />
| <br />
| Shortly after the key-generator was revealed to be flawed at the 32c3 3ds talk<br />
| January 20, 2016<br />
| [[User:Jakcron|jakcron]]<br />
|-<br />
| Factory firmware is vulnerable to sighax<br />
| During the 3DS's development, presumably boot9 was written (including the sighax) vulnerability. This vulnerability is also present in factory firmware (and earlier, including 0.11). This was fixed in version 1.0.0-0.<br />
| Deducing the mechanics of the sighax vulnerability in boot9 without having boot9 prot. Arm9 code execution on factory/earlier firmware.<br />
| [[1.0.0-0|1.0.0-X]]<br />
| [[1.0.0-0|1.0.0-X]]<br />
| May 9, 2017<br />
| May 19, 2017<br />
| [[User:SciresM|SciresM]], [[User:Myria|Myria]]<br />
|-<br />
| safefirmhax<br />
| SAFE_MODE_FIRM is almost never updated(even when NATIVE_FIRM is updated for vuln fixes), this can be noticed by ''just'' checking 3dbrew/ninupdates title-listings.<br />
<br />
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 <=> Kernel11 sync, PXI sync and then repeat the original attack on SAFE_FIRM instead.<br />
| ARM9 code execution<br />
| [[11.3.0-36|11.3.0-X]]<br />
| <br />
| 2012-2013?<br />
| Wiki: January 2, 2017<br />
| Everyone<br />
|-<br />
| safefirmhax 1.1<br />
| Nintendo's original safefirmhax fix was flawed -- they added a global boolean that got set to true whenever a non-sysmodule title got launched (except for a hardcoded repair title id), and panic()'d if that boolean was true to prevent launching safefirm after hax was active. However, because the boolean was initially false after firmlaunch -- With ARM11-kernel execution, one could FIRM-launch into NATIVE_FIRM, and then immediately FIRM-launch again into SAFE_FIRM early in NATIVE_FIRM boot before the boolean got set to true to repeat the safehax attack.<br />
<br />
This was fixed by adding additional CFG9_BOOTENV checks to firmlaunch code in 11.4.<br />
| ARM9 code execution<br />
| [[11.4.0-37|11.4.0-X]]<br />
| <br />
| safefirmhax fix<br />
| Wiki: April 10, 2017<br />
| Everyone<br />
|-<br />
| ntrcardhax<br />
| When reading the banner of a NTR title, Process9 relies on a hardware register to know when the banner was fully read.<br />
However that register is shared between the ARM9 and the ARM11.<br />
An attacker with k11 control can so make Process9 believe the banner continues forever and so trigger a buffer overflow.<br />
With a custom banner for a NTR flashcart, this leads to code execution in Process9.<br />
<br />
This was fixed by adding bound checks on the read data.<br />
| ARM9 code execution<br />
| [[10.4.0-29|10.4.0-X]]<br />
| <br />
| March 2015<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| Title downgrading via [[Application_Manager_Services|AM]]([[Application_Manager_Services_PXI|PXI]])<br />
| 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.<br />
<br />
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't compare the input title-version with anything. Hence, titles can be downgraded this way.<br />
<br />
[[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.<br />
| Bypassing title version check at installation, which then allows downgrading any title.<br />
| [[11.0.0-33|11.0.0-X]], for key system titles.<br />
| NATIVE_FIRM / AM-sysmodule [[11.0.0-33|11.0.0-X]]<br />
| ?<br />
| <br />
| ?<br />
|-<br />
| FAT FS code null-deref<br />
| 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't check for NULL which then triggers a read based at NULL.<br />
<br />
Sample "fsck.vfat -n -v -V <fat image backup>" output for the above crash:<br />
<br />
<pre>...<br />
Starting check/repair pass.<br />
<FilePath0> and<br />
<FilePath1><br />
share clusters.<br />
Truncating second to 3375104 bytes.<br />
<FilePath1><br />
File size is 2787392 bytes, cluster chain length is 16384 bytes.<br />
Truncating file to 16384 bytes.<br />
Checking for unused clusters.<br />
Reclaimed 1 unused cluster (16384 bytes).<br />
Checking free cluster summary.<br />
Free cluster summary wrong (1404490 vs. really 1404491)<br />
Auto-correcting.<br />
Starting verification pass.<br />
Checking for unused clusters.<br />
Leaving filesystem unchanged.</pre><br />
| Useless null-based-read<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| July 8-9, 2015<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
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't really a problem here because there's proper padding check code which is executed prior to this.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ValidateDSiWareSectionMAC]] [[AES_Registers|AES]] keyslot reuse<br />
| When the input DSiWare section index is higher than <max number of DSiWare sections supported by this FIRM>, 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 >=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's unknown whether a timing attack would work with this.<br />
This is basically a different form of the pxips9 keyslot vuln, except with AESMAC etc.<br />
| See description.<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| March 15, 2015<br />
| December 29, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| pxips9 [[AES_Registers|AES]] keyslot reuse<br />
| 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 <=10.1.0-X(see 32c3 3ds talk).<br />
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't return any errors, Process9 will just continue to do crypto with whatever AES keyslot was selected before the PS command was sent.<br />
| Reusing the previously used keyslot, for crypto with PS.<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| Roughly the same time(same day?) as firmlaunch-hax.<br />
| December 29, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for (PXI) command replies<br />
| 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.<br />
Certain ARM11 service commands have this same issue as well.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is useless, unless one can obtain the console-unique movable.sed keyY which encrypts the entire DSiWare .bin.<br />
| 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.<br />
| None.<br />
| 11.6.0-X<br />
| April 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| movable.sed keyY vulnerable to brute-force<br />
| Half of the movable.sed keyY's 128 bits are leaked through the [[Nandrw/sys/LocalFriendCodeSeed_B|LFCS]], which is available in userland and below. The LFCS itself also leaks almost half of the remaining bits by following the ratio: u32 keyY[3]=1/5(LFCS). The remaining keyY[3] uncertainty of about ±2000 can be greatly reduced by plotting expected error margins with several keyYs. This results in a final uncertainty of about 2^40, easily within practical brute force range of an average modern PC.<br />
| Knowing the keyY of a given 3ds allows for modification of DSiWare export contents, and chained with several other public vulns, ultimately arm9 execution.<br />
| None.<br />
| 11.6.0-X<br />
| December 2017<br />
| January 2018<br />
| zoogie<br />
|-<br />
| Improper validation of DSiWare title SRLs<br />
| The 3DS does not verify if the actual SRL embedded in the title's directory matches the titleID in the TMD before launching it or importing it from an sd DSiWare export. <br />
| This allows embedding older, exploitable DSiWare titles in completely different, unexploitable DSiWare titles. Since DSiWare has raw NAND RW, this can result in arm9 control through FIRM known-plaintext and sighax attacks.<br />
| None.<br />
| 11.6.0-X<br />
| 2015?<br />
| December 2016<br />
| Everyone<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| <br />
| [[User:Plutooo|plutoo]]/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| <br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]], maybe others(?)<br />
|}<br />
<br />
=== Kernel9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9<br />
| 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's never locked, you can dump it once you get ARM9 code execution.<br />
<br />
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).<br />
<br />
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 -> 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.<br />
| Dumping of the [[OTP Registers|OTP]] area<br />
| [[3.0.0-5|3.0.0-X]]<br />
|<br />
| February 2015<br />
| [[User:Plutooo|plutoo]], Normmatt independently<br />
|}<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC|svcSetProcessIdealProcessor]] reference count overflow and therefore use-after-free.<br />
| The SVC receive two arguments: handle and idealprocessor. The handle is used to get the KProcess object and the KProcess->refCnt gets incremented,later the function check if the KProcess->mem_type != BASE and if yes, it checks for idealprocessor == 2 or idealprocessor != 3. The problem here is that if you pass the idealprocessor = 3 it won't meet any condition and return the error 0xD9001BEA without decrement the reference count. <br />
It can be abused to overflow the KProcess reference count that will lead to an Use-after-free. <br />
| Before [[11.2.0-35|11.2.0-X]]: reference count overflow and therefore use-after-free.<br />
| <br />
| [[11.6.0-39|11.6.0-X]]<br />
| November 2, 2017<br />
| [[User:st4rk|st4rk]]<br />
|-<br />
| [[SVC|svcGetThreadList]] process reference leak<br />
| When given a valid process handle (including <code>0xFFFF8001</code>), svcGetThreadList forgets to decrement the reference count of the underlying [[KProcess]] instance, after having finished using it.<br />
| Before [[11.2.0-35|11.2.0-X]]: reference count overflow and therefore use-after-free, but this UAF was most likely not exploitable<br />
| <br />
| [[11.3.0-36|11.3.0-X]]<br />
| April 3, 2017<br />
| [[User:TuxSH|TuxSH]]<br />
|-<br />
| kernelhax via gspwn<br />
| Originally the kernel didn't initialize [[CONFIG11_Registers#CFG11_GPUPROT|CFG11_GPUPROT]]. Since it's 0 at hard-boot, this allowed the GPU to access the entire FCRAM + AXIWRAM.<br />
| Entire FCRAM+AXIWRAM R/W.<br />
| [[3.0.0-5|3.0.0-X]]<br />
| <br />
| February 7, 2017<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] partly<br />
|-<br />
| fasthax<br />
| 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.<br />
| See description.<br />
| [[11.3.0-36|11.3.0-X]]<br />
| [[11.3.0-36|11.3.0-X]]<br />
| May 2016<br />
| nedwill<br />
|-<br />
| ipctakeover<br />
| 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.<br />
<br />
Used by ctr-httpwn as of v1.2, for "ipctakeover/bosshaxx".<br />
<br />
This can be used to takeover processes where the process is using your service session. Like HTTPC -> BOSS, for bosshaxx above. NIM takeover can be done too(actual stack buffer overflow can trigger), etc.<br />
| See description.<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| November 26, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Using IPC input buffers as output buffers<br />
| 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.<br />
<br />
Used by ctr-httpwn as of v1.2, for "ipctakeover/bosshaxx".<br />
| See description.<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| November 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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.<br />
| See description<br />
| [[11.0.0-33|11.0.0-X]] (deleted)<br />
| <br />
|<br />
| Everyone<br />
|-<br />
| veryslowpidhax<br />
| '''This is completely different from the kernelmode-code-execution vuln described in the below separate entry.'''<br />
<br />
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 <total ARM11 FIRM modules> to access ''all'' 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.<br />
<br />
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.<br />
<br />
With launching+terminating a sysmodule repeatedly with this via ns:s, it would take weeks to finish(if not at least about a month?).<br />
| Access to all [[Services_API|services]], ControlMemory on any given mem-region.<br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| 2012 maybe?<br />
| <br />
|-<br />
| slowhax/waithax<br />
| 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.<br />
| ARM11 kernel-mode code execution<br />
| [[11.2.0-35|11.2.0-X]]<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2016<br />
| nedwill, [[User:Derrek|derrek]]<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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.<br />
| <br />
| None<br />
| [[11.3.0-36|11.3.0-X]]<br />
| <br />
| <br />
|-<br />
| memchunkhax2.1<br />
| Nintendo'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.<br />
derrek'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.<br />
| ARM11 kernel code execution<br />
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.<br />
| [[11.0.0-33|11.0.0-X]]<br />
|<br />
| [[User:Derrek|derrek]], aliaspider<br />
|-<br />
| memchunkhax2<br />
| When allocating a block of memory, the "next" pointer of the [[Memory_Management#MemoryBlockHeader|memchunkhdr]] is accessed without being checked after being mapped to userland.<br />
This allows a race condition, where the process can change the next pointer just before it'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. <br />
| ARM11 kernel code execution<br />
| [[10.4.0-29|10.4.0-X]] (partially, see memchunkhax2.1)<br />
| [[10.4.0-29|10.4.0-X]]<br />
|<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| heaphax<br />
| 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.<br />
| Code execution with access to all of NS's privileges. (including downgrading) Code execution within any applet.<br />
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.<br />
| [[11.0.0-33|11.0.0-X]]<br />
| April 2015 ?<br />
| smea<br />
|-<br />
| snshax<br />
| Can force creation of Safe NS process into gspwn-able memory, allowing for takeover.<br />
| Code execution with access to all of NS's privileges. (including downgrading)<br />
| [[10.1.0-27|10.1.0-X]]<br />
| [[10.1.0-27|10.1.0-X]]<br />
| April 2015 ?<br />
| smea<br />
|-<br />
| AffinityMask/processorid validation<br />
| 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.<br />
The original code with the first 3 did the following: <br />
* if(u32_processorcount > ~0x80000001)return 0xe0e01bfd;<br />
* if(s32_processorcount > <total_cores>)return 0xd8e007fd;<br />
The following code replaced the above:<br />
* if(u32_processorcount >= <total_cores+1>)return 0xd8e007fd;<br />
In theory the latter should catch everything that the former did, so it's unknown if this was really a security issue.<br />
<br />
The svcCreateThread changes with [[10.0.0-27|10.0.0-X]] definitely did fix a security issue.<br />
* Original code: "if(s32_processorid > <total_cores>)return 0xd8e007fd;"<br />
* New code: "if(s32_processorid >= <total_cores> || s32_processorid <= -4)return 0xd8e007fd;"<br />
This fixed an off-by-one issue: if one would use processorid=total_cores, which isn't actually a valid value, svcCreateThread would accept that value on <[[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:<br />
* Old3DS: Useless kernel-mode crash due to accessing unmapped memory.<br />
* New3DS: uncontrolled data write into a kernel-mode L1 MMU-table. This isn't really useful: the data can't be controlled, and the data which gets overwritten is all-zero anyway(this isn't anywhere near MMU L1 entries for actually mapped memory).<br />
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'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)).<br />
| Nothing useful<br />
| [[10.0.0-27|10.0.0-X]]<br />
| [[10.0.0-27|10.0.0-X]]<br />
| svcCreateThread issue: May 31, 2015. The rest: September 8, 2015, via v9.6->v10.0 ARM11-kernel code-diff.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| memchunkhax<br />
| 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.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs<br />
| The ARM11-kernel did access the 'key' 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:<br />
SlabHeap_free(KLinkedListNode);<br />
KObject *obj = KLinkedListNode->key; // the object there might have changed!<br />
This bug appeared all over the place.<br />
| ARM11-kernelmode code exec maybe<br />
| [[8.0.0-18|8.0.0-18]]<br />
| <br />
| April 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| FSDIR null-deref<br />
| [[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's just a null-deref.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| May 19(?)-20, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SM]] out-of-bounds BSS write (table 1 entry too small)<br />
| After accepting a new session, [[SM]] writes a (handler ID (0 for srv: sessions (max. 64), 1 for the srv:pm one), pointer to session context structure in BSS) pair in a global array. However that array is only 64-entry-big instead of 65 (as it ought to be), and no bound check is done in that regard.<br />
<br />
Unfortunately, as of [[11.4.0-37]], the overwritten fields are totally unused after their initialization by <code>__libc_init_array</code>.<br />
| Not currently exploitable<br />
| None<br />
| [[11.4.0-37]]<br />
|<br />
|<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Timeframe this was added to wiki<br />
! Discovered by<br />
|-<br />
| [[MP:SendDataFrame]] missing input array index validation<br />
| [[MP:SendDataFrame]] doesn't validate the input index at cmdreq[1], unless the function for flag=non-zero is executed. This is used to calculate the following, without validating the index at all: someptr = stateptr + (index*0x924) + somestateoffset.<br />
<br />
After validating some flags from someptr, when input_flag=0 the input buffer data is copied to someptr+someotheroffset+0x14 with the u16 size loaded from someptr+someotheroffset.<br />
<br />
With a large input index someptr could be setup to be at a <target address>, for overwriting memory.<br />
<br />
This is probably difficult to exploit.<br />
| <br />
| None<br />
| [[8.0.0-18]](MP-sysmodule v2048)<br />
| January 22, 2017<br />
| January 22, 2017<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[MP_Services|MP]] cmd1 out-of-bounds handle read<br />
| MP-sysmodule handles the input parameter for cmd1 as a s32. It checks for >=16, but not <0. With <16 it basically does the following(array of entries 4-bytes each): *outhandle = ((Handle*)(stateptr+offsetinstate))[inputindex].<br />
<br />
Hence, this can be used to load any handle in MP-sysmodule memory. MP doesn't really have any service handles of interest however(can be obtained from elsewhere too).<br />
| Reading any handle in MP-sysmodule memory.<br />
| None<br />
| [[8.0.0-18]](MP-sysmodule v2048)<br />
| January 21, 2017<br />
| January 22, 2017<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| AM stack/.bss infoleak via [[AM:ReadTwlBackupInfo]]([[AM:ReadTwlBackupInfoEx|Ex]])<br />
| 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.<br />
<br />
'''This was not tested on hardware.'''<br />
| Stack/.bss reading<br />
| None<br />
| [[10.0.0-27]](AM v9217)<br />
| Roughly October 17, 2016<br />
| October 25, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[MVD_Services|MVD]]: Stack buffer overflow with [[MVDSTD:SetupOutputBuffers]].<br />
| 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->physaddrs used there are also copied to stack(0x8-bytes of physaddrs per entry).<br />
<br />
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.<br />
| MVD-sysmodule crash.<br />
| None<br />
| [[9.0.0-20]]<br />
| April 22, 2016 (Tested on the 25th)<br />
| April 25, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]]: Using CTRSDK heap with UDS sharedmem from the user-process.<br />
| See the HTTP-sysmodule section below.<br />
<br />
CTRSDK heap is used with the sharedmem from [[NWMUDS:InitializeWithVersion]]. Buffers are allocated/freed under this heap using [[NWMUDS:Bind]] and [[NWMUDS:Unbind]].<br />
<br />
Hence, overwriting sharedmem with gspwn then using [[NWMUDS:Unbind]] results in the usual controlled CTRSDK memchunk-header write, similar to HTTP-sysmodule.<br />
<br />
This could be done by creating an UDS network, without any other nodes on the network.<br />
<br />
Besides CTRSDK memchunk-headers, there are no addresses stored under this sharedmem.<br />
| ROP under NWM-module.<br />
| [[11.4.0-37|11.4.0-X]]<br />
| [[9.0.0-20|9.0.0-X]]<br />
| April 10, 2016<br />
| April 16, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DLP_Services|DLP]]: Out-of-bounds memory access during spectator [[Download_Play|data-frame]] checksum calculation<br />
| DLP doesn'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'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.<br />
<br />
Hence, using a large frame_size like 0xFFFF will result in the checksum calculation code reading data out-of-bounds. This isn'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's about all(trying to infoleak with this likely isn't useful either).<br />
| DLP-sysmodule crash, handled by dlplay system-application by a "connection interrupted" error eventually then a fatal-error via ErrDisp.<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| April 8, 2016 (Tested on the 10th)<br />
| April 10, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DLP_Services|DLP]]: Out-of-bounds output data writing during spectator sysupdate titlelist [[Download_Play|data-frame]] handling<br />
| 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.<br />
<br />
There'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.<br />
<br />
There's no known way to exploit the above crash, since the linked-list code involves writes zeros(with a controlled start ptr).<br />
| <br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| April 8-9, 2016<br />
| April 10, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[IR_Services|IR]]: Stack buffer overflow with custom hardware<br />
| 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.<br />
<br />
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.<br />
| ROP under IR sysmodule.<br />
| [[10.6.0-31|10.6.0-31]]<br />
| <br />
| February 23, 2016 (Unknown if it was noticed before then)<br />
| February 23, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HTTP_Services|HTTP]]: Using CTRSDK heap with sharedmem from the user-process.<br />
| 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.<br />
Normally this sharedmem isn't accessible to the user-process once the sysmodule maps it, hence using it is supposed to be "safe".<br />
<br />
This isn'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.<br />
<br />
This is exploited by [https://github.com/yellows8/ctr-httpwn/ctr-httpwn ctr-httpwn].<br />
| ROP under HTTP sysmdule.<br />
| [[11.4.0-37|11.4.0-X]]<br />
| [[9.6.0-24|9.6.0-X]] (Latest sysmodule version as of [[10.7.0-32|10.7.0-32]])<br />
| Late 2015<br />
| March 22, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NIM_Services|NIM]]: Downloading old title-versions from eShop<br />
| 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 ''if'' it's still available from CDN.<br />
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).<br />
<br />
Originally this was tested with a debugging-system via modded-FIRM, eventually smea implemented it in HANS for the 32c3 release.<br />
| Downloading old title-versions from eShop<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| October 24, 2015 (Unknown when exactly the first eShop title downgrade was actually tested, maybe November)<br />
| January 7, 2016 (Same day Ironfall v1.0 was removed from CDN via the main-CXI files)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| <br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| December 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWMUDS:DecryptBeaconData]] heap buffer overflow<br />
| input_size = 0x1E * <value the u8 from input_[[NWM_Services|networkstruct]]+0x1D>. Then input_tag0 is copied to a heap buffer. When input_size is larger than 0xFA-bytes, it will then copy input_tag1 to <end_address_of_previous_outbuf>, with size=input_size-0xFA.<br />
<br />
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.<br />
<br />
There'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't be controlled it seems(with just broadcasting a beacon at least). It's unknown whether this could be exploited from just using NWMUDS service-cmd(s) directly.<br />
| 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.<br />
| None<br />
| [[9.0.0-20]]<br />
| ~September 23, 2014(see the [[NWMUDS:DecryptBeaconData]] page history)<br />
| August 3, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
<br />
FCRAM is gpu-accessible up to physaddr 0x26800000 on Old3DS, and 0x2D800000 on New3DS. This is BASE_memregion_start(aka SYSTEM_memregion_end)-0x400000 (0x800000 with New3DS) with the default memory-layout on Old3DS/New3DS. With [[11.3.0-36|11.3.0-X]] the cutoff now varies due to the new [[SVC]] 0x59. The New3DS "normal"(non-APPLICATION) cutoff was changed to 0x2D000000 due to the new [[SVC]] 0x59.<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| <br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| <br />
| smea, [[User:Plutooo|plutoo]] joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| Last tested with [[10.1.0-27|10.1.0-X]].<br />
| June(?) 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| CTPK buffer overflow<br />
| 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'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.<br />
<br />
While CTPK(*.ctpk) are normally only loaded from RomFS, some application(s) load from elsewhere too.<br />
| ROP under the target application.<br />
| None?<br />
| "[SDK+NINTENDO:CTR_SDK-11_4_0_200_none]"<br />
| November 14, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=FIRM&diff=19151FIRM2017-01-04T18:48:46Z<p>Derrek: /* Firmware Section Headers */</p>
<hr />
<div>This page describes the file format for the [[Title list#00040138 - System Firmware|3DS' Firmware]], it contains up to four 'sections' of data comprising the ARM9 and ARM11 kernels, and some fundamental processes. The firmware sections are not encrypted. In a nutshell, a FIRM contains all the data required to set up the ARM9 and ARM11 kernels, and basic operating functionality.<br />
<br />
The ARM9 section contains the ARM9 kernel (and loader) and the Process9 NCCH (which is the only process run in user mode on the ARM9). The ARM11 sections contain the ARM11 kernel (and loader), and various ARM11 process NCCHs. For NATIVE_FIRM/SAFE_MODE_FIRM these ARM11 processes are sm, fs, pm, loader, and pxi. Normally the 4th section is not used. The code loaded from FIRM is constantly running on the system until another FIRM is launched. The ARM11 kernel is hard-coded to always decompress the ExeFS .code of embedded ARM11 NCCHs without checking the exheader compression bit.<br />
<br />
== FIRM Header ==<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x000<br />
| 4<br />
| Magic 'FIRM'<br />
|-<br />
| 0x004<br />
| 4<br />
| Boot priority (highest value = max prio), this is normally zero.<br />
|-<br />
| 0x008<br />
| 4<br />
| ARM11 Entrypoint<br />
|-<br />
| 0x00C<br />
| 4<br />
| ARM9 Entrypoint<br />
|-<br />
| 0x010<br />
| 0x030<br />
| Reserved2<br />
|-<br />
| 0x040<br />
| 0x0C0 (0x030*4)<br />
| Firmware Section Headers<br />
|-<br />
| 0x100<br />
| 0x100<br />
| RSA-2048 signature of the FIRM header's SHA-256 hash. The signature is checked when bootrom/Process9 are doing FIRM-launch (with the public key being hardcoded in each). The signature is not checked when installing FIRM to the NAND firm0/firm1 partitions.<br />
|}<br />
<br />
== Firmware Section Headers ==<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x000<br />
| 4<br />
| Byte offset<br />
|-<br />
| 0x004<br />
| 4<br />
| Physical address where the section is loaded to.<br />
|-<br />
| 0x008<br />
| 4<br />
| Byte-size. While loading FIRM this is the field used to determine whether the section exists or not, by checking for value 0x0.<br />
|-<br />
| 0x00C<br />
| 4<br />
| Copy-method (0 = NDMA, 1 = Corelink DMA, 2 = CPU mem-copy), Process9 ignores this field.<br />
|-<br />
| 0x010<br />
| 0x020<br />
| SHA-256 Hash of Firmware Section<br />
|}<br />
<br />
== [[New_3DS]] FIRM ==<br />
For New3DS firmwares (NATIVE_FIRM, TWL_FIRM, ..), the ARM9 FIRM binary has an additional layer of crypto. At the end of each ARM9 binary, there's a plaintext loader. The format of the FIRM header is identical to regular 3DS FIRM(the RSA modulo is the same as regular 3DS too).<br />
<br />
Before checking [[CONFIG_Registers|CFG_SYSPROT9]] the loader main() does the following:<br />
* On [[9.5.0-22|9.5.0-X]]: executes a nop instruction with r0=0 and r1=<address of arm9binhdr+0x50>.<br />
* Clears bit6 in [[AES_Registers|REG_AESKEYCNT]].<br />
<br />
If [[CONFIG_Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit 1 is clear (which means the OTP area is unlocked and so it knows that this is a hard reboot), it does the following things:<br />
* Clears 0x200-bytes on the stack, then reads [[Flash_Filesystem|NAND]] sector 0x96(NAND image offset 0x12C00), with size 0x200-bytes into that stack buffer.<br />
* Checks [[CONFIG_Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit 1 again, if it's set then it executes a panic function(set r0-r2=0, execute nop instruction, then execute instruction "bkpt 0x99").<br />
* Hashes data from the OTP region [[IO_Registers|0x10012000-0x10012090]] using SHA256 via the [[SHA_Registers|SHA]] hardware.<br />
* Clears bit6 in [[AES_Registers|REG_AESKEYCNT]]. Initializes AES keyslot 0x11 keyX, keyY to the lower and higher portion of the above hash, respectively. Due to the above hashed data, the keyX+keyY here are console-unique.<br />
* Decrypts the first 0x10-byte block in the above read NAND sector with keyslot 0x11 using AES-ECB. [[9.6.0-24|9.6.0-X]]: Then it decrypts the 0x10-bytes at offset 0x10 in the sector with keyslot 0x11.<br />
* Then the normalkey, keyX, and keyY, for keyslot 0x11 are cleared to zero. Runs the TWL key-init/etc code which was originally in the ARM9-kernel, then writes 0x2 to [[CONFIG_Registers|CFG_SYSPROT9]] to disable the OTP area.<br />
* Then it uses the above decrypted block from sector+0 to set the normalkey for keyslot 0x11. Decrypts arm9_bin_buf+0 using keyslot 0x11 with AES-ECB, and initialises keyX for keyslot 0x15 with it.<br />
* [[9.6.0-24|9.6.0-X]]: Then it uses the above decrypted block from sector+0 to set the normalkey for keyslot 0x11. Decrypts a 0x10-byte block from arm9loader .(ro)data using keyslot 0x11 with AES-ECB, and initializes keyX for keyslot 0x18 with it(same block as previous versions).<br />
* [[9.6.0-24|9.6.0-X]]: Starting with this version keyslot 0x16 keyX init was moved here, see below for details on this. The code for this is same as [[9.5.0-22|9.5.0-X]], except the decrypted normalkey from sector+0x10 is used for keyslot 0x11 instead.<br />
* Initialises KeyX for keyslots 0x18..0x1F(0x19..0x1F with [[9.6.0-24|9.6.0-X]]) with the output of decrypting a 0x10-byte block with AES-ECB using keyslot 0x11. This block was changed to a new one separate from keyslot 0x18, starting with [[9.6.0-24|9.6.0-X]]. The last byte in this 0x10-byte input block is increased by 0x01 after initializing each keyslot. Before doing the crypto each time, the loader sets the normal-key for keyslot 0x11 to the plaintext normalkey from sector+0(+0x10 with [[9.6.0-24|9.6.0-X]]). These are New3DS-specific keys.<br />
* [[9.5.0-22|9.5.0-X]](moved to above with [[9.6.0-24|9.6.0-X]]): Sets the normal-key for keyslot 0x11 to the same one already decrypted on the stack. Decrypts the 0x10-byte block at arm9binhdr+0x60 with AES-ECB using keyslot 0x11, then sets the keyX for keyslot 0x16 to the output data.<br />
* [[9.5.0-22|9.5.0-X]]: The normalkey, keyX, and keyY, for keyslot 0x11 are then cleared to zero.<br />
<br />
When [[CONFIG_Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit 1 is set(which means this happens only when this loader runs again for firm-launch), the normalkey, keyX, and keyY, for keyslot 0x11 are cleared to zero.<br />
<br />
It sets KeyY for keyslot 0x15(0x16 with [[9.5.0-22|9.5.0-X]]) to arm9_bin_buf+16, the CTR to arm9_bin_buf+32 (both are unique for every version). It then proceeds to decrypt the binary with AES-CTR. When done, it sets the normal-key for the keyslot used for binary decryption to zeros. It then decrypts arm9_bin_buf+64 using an hardcoded keyY for keyslot 0x15([[9.5.0-22|9.5.0-X]]/[[9.6.0-24|9.6.0-X]] also uses keyslot 0x15), sets the normal-key for this keyslot to zeros again, then makes sure the output block is all zeroes. If it is, it does some cleanup then it jumps to the entrypoint for the decrypted binary. Otherwise it will clear the keyX, keyY, and normal-key for each of the keyslots initialized by this loader (on [[9.6.0-24|9.6.0-X]]+, on older versions this was bugged and cleared keys 0x00..0x07 instead of 0x18..0x1F), do cleanup(same cleanup as when the decrypted block is all-zero) then just loop forever.<br />
<br />
Thus, the ARM9 binary has the following header:<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x000<br />
| 16<br />
| Encrypted KeyX (same for all FIRM's)<br />
|-<br />
| 0x010<br />
| 16<br />
| KeyY<br />
|-<br />
| 0x020<br />
| 16<br />
| CTR<br />
|-<br />
| 0x030<br />
| 8<br />
| Size of encrypted binary, as ASCII text?<br />
|-<br />
| 0x038<br />
| 8<br />
| ?<br />
|-<br />
| 0x040<br />
| 16<br />
| Control block<br />
|-<br />
| 0x050<br />
| 16<br />
| Added with [[9.5.0-22|9.5.0-X]]. Only used for hardware debugging: a nop instruction is executed with r0=0 and r1=<address of this data>.<br />
|-<br />
| 0x060<br />
| 16<br />
| Added with [[9.5.0-22|9.5.0-X]]. Encrypted keyX for keyslot 0x16.<br />
|}<br />
<br />
Originally the padding after the header before offset 0x800(start of actual ARM9-binary) was 0xFF bytes, with [[9.5.0-22|9.5.0-X]] this was changed to 0x0.<br />
<br />
For the New3DS NATIVE_FIRM arm9-section header, the only difference between the [[8.1.0-0_New3DS]] version and the [[9.0.0-20]] version is that the keyY, CTR, and the block at 0x30 in the header were updated.<br />
<br />
===New3DS ARM9 binary loader versions===<br />
{| class="wikitable" border="1"<br />
|-<br />
! FIRM system version(s)<br />
! Description<br />
|-<br />
| [[8.1.0-0_New3DS]] - [[9.3.0-21|9.3.0-X]]<br />
| Initial version.<br />
|-<br />
| [[9.5.0-22|9.5.0-X]]<br />
| Added keyX initialization for keyslot 0x16(see above), and added code for clearing keyslot 0x11 immediately after the code finishes using keyslot 0x11. The keyslot used for arm9bin decryption was changed from 0x15 to 0x16. Added code for clearing keyslot 0x16 when control-block decryption fails. Added code for using arm9bin_hdr+0x50 with a nop instruction, at the very beginning of the main arm9-loader function. Added two new 0x10-blocks to the arm9bin-hdr.<br />
|-<br />
| [[9.6.0-24|9.6.0-X]] - [[11.2.0-35|11.2.0-X]]<br />
| See above and [[9.6.0-24|here]].<br />
|}<br />
<br />
===New3DS ARM9 kernel===<br />
The only actual code-difference for the Old3DS/New3DS ARM9-kernels' crt0, besides TWL AES / [[IO_Registers|0x10012000]] related code, is that the New3DS ARM9-kernel writes 0x1 to [[CONFIG_Registers|REG_EXTMEMCNT9]] in the crt0.<br />
<br />
===New3DS Process9===<br />
The following is all of the differences for Old3DS/New3DS Process9 with [[9.3.0-21|9.3.0-X]]:<br />
* The FIRM-launch code called at the end of the New3DS proc9 main() has different mem-range checks.<br />
* In the New3DS proc9, the v6.0/v7.0 keyinit function at the very beginning(before the original code) had additional code added for setting [[Flash_Filesystem|CTRNAND]] [[AES_Registers|keyslot]] 0x5, with keydata from .data. After setting the keyY, the keyY in .data is cleared.<br />
* In New3DS proc9, the functions for getting the gamecard crypto keyslots / NCCH keyslot can return New3DS keyslots when New3DS flags(NCSD/NCCH) are set.<br />
* The code/data for the binary near the end of arm9mem is slightly different, because of memory-region sizes.<br />
* The only difference in .data(besides the above code binary) is that the New3DS proc9 has an additional 0x10-byte block for the keyslot 0x5 keyY, see above.<br />
<br />
== Variations ==<br />
There exists different official firmwares for the 3DS: The default one (NATIVE_FIRM) is used to run all 3DS content and boots by default, while backwards compatibility is handled by TWL_FIRM and AGB_FIRM. There furthermore is a rescue mode provided by SAFE_MODE_FIRM.<br />
<br />
=== NATIVE_FIRM ===<br />
NATIVE_FIRM is the FIRM which is installed to the [[Flash_Filesystem|NAND]] firm partitions, which is loaded by bootrom.<br />
<br />
Version history:<br />
<br />
{| class="wikitable" border="1"<br />
! System version<br />
! old 3DS title version<br />
! old 3DS hex title contentID<br />
! Kernel/FIRM version (old 3DS/new 3DS)<br />
|-<br />
| [[Factory_Setup|Factory]] FIRM (titleID 00040001-00000002)<br />
| v0<br />
| 00<br />
| 2.3-0<br />
|-<br />
| Pre-1.0. Referenced in the v1.0 Home Menu NCCH plain-region.<br />
| <br />
| <br />
| 2.23-X<br />
|-<br />
| [[1.0.0-0|1.0.0]]<br />
| v432<br />
| 00<br />
| 2.27-0<br />
|-<br />
| [[1.1.0-1|1.1.0]]<br />
| v1472<br />
| 02<br />
| 2.28-0<br />
|-<br />
| [[2.0.0-2|2.0.0]]<br />
| v2516<br />
| 09<br />
| 2.29-7<br />
|-<br />
| [[2.1.0-3|2.1.0]]<br />
| v3553<br />
| 0B<br />
| 2.30-18<br />
|-<br />
| [[2.2.0-X|2.2.0]]<br />
| v4595<br />
| 0F<br />
| 2.31-40<br />
|-<br />
| [[3.0.0-5|3.0.0]]<br />
| v5647<br />
| 18<br />
| 2.32-15<br />
|-<br />
| [[4.0.0-7|4.0.0]]<br />
| v6677<br />
| 1D<br />
| 2.33-4<br />
|-<br />
| [[4.1.0-8|4.1.0]]<br />
| v7712<br />
| 1F<br />
| 2.34-0<br />
|-<br />
| [[5.0.0-11|5.0.0]]<br />
| v8758<br />
| 25<br />
| 2.35-6<br />
|-<br />
| [[5.1.0-11|5.1.0]]<br />
| v9792<br />
| 26<br />
| 2.36-0<br />
|-<br />
| [[6.0.0-11|6.0.0]]<br />
| v10833<br />
| 29<br />
| 2.37-0<br />
|-<br />
| [[6.1.0-11|6.1.0]]<br />
| v11872<br />
| 2A<br />
| 2.38-0<br />
|-<br />
| [[7.0.0-13|7.0.0]]<br />
| v12916<br />
| 2E<br />
| 2.39-4<br />
|-<br />
| [[7.2.0-17|7.2.0]]<br />
| v13956<br />
| 30<br />
| 2.40-0<br />
|-<br />
| [[8.0.0-18|8.0.0]]<br />
| v15047<br />
| 37<br />
| 2.44-6<br />
|-<br />
| [[8.1.0-0_New3DS]]<br />
|N/A<br />
|N/A<br />
| 2.45-5<br />
|-<br />
| [[9.0.0-20|9.0.0]]<br />
| v17120<br />
| 38<br />
| 2.46-0<br />
|-<br />
| [[9.3.0-21|9.3.0]]<br />
| v18182<br />
| 3F<br />
| 2.48-3<br />
|-<br />
| [[9.5.0-22|9.5.0]]<br />
| v19216<br />
| 40<br />
| 2.49-0<br />
|-<br />
| [[9.6.0-24|9.6.0]]<br />
| v20262<br />
| 49<br />
| 2.50-1<br />
|-<br />
| [[10.0.0-27|10.0.0]]<br />
| v21288<br />
| 4B<br />
| 2.50-7<br />
|-<br />
| [[10.2.0-28|10.2.0]]<br />
| v22313<br />
| 4C<br />
| 2.50-9<br />
|-<br />
| [[10.4.0-29|10.4.0]]<br />
| v23341<br />
| 50<br />
| 2.50-11<br />
|-<br />
| [[11.0.0-33|11.0.0]]<br />
| v24368<br />
| 52<br />
| 2.51-0<br />
|-<br />
| [[11.1.0-34|11.1.0]]<br />
| v25396<br />
| 56<br />
| 2.51-2<br />
|-<br />
| [[11.2.0-35|11.2.0]]<br />
| v26432<br />
| 58<br />
| 2.52-0<br />
|}<br />
<br />
The above kernel/FIRM versions are in the format: <KERNEL_VERSIONMAJOR>.<KERNEL_VERSIONMINOR>-<KERNEL_VERSIONREVISION>.<br />
<br />
=== SAFE_MODE_FIRM ===<br />
SAFE_MODE is used for running the [[System_Settings#System_Updater|System Updater]]. SAFE_MODE_FIRM and NATIVE_FIRM for the initial versions are exactly the same, except for the system core version fields.<br />
<br />
=== TWL_FIRM ===<br />
TWL_FIRM handles DS(i) backwards compatibility.<br />
<br />
The 3DS-mode ARM9 core seems to switch into DSi-mode(for running DSi-mode ARM9 code) by writing to a [[PDN]] register(this changes the memory layout to DSi-mode / etc, therefore this register poke *must* be executed from ITCM). This is the final 3DS-mode register poke before the ARM9 switches into DSi-mode. DS(i)-mode ARM7 code is run on the internal [[ARM7]] core, which is started up during TWL_FIRM boot. Trying to read from the exception-vector region(address 0x0) under this DSi-mode ARM7 seems to only return 0x00/0xFF data. Also note that this DSi-mode ARM7 runs code(stored in TWL_FIRM) which pokes some DSi-mode registers that on the DSi were used for disabling access to the DSi bootROMs, however these registers do not affect the 3DS DSi-mode ARM9/ARM7 "bootrom" region(exceptionvector region + 0x8000) at all.<br />
<br />
For shutting down the system, TWL_FIRM writes u8 value 8 to [[I2C]] MCU register 0x20. For returning to 3DS-mode, TWL_FIRM writes value 4 to that MCU register to trigger a hardware system reboot.<br />
<br />
The TWL_FIRM ARM11-process includes a TWL bootloader, see [http://dsibrew.org/wiki/Bootloader here] and [[Memory_layout#Detailed_TWL_FIRM_ARM11_Memory|here]] for details.<br />
<br />
TWL_FIRM verifies all TWL RSA padding with the following. This is different from the DSi "BIOS" code.<br />
* The first byte must be 0x0.<br />
* The second byte must be 0x1 or 0x2.<br />
* Executes a while(<value of byte at current pos in RSA message>). When the second_byte in the message is 0x1, the byte at curpos must be 0xFF(otherwise the non-zero value of the byte at curpos doesn't matter). This loop must find a zero byte before offset 0x7F in the message otherwise an error is returned.<br />
* Returns an address for msg_curpos+1.<br />
totalhashdatasize = rsasig_bytesize - above position in the message for the hashdata. The actual "totalhashdatasize" in the RSA message must be <= <expected hashdata_size>(0x74 for bootloader). The TWL_FIRM code copies the RSA "hashdata" to the output buffer, using the actual size of the RSA "hashdata".<br />
<br />
=== AGB_FIRM ===<br />
AGB_FIRM handles running GBA VC titles. The ARM9 FIRM section for TWL_FIRM and AGB_FIRM are exactly the same (for TWL_FIRM and AGB_FIRM versions which were updated with the same system-update).<br />
<br />
== FIRM Launch Parameters ==<br />
The FIRM-launch parameters structure is located at FCRAM+0, size 0x1000-bytes. The ARM11-kernel copies this structure elsewhere, then clears the 0x1000-bytes at FCRAM+0. It will not handle an existing structure at FCRAM+0 if [[CONFIG Registers#CFG_BOOTENV|CFG_BOOTENV]] is zero. The ARM9 kernel [[Configuration_Memory#0x1FF80016|writes some values]] about the boot environment to AXI WRAM during init to enable this.<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x300<br />
| 0x100<br />
| 'TLNC' block created by TWL applications, handled by NS for backwards-compatibility purposes. See [[NS#Auto-boot|here]] for more info.<br />
|-<br />
| 0x400<br />
| 0x4<br />
| Flags<br />
|-<br />
| 0x410<br />
| 0xC<br />
| This is used for overriding the FIRM_* fields in [[Configuration_Memory]], when the flag listed below is set, in the following order(basically just data-copy from here to 0x1FF80060): "FIRM_?", FIRM_VERSIONREVISION, FIRM_VERSIONMINOR, FIRM_VERSIONMAJOR, FIRM_SYSCOREVER, and FIRM_CTRSDKVERSION.<br />
|-<br />
| 0x438<br />
| 0x4<br />
| The kernel checks this field for value 0xFFFF, if it matches the kernel uses the rest of these parameter fields, otherwise FIRM-launch parameters fields are ignored by the kernel.<br />
|-<br />
| 0x43C<br />
| 0x4<br />
| CRC32, this is calculated starting at FIRM-params offset 0x400, with size 0x140(with this field cleared to zero during calculation). When invalid the kernel clears the entire buffer used for storing the FIRM-params, therefore no actual FIRM-params are handled after that.<br />
|-<br />
| 0x440<br />
| 0x10<br />
| Titleinfo [[Filesystem_services#ProgramInfo|Program Info]], used by NS during NS startup, to launch the specified title when the below flag is set.<br />
|-<br />
| 0x450<br />
| 0x10<br />
| Titleinfo [[Filesystem_services#ProgramInfo|Program Info]]. This might be used for returning to the specified title, once the above launched title terminates?<br />
|-<br />
| 0x460<br />
| 0x4<br />
| Bit0: 0 = titleinfo structure isn't set, 1 = titleinfo structure is set.<br />
|-<br />
| 0x480<br />
| 0x20<br />
| This can be set via buf1 for [[APT:SendDeliverArg]]/[[APT:StartApplication]].<br />
|-<br />
| 0x4A0<br />
| 0x10<br />
| This can be set by [[NSS:SetWirelessRebootInfo]].<br />
|-<br />
| 0x4B0<br />
| 0x14<br />
| SHA1-HMAC of the banner for TWL/NTR titles. This can be set by [[NSS:SetTWLBannerHMAC]].<br />
|-<br />
| 0x500<br />
| 0x40<br />
| This is used by [[APT:LoadSysMenuArg]] and [[APT:StoreSysMenuArg]].<br />
|-<br />
| 0xD70<br />
| 0x290<br />
| [[Config Savegame|Config]] data struct for LGY FIRM.<br />
|}<br />
<br />
Flags from offset 0x400:<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x0<br />
| 0x1<br />
| This can be used for overriding the default FCRAM [[Memory_layout|memory-regions]] allocation sizes(APPLICATION, SYSTEM, and BASE). The values for this is the same as [[Configuration_Memory#APPMEMTYPE|Configmem-APPMEMTYPE]]. Values 0-1 are handled the same way by the kernel. However for NS, 0=titleinfo structure for launching a title isn't set, while non-zero=titleinfo structure is set.<br />
|-<br />
| 0x1<br />
| 0x3<br />
| Setting bit0 here enables overriding the FIRM_* fields in [[Configuration_Memory]].<br />
|}<br />
<br />
[[Config Savegame|Config]] struct for booting LGY FIRMs from offset 0xD70:<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x0<br />
| 0x1<br />
| Config block 0x30000.<br />
|-<br />
| 0x1<br />
| 0x1<br />
| Config block 0x70001.<br />
|-<br />
| 0x2<br />
| 0x1<br />
| System language (Config block 0xA0002).<br />
|-<br />
| 0x3<br />
| 0x1<br />
| [[Cfg:SecureInfoGetRegion|Region from SecureInfo]] ("pseudo-block" 0x140000 in LGY FIRM).<br />
|-<br />
| 0x4<br />
| 0xF<br />
| [[CfgS:SecureInfoGetSerialNo|Serial number from SecureInfo]] ("pseudo-block" 0x140001 in LGY FIRM).<br />
|-<br />
| 0x13<br />
| 0x1<br />
| Config block 0x100002.<br />
|-<br />
| 0x14<br />
| 0x10<br />
| Config block 0x100003.<br />
|-<br />
| 0x24<br />
| 0x2<br />
| Config block 0x100000.<br />
|-<br />
| 0x26<br />
| 0x1<br />
| Cleared to zero.<br />
|-<br />
| 0x27<br />
| 0x1<br />
| Cleared to zero.<br />
|-<br />
| 0x28<br />
| 0x94<br />
| Config block 0x100001.<br />
|-<br />
| 0xBC<br />
| 0x2<br />
| Config block 0x50000.<br />
|-<br />
| 0xBE<br />
| 0x2<br />
| Config block 0x50001.<br />
|-<br />
| 0xC0<br />
| 0x38<br />
| Config block 0x50002.<br />
|-<br />
| 0xF8<br />
| 0x20<br />
| Config block 0x50004.<br />
|-<br />
| 0x118<br />
| 0x134<br />
| Config block 0x20000.<br />
|-<br />
| 0x24C<br />
| 0x10<br />
| Config block 0x40000.<br />
|-<br />
| 0x25C<br />
| 0x1C<br />
| Config block 0x40001.<br />
|-<br />
| 0x278<br />
| 0x4<br />
| Cleared to zero.<br />
|-<br />
| 0x27C<br />
| 0x4<br />
| Cleared to zero.<br />
|-<br />
| 0x280<br />
| 0x8<br />
| Config block 0x30001.<br />
|-<br />
| 0x288<br />
| 0x2<br />
| CRC16 over the above fields from offset 0x0, size 0x288. If not valid, LGY FIRM uses dummy data from .(ro)data.<br />
|-<br />
| 0x28A<br />
| 0x2<br />
| If non-zero, the size (below) is hardcoded (currently) to value 0x288, otherwise the size field below is used.<br />
|-<br />
| 0x28C<br />
| 0x4<br />
| Value 0x288 (size used for verifying the CRC16).<br />
|}<br />
<br />
"Cleared to zero" fields above are not read at all by LGY FIRM.</div>Derrekhttps://www.3dbrew.org/w/index.php?title=FIRM&diff=19150FIRM2017-01-04T18:45:24Z<p>Derrek: /* FIRM Header */</p>
<hr />
<div>This page describes the file format for the [[Title list#00040138 - System Firmware|3DS' Firmware]], it contains up to four 'sections' of data comprising the ARM9 and ARM11 kernels, and some fundamental processes. The firmware sections are not encrypted. In a nutshell, a FIRM contains all the data required to set up the ARM9 and ARM11 kernels, and basic operating functionality.<br />
<br />
The ARM9 section contains the ARM9 kernel (and loader) and the Process9 NCCH (which is the only process run in user mode on the ARM9). The ARM11 sections contain the ARM11 kernel (and loader), and various ARM11 process NCCHs. For NATIVE_FIRM/SAFE_MODE_FIRM these ARM11 processes are sm, fs, pm, loader, and pxi. Normally the 4th section is not used. The code loaded from FIRM is constantly running on the system until another FIRM is launched. The ARM11 kernel is hard-coded to always decompress the ExeFS .code of embedded ARM11 NCCHs without checking the exheader compression bit.<br />
<br />
== FIRM Header ==<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x000<br />
| 4<br />
| Magic 'FIRM'<br />
|-<br />
| 0x004<br />
| 4<br />
| Boot priority (highest value = max prio), this is normally zero.<br />
|-<br />
| 0x008<br />
| 4<br />
| ARM11 Entrypoint<br />
|-<br />
| 0x00C<br />
| 4<br />
| ARM9 Entrypoint<br />
|-<br />
| 0x010<br />
| 0x030<br />
| Reserved2<br />
|-<br />
| 0x040<br />
| 0x0C0 (0x030*4)<br />
| Firmware Section Headers<br />
|-<br />
| 0x100<br />
| 0x100<br />
| RSA-2048 signature of the FIRM header's SHA-256 hash. The signature is checked when bootrom/Process9 are doing FIRM-launch (with the public key being hardcoded in each). The signature is not checked when installing FIRM to the NAND firm0/firm1 partitions.<br />
|}<br />
<br />
== Firmware Section Headers ==<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x000<br />
| 4<br />
| Byte offset<br />
|-<br />
| 0x004<br />
| 4<br />
| Physical address where the section is loaded to.<br />
|-<br />
| 0x008<br />
| 4<br />
| Byte-size. While loading FIRM this is the field used to determine whether the section exists or not, by checking for value 0x0.<br />
|-<br />
| 0x00C<br />
| 4<br />
| Firmware Type ('0'=ARM9/'1'=ARM11) Process9 doesn't use this field at all.<br />
|-<br />
| 0x010<br />
| 0x020<br />
| SHA-256 Hash of Firmware Section<br />
|}<br />
<br />
== [[New_3DS]] FIRM ==<br />
For New3DS firmwares (NATIVE_FIRM, TWL_FIRM, ..), the ARM9 FIRM binary has an additional layer of crypto. At the end of each ARM9 binary, there's a plaintext loader. The format of the FIRM header is identical to regular 3DS FIRM(the RSA modulo is the same as regular 3DS too).<br />
<br />
Before checking [[CONFIG_Registers|CFG_SYSPROT9]] the loader main() does the following:<br />
* On [[9.5.0-22|9.5.0-X]]: executes a nop instruction with r0=0 and r1=<address of arm9binhdr+0x50>.<br />
* Clears bit6 in [[AES_Registers|REG_AESKEYCNT]].<br />
<br />
If [[CONFIG_Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit 1 is clear (which means the OTP area is unlocked and so it knows that this is a hard reboot), it does the following things:<br />
* Clears 0x200-bytes on the stack, then reads [[Flash_Filesystem|NAND]] sector 0x96(NAND image offset 0x12C00), with size 0x200-bytes into that stack buffer.<br />
* Checks [[CONFIG_Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit 1 again, if it's set then it executes a panic function(set r0-r2=0, execute nop instruction, then execute instruction "bkpt 0x99").<br />
* Hashes data from the OTP region [[IO_Registers|0x10012000-0x10012090]] using SHA256 via the [[SHA_Registers|SHA]] hardware.<br />
* Clears bit6 in [[AES_Registers|REG_AESKEYCNT]]. Initializes AES keyslot 0x11 keyX, keyY to the lower and higher portion of the above hash, respectively. Due to the above hashed data, the keyX+keyY here are console-unique.<br />
* Decrypts the first 0x10-byte block in the above read NAND sector with keyslot 0x11 using AES-ECB. [[9.6.0-24|9.6.0-X]]: Then it decrypts the 0x10-bytes at offset 0x10 in the sector with keyslot 0x11.<br />
* Then the normalkey, keyX, and keyY, for keyslot 0x11 are cleared to zero. Runs the TWL key-init/etc code which was originally in the ARM9-kernel, then writes 0x2 to [[CONFIG_Registers|CFG_SYSPROT9]] to disable the OTP area.<br />
* Then it uses the above decrypted block from sector+0 to set the normalkey for keyslot 0x11. Decrypts arm9_bin_buf+0 using keyslot 0x11 with AES-ECB, and initialises keyX for keyslot 0x15 with it.<br />
* [[9.6.0-24|9.6.0-X]]: Then it uses the above decrypted block from sector+0 to set the normalkey for keyslot 0x11. Decrypts a 0x10-byte block from arm9loader .(ro)data using keyslot 0x11 with AES-ECB, and initializes keyX for keyslot 0x18 with it(same block as previous versions).<br />
* [[9.6.0-24|9.6.0-X]]: Starting with this version keyslot 0x16 keyX init was moved here, see below for details on this. The code for this is same as [[9.5.0-22|9.5.0-X]], except the decrypted normalkey from sector+0x10 is used for keyslot 0x11 instead.<br />
* Initialises KeyX for keyslots 0x18..0x1F(0x19..0x1F with [[9.6.0-24|9.6.0-X]]) with the output of decrypting a 0x10-byte block with AES-ECB using keyslot 0x11. This block was changed to a new one separate from keyslot 0x18, starting with [[9.6.0-24|9.6.0-X]]. The last byte in this 0x10-byte input block is increased by 0x01 after initializing each keyslot. Before doing the crypto each time, the loader sets the normal-key for keyslot 0x11 to the plaintext normalkey from sector+0(+0x10 with [[9.6.0-24|9.6.0-X]]). These are New3DS-specific keys.<br />
* [[9.5.0-22|9.5.0-X]](moved to above with [[9.6.0-24|9.6.0-X]]): Sets the normal-key for keyslot 0x11 to the same one already decrypted on the stack. Decrypts the 0x10-byte block at arm9binhdr+0x60 with AES-ECB using keyslot 0x11, then sets the keyX for keyslot 0x16 to the output data.<br />
* [[9.5.0-22|9.5.0-X]]: The normalkey, keyX, and keyY, for keyslot 0x11 are then cleared to zero.<br />
<br />
When [[CONFIG_Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit 1 is set(which means this happens only when this loader runs again for firm-launch), the normalkey, keyX, and keyY, for keyslot 0x11 are cleared to zero.<br />
<br />
It sets KeyY for keyslot 0x15(0x16 with [[9.5.0-22|9.5.0-X]]) to arm9_bin_buf+16, the CTR to arm9_bin_buf+32 (both are unique for every version). It then proceeds to decrypt the binary with AES-CTR. When done, it sets the normal-key for the keyslot used for binary decryption to zeros. It then decrypts arm9_bin_buf+64 using an hardcoded keyY for keyslot 0x15([[9.5.0-22|9.5.0-X]]/[[9.6.0-24|9.6.0-X]] also uses keyslot 0x15), sets the normal-key for this keyslot to zeros again, then makes sure the output block is all zeroes. If it is, it does some cleanup then it jumps to the entrypoint for the decrypted binary. Otherwise it will clear the keyX, keyY, and normal-key for each of the keyslots initialized by this loader (on [[9.6.0-24|9.6.0-X]]+, on older versions this was bugged and cleared keys 0x00..0x07 instead of 0x18..0x1F), do cleanup(same cleanup as when the decrypted block is all-zero) then just loop forever.<br />
<br />
Thus, the ARM9 binary has the following header:<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x000<br />
| 16<br />
| Encrypted KeyX (same for all FIRM's)<br />
|-<br />
| 0x010<br />
| 16<br />
| KeyY<br />
|-<br />
| 0x020<br />
| 16<br />
| CTR<br />
|-<br />
| 0x030<br />
| 8<br />
| Size of encrypted binary, as ASCII text?<br />
|-<br />
| 0x038<br />
| 8<br />
| ?<br />
|-<br />
| 0x040<br />
| 16<br />
| Control block<br />
|-<br />
| 0x050<br />
| 16<br />
| Added with [[9.5.0-22|9.5.0-X]]. Only used for hardware debugging: a nop instruction is executed with r0=0 and r1=<address of this data>.<br />
|-<br />
| 0x060<br />
| 16<br />
| Added with [[9.5.0-22|9.5.0-X]]. Encrypted keyX for keyslot 0x16.<br />
|}<br />
<br />
Originally the padding after the header before offset 0x800(start of actual ARM9-binary) was 0xFF bytes, with [[9.5.0-22|9.5.0-X]] this was changed to 0x0.<br />
<br />
For the New3DS NATIVE_FIRM arm9-section header, the only difference between the [[8.1.0-0_New3DS]] version and the [[9.0.0-20]] version is that the keyY, CTR, and the block at 0x30 in the header were updated.<br />
<br />
===New3DS ARM9 binary loader versions===<br />
{| class="wikitable" border="1"<br />
|-<br />
! FIRM system version(s)<br />
! Description<br />
|-<br />
| [[8.1.0-0_New3DS]] - [[9.3.0-21|9.3.0-X]]<br />
| Initial version.<br />
|-<br />
| [[9.5.0-22|9.5.0-X]]<br />
| Added keyX initialization for keyslot 0x16(see above), and added code for clearing keyslot 0x11 immediately after the code finishes using keyslot 0x11. The keyslot used for arm9bin decryption was changed from 0x15 to 0x16. Added code for clearing keyslot 0x16 when control-block decryption fails. Added code for using arm9bin_hdr+0x50 with a nop instruction, at the very beginning of the main arm9-loader function. Added two new 0x10-blocks to the arm9bin-hdr.<br />
|-<br />
| [[9.6.0-24|9.6.0-X]] - [[11.2.0-35|11.2.0-X]]<br />
| See above and [[9.6.0-24|here]].<br />
|}<br />
<br />
===New3DS ARM9 kernel===<br />
The only actual code-difference for the Old3DS/New3DS ARM9-kernels' crt0, besides TWL AES / [[IO_Registers|0x10012000]] related code, is that the New3DS ARM9-kernel writes 0x1 to [[CONFIG_Registers|REG_EXTMEMCNT9]] in the crt0.<br />
<br />
===New3DS Process9===<br />
The following is all of the differences for Old3DS/New3DS Process9 with [[9.3.0-21|9.3.0-X]]:<br />
* The FIRM-launch code called at the end of the New3DS proc9 main() has different mem-range checks.<br />
* In the New3DS proc9, the v6.0/v7.0 keyinit function at the very beginning(before the original code) had additional code added for setting [[Flash_Filesystem|CTRNAND]] [[AES_Registers|keyslot]] 0x5, with keydata from .data. After setting the keyY, the keyY in .data is cleared.<br />
* In New3DS proc9, the functions for getting the gamecard crypto keyslots / NCCH keyslot can return New3DS keyslots when New3DS flags(NCSD/NCCH) are set.<br />
* The code/data for the binary near the end of arm9mem is slightly different, because of memory-region sizes.<br />
* The only difference in .data(besides the above code binary) is that the New3DS proc9 has an additional 0x10-byte block for the keyslot 0x5 keyY, see above.<br />
<br />
== Variations ==<br />
There exists different official firmwares for the 3DS: The default one (NATIVE_FIRM) is used to run all 3DS content and boots by default, while backwards compatibility is handled by TWL_FIRM and AGB_FIRM. There furthermore is a rescue mode provided by SAFE_MODE_FIRM.<br />
<br />
=== NATIVE_FIRM ===<br />
NATIVE_FIRM is the FIRM which is installed to the [[Flash_Filesystem|NAND]] firm partitions, which is loaded by bootrom.<br />
<br />
Version history:<br />
<br />
{| class="wikitable" border="1"<br />
! System version<br />
! old 3DS title version<br />
! old 3DS hex title contentID<br />
! Kernel/FIRM version (old 3DS/new 3DS)<br />
|-<br />
| [[Factory_Setup|Factory]] FIRM (titleID 00040001-00000002)<br />
| v0<br />
| 00<br />
| 2.3-0<br />
|-<br />
| Pre-1.0. Referenced in the v1.0 Home Menu NCCH plain-region.<br />
| <br />
| <br />
| 2.23-X<br />
|-<br />
| [[1.0.0-0|1.0.0]]<br />
| v432<br />
| 00<br />
| 2.27-0<br />
|-<br />
| [[1.1.0-1|1.1.0]]<br />
| v1472<br />
| 02<br />
| 2.28-0<br />
|-<br />
| [[2.0.0-2|2.0.0]]<br />
| v2516<br />
| 09<br />
| 2.29-7<br />
|-<br />
| [[2.1.0-3|2.1.0]]<br />
| v3553<br />
| 0B<br />
| 2.30-18<br />
|-<br />
| [[2.2.0-X|2.2.0]]<br />
| v4595<br />
| 0F<br />
| 2.31-40<br />
|-<br />
| [[3.0.0-5|3.0.0]]<br />
| v5647<br />
| 18<br />
| 2.32-15<br />
|-<br />
| [[4.0.0-7|4.0.0]]<br />
| v6677<br />
| 1D<br />
| 2.33-4<br />
|-<br />
| [[4.1.0-8|4.1.0]]<br />
| v7712<br />
| 1F<br />
| 2.34-0<br />
|-<br />
| [[5.0.0-11|5.0.0]]<br />
| v8758<br />
| 25<br />
| 2.35-6<br />
|-<br />
| [[5.1.0-11|5.1.0]]<br />
| v9792<br />
| 26<br />
| 2.36-0<br />
|-<br />
| [[6.0.0-11|6.0.0]]<br />
| v10833<br />
| 29<br />
| 2.37-0<br />
|-<br />
| [[6.1.0-11|6.1.0]]<br />
| v11872<br />
| 2A<br />
| 2.38-0<br />
|-<br />
| [[7.0.0-13|7.0.0]]<br />
| v12916<br />
| 2E<br />
| 2.39-4<br />
|-<br />
| [[7.2.0-17|7.2.0]]<br />
| v13956<br />
| 30<br />
| 2.40-0<br />
|-<br />
| [[8.0.0-18|8.0.0]]<br />
| v15047<br />
| 37<br />
| 2.44-6<br />
|-<br />
| [[8.1.0-0_New3DS]]<br />
|N/A<br />
|N/A<br />
| 2.45-5<br />
|-<br />
| [[9.0.0-20|9.0.0]]<br />
| v17120<br />
| 38<br />
| 2.46-0<br />
|-<br />
| [[9.3.0-21|9.3.0]]<br />
| v18182<br />
| 3F<br />
| 2.48-3<br />
|-<br />
| [[9.5.0-22|9.5.0]]<br />
| v19216<br />
| 40<br />
| 2.49-0<br />
|-<br />
| [[9.6.0-24|9.6.0]]<br />
| v20262<br />
| 49<br />
| 2.50-1<br />
|-<br />
| [[10.0.0-27|10.0.0]]<br />
| v21288<br />
| 4B<br />
| 2.50-7<br />
|-<br />
| [[10.2.0-28|10.2.0]]<br />
| v22313<br />
| 4C<br />
| 2.50-9<br />
|-<br />
| [[10.4.0-29|10.4.0]]<br />
| v23341<br />
| 50<br />
| 2.50-11<br />
|-<br />
| [[11.0.0-33|11.0.0]]<br />
| v24368<br />
| 52<br />
| 2.51-0<br />
|-<br />
| [[11.1.0-34|11.1.0]]<br />
| v25396<br />
| 56<br />
| 2.51-2<br />
|-<br />
| [[11.2.0-35|11.2.0]]<br />
| v26432<br />
| 58<br />
| 2.52-0<br />
|}<br />
<br />
The above kernel/FIRM versions are in the format: <KERNEL_VERSIONMAJOR>.<KERNEL_VERSIONMINOR>-<KERNEL_VERSIONREVISION>.<br />
<br />
=== SAFE_MODE_FIRM ===<br />
SAFE_MODE is used for running the [[System_Settings#System_Updater|System Updater]]. SAFE_MODE_FIRM and NATIVE_FIRM for the initial versions are exactly the same, except for the system core version fields.<br />
<br />
=== TWL_FIRM ===<br />
TWL_FIRM handles DS(i) backwards compatibility.<br />
<br />
The 3DS-mode ARM9 core seems to switch into DSi-mode(for running DSi-mode ARM9 code) by writing to a [[PDN]] register(this changes the memory layout to DSi-mode / etc, therefore this register poke *must* be executed from ITCM). This is the final 3DS-mode register poke before the ARM9 switches into DSi-mode. DS(i)-mode ARM7 code is run on the internal [[ARM7]] core, which is started up during TWL_FIRM boot. Trying to read from the exception-vector region(address 0x0) under this DSi-mode ARM7 seems to only return 0x00/0xFF data. Also note that this DSi-mode ARM7 runs code(stored in TWL_FIRM) which pokes some DSi-mode registers that on the DSi were used for disabling access to the DSi bootROMs, however these registers do not affect the 3DS DSi-mode ARM9/ARM7 "bootrom" region(exceptionvector region + 0x8000) at all.<br />
<br />
For shutting down the system, TWL_FIRM writes u8 value 8 to [[I2C]] MCU register 0x20. For returning to 3DS-mode, TWL_FIRM writes value 4 to that MCU register to trigger a hardware system reboot.<br />
<br />
The TWL_FIRM ARM11-process includes a TWL bootloader, see [http://dsibrew.org/wiki/Bootloader here] and [[Memory_layout#Detailed_TWL_FIRM_ARM11_Memory|here]] for details.<br />
<br />
TWL_FIRM verifies all TWL RSA padding with the following. This is different from the DSi "BIOS" code.<br />
* The first byte must be 0x0.<br />
* The second byte must be 0x1 or 0x2.<br />
* Executes a while(<value of byte at current pos in RSA message>). When the second_byte in the message is 0x1, the byte at curpos must be 0xFF(otherwise the non-zero value of the byte at curpos doesn't matter). This loop must find a zero byte before offset 0x7F in the message otherwise an error is returned.<br />
* Returns an address for msg_curpos+1.<br />
totalhashdatasize = rsasig_bytesize - above position in the message for the hashdata. The actual "totalhashdatasize" in the RSA message must be <= <expected hashdata_size>(0x74 for bootloader). The TWL_FIRM code copies the RSA "hashdata" to the output buffer, using the actual size of the RSA "hashdata".<br />
<br />
=== AGB_FIRM ===<br />
AGB_FIRM handles running GBA VC titles. The ARM9 FIRM section for TWL_FIRM and AGB_FIRM are exactly the same (for TWL_FIRM and AGB_FIRM versions which were updated with the same system-update).<br />
<br />
== FIRM Launch Parameters ==<br />
The FIRM-launch parameters structure is located at FCRAM+0, size 0x1000-bytes. The ARM11-kernel copies this structure elsewhere, then clears the 0x1000-bytes at FCRAM+0. It will not handle an existing structure at FCRAM+0 if [[CONFIG Registers#CFG_BOOTENV|CFG_BOOTENV]] is zero. The ARM9 kernel [[Configuration_Memory#0x1FF80016|writes some values]] about the boot environment to AXI WRAM during init to enable this.<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x300<br />
| 0x100<br />
| 'TLNC' block created by TWL applications, handled by NS for backwards-compatibility purposes. See [[NS#Auto-boot|here]] for more info.<br />
|-<br />
| 0x400<br />
| 0x4<br />
| Flags<br />
|-<br />
| 0x410<br />
| 0xC<br />
| This is used for overriding the FIRM_* fields in [[Configuration_Memory]], when the flag listed below is set, in the following order(basically just data-copy from here to 0x1FF80060): "FIRM_?", FIRM_VERSIONREVISION, FIRM_VERSIONMINOR, FIRM_VERSIONMAJOR, FIRM_SYSCOREVER, and FIRM_CTRSDKVERSION.<br />
|-<br />
| 0x438<br />
| 0x4<br />
| The kernel checks this field for value 0xFFFF, if it matches the kernel uses the rest of these parameter fields, otherwise FIRM-launch parameters fields are ignored by the kernel.<br />
|-<br />
| 0x43C<br />
| 0x4<br />
| CRC32, this is calculated starting at FIRM-params offset 0x400, with size 0x140(with this field cleared to zero during calculation). When invalid the kernel clears the entire buffer used for storing the FIRM-params, therefore no actual FIRM-params are handled after that.<br />
|-<br />
| 0x440<br />
| 0x10<br />
| Titleinfo [[Filesystem_services#ProgramInfo|Program Info]], used by NS during NS startup, to launch the specified title when the below flag is set.<br />
|-<br />
| 0x450<br />
| 0x10<br />
| Titleinfo [[Filesystem_services#ProgramInfo|Program Info]]. This might be used for returning to the specified title, once the above launched title terminates?<br />
|-<br />
| 0x460<br />
| 0x4<br />
| Bit0: 0 = titleinfo structure isn't set, 1 = titleinfo structure is set.<br />
|-<br />
| 0x480<br />
| 0x20<br />
| This can be set via buf1 for [[APT:SendDeliverArg]]/[[APT:StartApplication]].<br />
|-<br />
| 0x4A0<br />
| 0x10<br />
| This can be set by [[NSS:SetWirelessRebootInfo]].<br />
|-<br />
| 0x4B0<br />
| 0x14<br />
| SHA1-HMAC of the banner for TWL/NTR titles. This can be set by [[NSS:SetTWLBannerHMAC]].<br />
|-<br />
| 0x500<br />
| 0x40<br />
| This is used by [[APT:LoadSysMenuArg]] and [[APT:StoreSysMenuArg]].<br />
|-<br />
| 0xD70<br />
| 0x290<br />
| [[Config Savegame|Config]] data struct for LGY FIRM.<br />
|}<br />
<br />
Flags from offset 0x400:<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x0<br />
| 0x1<br />
| This can be used for overriding the default FCRAM [[Memory_layout|memory-regions]] allocation sizes(APPLICATION, SYSTEM, and BASE). The values for this is the same as [[Configuration_Memory#APPMEMTYPE|Configmem-APPMEMTYPE]]. Values 0-1 are handled the same way by the kernel. However for NS, 0=titleinfo structure for launching a title isn't set, while non-zero=titleinfo structure is set.<br />
|-<br />
| 0x1<br />
| 0x3<br />
| Setting bit0 here enables overriding the FIRM_* fields in [[Configuration_Memory]].<br />
|}<br />
<br />
[[Config Savegame|Config]] struct for booting LGY FIRMs from offset 0xD70:<br />
{| class="wikitable" border="1"<br />
|-<br />
! OFFSET<br />
! SIZE<br />
! DESCRIPTION<br />
|-<br />
| 0x0<br />
| 0x1<br />
| Config block 0x30000.<br />
|-<br />
| 0x1<br />
| 0x1<br />
| Config block 0x70001.<br />
|-<br />
| 0x2<br />
| 0x1<br />
| System language (Config block 0xA0002).<br />
|-<br />
| 0x3<br />
| 0x1<br />
| [[Cfg:SecureInfoGetRegion|Region from SecureInfo]] ("pseudo-block" 0x140000 in LGY FIRM).<br />
|-<br />
| 0x4<br />
| 0xF<br />
| [[CfgS:SecureInfoGetSerialNo|Serial number from SecureInfo]] ("pseudo-block" 0x140001 in LGY FIRM).<br />
|-<br />
| 0x13<br />
| 0x1<br />
| Config block 0x100002.<br />
|-<br />
| 0x14<br />
| 0x10<br />
| Config block 0x100003.<br />
|-<br />
| 0x24<br />
| 0x2<br />
| Config block 0x100000.<br />
|-<br />
| 0x26<br />
| 0x1<br />
| Cleared to zero.<br />
|-<br />
| 0x27<br />
| 0x1<br />
| Cleared to zero.<br />
|-<br />
| 0x28<br />
| 0x94<br />
| Config block 0x100001.<br />
|-<br />
| 0xBC<br />
| 0x2<br />
| Config block 0x50000.<br />
|-<br />
| 0xBE<br />
| 0x2<br />
| Config block 0x50001.<br />
|-<br />
| 0xC0<br />
| 0x38<br />
| Config block 0x50002.<br />
|-<br />
| 0xF8<br />
| 0x20<br />
| Config block 0x50004.<br />
|-<br />
| 0x118<br />
| 0x134<br />
| Config block 0x20000.<br />
|-<br />
| 0x24C<br />
| 0x10<br />
| Config block 0x40000.<br />
|-<br />
| 0x25C<br />
| 0x1C<br />
| Config block 0x40001.<br />
|-<br />
| 0x278<br />
| 0x4<br />
| Cleared to zero.<br />
|-<br />
| 0x27C<br />
| 0x4<br />
| Cleared to zero.<br />
|-<br />
| 0x280<br />
| 0x8<br />
| Config block 0x30001.<br />
|-<br />
| 0x288<br />
| 0x2<br />
| CRC16 over the above fields from offset 0x0, size 0x288. If not valid, LGY FIRM uses dummy data from .(ro)data.<br />
|-<br />
| 0x28A<br />
| 0x2<br />
| If non-zero, the size (below) is hardcoded (currently) to value 0x288, otherwise the size field below is used.<br />
|-<br />
| 0x28C<br />
| 0x4<br />
| Value 0x288 (size used for verifying the CRC16).<br />
|}<br />
<br />
"Cleared to zero" fields above are not read at all by LGY FIRM.</div>Derrekhttps://www.3dbrew.org/w/index.php?title=Bootloader&diff=19145Bootloader2017-01-03T12:38:54Z<p>Derrek: /* Boot Procedure */ removed wrong info</p>
<hr />
<div>The bootloader is the binary code stored in the ARM9 and ARM11 boot ROMs and hence is ran when the 3DS is powered on. It's purpose is initializing hardware and loading the [[FIRM|system firmware]] from the internal [[Flash_Filesystem|NAND memory]].<br />
<br />
Besides NATIVE_FIRM, the bootloader is also capable of booting other firmwares (such as TWL_FIRM and AGB_FIRM). However, this will result either in a japanese error-screen or a system shutdown, directly after FIRM-Launching.<br />
<br />
== Boot ROM ==<br />
Upon boot, parts of the ARM9 and ARM11 boot ROMs are protected by writing to [[CONFIG#CFG_SYSPROT9|CFG_SYSPROT9]] and [[CONFIG#CFG_SYSPROT11|CFG_SYSPROT11]], respectively. The non-protected areas of the ARM9 and ARM11 boot ROMs are identical for launch-day regular Old3DS, 2DS, and regular New3DS.<br />
<br />
== Non-NAND FIRM boot ==<br />
Boot9 can also boot from non-NAND. For this a different set of RSA pubks are used(separate pubks for retail/devunit like NAND). The spiflash FIRM image for this is also encrypted with AES-CBC using a normalkey stored in prot_boot9(separate for retail/devunit). This encryption is basically used instead of what is used for NAND-firm-partitions. This encryption is only used for the FIRM sections, the FIRM header is used raw. The AES keyslot for this is only overwritten afterwards when booting from non-NAND fails. AES keyslot 0x3F is used for this.<br />
<br />
CTR_word[0] = firmimageoffset;<br />
CTR_word[1] = outbufaddr;<br />
CTR_word[2] = readsize;<br />
CTR_word[3] = readsize;<br />
<br />
When booting from NAND fails, boot9 will then attempt to boot from Wifi SPI-flash(this only triggers when the wifi module hw is properly accessible/connected, which is normally the case). The base offset for spiflash FIRM is 0x400. Note that this region is write-protected by the spiflash.<br />
<br />
== SDMMC ==<br />
<br />
Boot9 has code implemented for using SD(HC) cards, but the input deviceids used by boot9 for those functions are hard-coded for NAND.<br />
<br />
== Boot Procedure ==<br />
<br />
* 0 seconds - unit is powered on. The ARM9 and ARM11 [[Memory_layout|bootroms]] begin execution.<br />
<br />
* 2 seconds - ARM9 bootrom attempts to initialize the NAND.<br />
**If the NAND is successfully initialized:<br />
***the ARM9 bootrom loads the [[FIRM|firmware]] stored in the NAND [[FIRM]] partition which handles booting the rest of the system (if verification for NAND firm0 fails, the ARM9 bootrom will attempt to use firm1 instead).<br />
***The ARM11 kernel loaded from FIRM then launches the [[NCCH#CXI|CXI]] ARM11 system modules loaded from FIRM (i.e. sm, fs, pm, loader, and pxi). (Note that the ARM11 kernel does not handle any encryption/RSA verification, this is handled by the [[FIRM|ARM9]].)<br />
**If the NAND cannot be initialized (i.e. the NAND chip is not connected/damaged/etc), a [[Bootloader#Error_Codes|blue error screen]] appears.<br />
<br />
* 3 seconds - all essential hardware is active.<br />
**The [[Process_Manager_Services|PM]] module launches [[NS]]<br />
**If [[Home_Menu#Auto-Boot_Function|auto-booting]] is needed, NS will [[NS#Auto-boot|auto-boot]] titles.<br />
**Otherwise, NS will instead launch [[ErrDisp]] and the [[Configuration Memory#ACTIVEMENUTID|current active menu]] via the PM module. For retail units, this menu is usually the [[Home Menu]]. Note that the PM module first launches the module dependencies when launching a process, prior to actually launching the process.<br />
**The further Home Menu startup process is described [[Home_Menu#Home_Menu_startup|here]].<br />
<br />
* 4 seconds - the LCD screens are initialized.<br />
<br />
* 7 seconds - [[Home Menu]] is fully initialized/loaded.<br />
<br />
== NAND Reads during Boot ==<br />
During a successful boot on 6.x, the bootloader (and firm) reads the following sectors from NAND (in this order):<br />
00000000 (NCSD Partition Table)<br />
<br />
Only verify 'FIRM' magic? (A second Header-read will be attempted even if everything except the magic is 0xFF...)<br />
0B130000 (FIRM Partition)<br />
0B530000 (Secondary FIRM Partition)<br />
<br />
Verify RSA signature and parse Header:<br />
0B130000 (FIRM: Header)<br />
0B130200 (FIRM: Section 1)<br />
0B163E00 (FIRM: Section 2)<br />
0B193E00 (FIRM: Section 3)<br />
<br />
00013000 .. Below is probably NATIVE_FIRM booting ..<br />
00014000<br />
00015000<br />
00016000<br />
00017000<br />
<br />
09011A00<br />
09011C00<br />
09012000<br />
09012400<br />
...<br />
<br />
== Error Codes ==<br />
When the 3DS does not find the NAND chip, the following error is displayed:<br />
<br />
[[Image:CTR_Bootrom_Error.jpg|240px]]<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Error<br />
! Description<br />
|-<br />
| <tt>00F800FE 00000000 00000000 00000200 00000000</tt><br />
| Error when having SD-card reader connected to NAND during boot.<br />
|-<br />
| <tt>00F800FE 00000000 00000000 00000400 00000000</tt><br />
| NAND not found error (?)<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000080 00800000</tt><br />
| NAND error when DAT1 was used as DAT0.<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000005 00800000</tt><br />
| NAND error when DAT2 was used as DAT0.<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000005 00000000</tt><br />
| NAND error when DAT3 was used as DAT0.<br />
|-<br />
| <tt>00F800FF F8F8FFFF FFFFFFFF 00000000 00000000</tt><br />
| Both the firm0 and firm1 partitions are corrupt (failed signature checks).<br />
|-<br />
| <tt>00F800EE FFFFFFFF FFFFFFFF 00000000 00000000</tt><br />
| [[NCSD]] header in sector 0 is corrupt (failed signature check).<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=191203DS System Flaws2017-01-02T14:53:40Z<p>Derrek: </p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there'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.<br />
<br />
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).<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Fixed with hardware model/revision<br />
! Newest hardware model/revision this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| ARM9/ARM11 bootrom vectors point at uninitialized RAM<br />
| ARM9's and ARM11's exception vectors are hardcoded to point at the CPU'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. <br />
Since RAM isn't cleared on boot (see below), one can immediately start execution of their own code here to dump bootrom, OTP, etc.<br />
The ARM9 bootrom does the following at reset: reset vector branches to another instruction, then branches to bootrom+0x8000. Hence, there's no way to know for certain when exactly the ARM9 exception-vector data stored in memory gets initialized.<br />
<br />
This requires *very* *precise* timing for triggering the hardware fault.<br />
<br />
It has been exploited by derrek to dump the ARM9 bootrom as of Summer 2015.<br />
| None: all available 3DS models at the time of writing have the exact same ARM9/ARM11 bootrom for the unprotected areas.<br />
| New3DS<br />
| End of February 2014<br />
| [[User:Derrek|derrek]], WulfyStylez (May 2015) independently<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
| None<br />
| New3DS<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No RAM clearing on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM/VRAM keeps its contents.<br />
| None<br />
| New3DS<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| 32bits of actual console-unique TWLNAND keydata<br />
| 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's highest bit is always ORed. only 31 bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.<br />
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).<br />
| None<br />
| New3DS<br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| None<br />
| New3DS<br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| 3DS key-generator<br />
| 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.<br />
<br />
Several such pairs of matching normal-keys and KeyY values were found, leading to deducing the key-generator function.<br />
| None<br />
| New3DS<br />
| February 2015<br />
| [[User:Yellows8|Yellows8]], [[User:Plutooo|plutoo]]<br />
|-<br />
| FIRM partitions known-plaintext<br />
| The [[Flash_Filesystem|FIRM partitions]] are encrypted with AES-CTR without a MAC. Since this works by XOR'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.<br />
<br />
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).<br />
<br />
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.<br />
| None<br />
| New3DS<br />
| <br />
| Everyone<br />
|}<br />
<br />
== ARM9 software ==<br />
<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Public disclosure timeframe<br />
! Discovered by<br />
|-<br />
| Rearrangable keys in the NAND keystore<br />
| Due to the keystore being encrypted with AES-ECB, one can rearrange blocks and still have the NAND keystore decrypt in a deterministic way. <br />
<br />
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.<br />
| arm9loaderhax given existing ARM9 code execution<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| Early 2016<br />
| 27 September 2016<br />
| Myria, [[User:Dark samus|dark_samus]]; mathieulh (independently); [[User:Plutooo|plutoo]] (independently) + others<br />
|-<br />
| Uncleared OTP hash keydata in console-unique 0x11 key-generation<br />
| 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.<br />
<br />
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.<br />
<br />
This can be performed by exploiting the "arm9loaderhax" 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 <[[3.0.0-6|3.0.0-X]].<br />
<br />
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.<br />
| Derivation of all New3DS keys generated via the NAND keystore (0x1B "Secure4" etc.)<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| ~April 2015, implemented in May 2015<br />
| 13 January 2016<br />
| [[User:WulfyStylez|WulfyStylez]], [[User:Dazzozo|Dazzozo]], [[User:Shinyquagsire23|shinyquagsire23]] (complimentary + implemented), [[User:Plutooo|plutoo]], Normmatt (discovered independently)<br />
|-<br />
| enhanced-arm9loaderhax<br />
| See the 32c3 3ds talk.<br />
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'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.<br />
| arm9loaderhax which automatically occurs at hard-boot.<br />
| See arm9loaderhax / description.<br />
| See arm9loaderhax / description.<br />
| Theorized around mid July, 2015. Later implemented+tested by [[User:Plutooo|plutoo]] and [[User:Derrek|derrek]].<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Missing verification-block for the 9.6 keys (arm9loaderhax)<br />
| 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.<br />
<br />
Writing an incorrect key to NAND will cause arm9loader to decrypt the ARM9 kernel as garbage and then jump to it.<br />
<br />
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'll find some garbage that jumps to your code.<br />
<br />
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. <br />
<br />
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.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key, access to uncleared OTP hash keydata<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| March, 2015<br />
| <br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Public disclosure timeframe<br />
! Discovered by<br />
|-<br />
| Leak of normal-key matching a key-scrambler key<br />
| 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 "fixed" 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.<br />
<br />
Nintendo'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 "Hardware" above), the key scrambler function could be deduced.<br />
| Deducing the keyX for keyslot 0x39 and the key scrambler algorithm<br />
| New 3DS [[9.3.0-21|9.3.0-X]], sort of<br />
| [[10.0.0-27|10.0.0-X]]<br />
| Sometime in 2015 after the hardware key-generator was broken.<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Leak of normal-key matching a key-generator key<br />
| During the 3DS' 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.<br />
<br />
<br />
Knowing the keyY and the normal-key for common-key index1, the devkit key-generator algorithm can be deduced (see "Hardware" above). Additionally the remaining devkit common-keys can be generated once the common-key keyX is recovered.<br />
<br />
Note the devkit key-generator was discovered to be the same as the retail key-generator.<br />
| Deducing the keyX for keyslot 0x3D and hardware key-generator algorithm. Generate remaining devkit common-keys.<br />
| pre-[[1.0.0-0|1.0.0-X]]<br />
| <br />
| Shortly after the key-generator was revealed to be flawed at the 32c3 3ds talk<br />
| January 20, 2016<br />
| [[User:Jakcron|jakcron]]<br />
|-<br />
| safefirmlaunchhax<br />
| The fix for firmlaunchhax 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 <=> Kernel11 sync and then repeat the original attack on SAFE_FIRM instead.<br />
| ARM9 code execution<br />
| None<br />
| <br />
| <br />
| <br />
| Everyone ([[User:Plutooo|plutoo]] has found it originally)<br />
|-<br />
| ntrcardhax<br />
| <br />
| ARM9 code execution<br />
| 10.4.0-29<br />
| <br />
| March 2015<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| Title downgrading via [[Application_Manager_Services|AM]]([[Application_Manager_Services_PXI|PXI]])<br />
| 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.<br />
<br />
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't compare the input title-version with anything. Hence, titles can be downgraded this way.<br />
<br />
[[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.<br />
| Bypassing title version check at installation, which then allows downgrading any title.<br />
| [[11.0.0-33|11.0.0-X]], for key system titles.<br />
| NATIVE_FIRM / AM-sysmodule [[11.0.0-33|11.0.0-X]]<br />
| ?<br />
| <br />
| ?<br />
|-<br />
| FAT FS code null-deref<br />
| 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't check for NULL which then triggers a read based at NULL.<br />
<br />
Sample "fsck.vfat -n -v -V <fat image backup>" output for the above crash:<br />
<br />
<pre>...<br />
Starting check/repair pass.<br />
<FilePath0> and<br />
<FilePath1><br />
share clusters.<br />
Truncating second to 3375104 bytes.<br />
<FilePath1><br />
File size is 2787392 bytes, cluster chain length is 16384 bytes.<br />
Truncating file to 16384 bytes.<br />
Checking for unused clusters.<br />
Reclaimed 1 unused cluster (16384 bytes).<br />
Checking free cluster summary.<br />
Free cluster summary wrong (1404490 vs. really 1404491)<br />
Auto-correcting.<br />
Starting verification pass.<br />
Checking for unused clusters.<br />
Leaving filesystem unchanged.</pre><br />
| Useless null-based-read<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| July 8-9, 2015<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
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't really a problem here because there's proper padding check code which is executed prior to this.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ValidateDSiWareSectionMAC]] [[AES_Registers|AES]] keyslot reuse<br />
| When the input DSiWare section index is higher than <max number of DSiWare sections supported by this FIRM>, 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 >=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's unknown whether a timing attack would work with this.<br />
This is basically a different form of the pxips9 keyslot vuln, except with AESMAC etc.<br />
| See description.<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| March 15, 2015<br />
| December 29, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| pxips9 [[AES_Registers|AES]] keyslot reuse<br />
| 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 <=10.1.0-X(see 32c3 3ds talk).<br />
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't return any errors, Process9 will just continue to do crypto with whatever AES keyslot was selected before the PS command was sent.<br />
| Reusing the previously used keyslot, for crypto with PS.<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| Roughly the same time(same day?) as firmlaunch-hax.<br />
| December 29, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for (PXI) command replies<br />
| 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.<br />
Certain ARM11 service commands have this same issue as well.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.<br />
| 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.<br />
| Unknown, probably none.<br />
| ?<br />
| April 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| <br />
| [[User:Plutooo|plutoo]]/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| <br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]], maybe others(?)<br />
|}<br />
<br />
=== Kernel9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9<br />
| 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's never locked, you can dump it once you get ARM9 code execution.<br />
<br />
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).<br />
<br />
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 -> 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.<br />
| Dumping of the [[OTP Registers|OTP]] area<br />
| [[3.0.0-5|3.0.0-X]]<br />
|<br />
| February 2015<br />
| [[User:Plutooo|plutoo]], Normmatt independently<br />
|}<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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.<br />
| See description<br />
| [[11.0.0-33|11.0.0-X]] (deleted)<br />
| <br />
|<br />
| Everyone<br />
|-<br />
| veryslowpidhax<br />
| '''This is completely different from the kernelmode-code-execution vuln described in the below separate entry.'''<br />
<br />
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 <total ARM11 FIRM modules> to access ''all'' 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.<br />
<br />
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.<br />
<br />
With launching+terminating a sysmodule repeatedly with this via ns:s, it would take weeks to finish(if not at least about a month?).<br />
| Access to all [[Services_API|services]], ControlMemory on any given mem-region.<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2012 maybe?<br />
| <br />
|-<br />
| slowhax/waithax<br />
| 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.<br />
| ARM11 kernel-mode code execution<br />
| [[11.2.0-35|11.2.0-X]]<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2016<br />
| nedwill, [[User:Derrek|derrek]]<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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.<br />
| <br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| <br />
| <br />
|-<br />
| memchunkhax2.1<br />
| Nintendo'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.<br />
derrek'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.<br />
| ARM11 kernel code execution<br />
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.<br />
| [[11.0.0-33|11.0.0-X]]<br />
|<br />
| [[User:Derrek|derrek]], aliaspider<br />
|-<br />
| memchunkhax2<br />
| When allocating a block of memory, the "next" pointer of the [[Memory_Management#MemoryBlockHeader|memchunkhdr]] is accessed without being checked after being mapped to userland.<br />
This allows a race condition, where the process can change the next pointer just before it'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. <br />
| ARM11 kernel code execution<br />
| [[10.4.0-29|10.4.0-X]] (partially, see memchunkhax2.1)<br />
| [[10.4.0-29|10.4.0-X]]<br />
|<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| heaphax<br />
| 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.<br />
| Code execution with access to all of NS's privileges. (including downgrading) Code execution within any applet.<br />
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.<br />
| [[11.0.0-33|11.0.0-X]]<br />
| April 2015 ?<br />
| smea<br />
|-<br />
| snshax<br />
| Can force creation of Safe NS process into gspwn-able memory, allowing for takeover.<br />
| Code execution with access to all of NS's privileges. (including downgrading)<br />
| [[10.1.0-27|10.1.0-X]]<br />
| [[10.1.0-27|10.1.0-X]]<br />
| April 2015 ?<br />
| smea<br />
|-<br />
| AffinityMask/processorid validation<br />
| 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.<br />
The original code with the first 3 did the following: <br />
* if(u32_processorcount > ~0x80000001)return 0xe0e01bfd;<br />
* if(s32_processorcount > <total_cores>)return 0xd8e007fd;<br />
The following code replaced the above:<br />
* if(u32_processorcount >= <total_cores+1>)return 0xd8e007fd;<br />
In theory the latter should catch everything that the former did, so it's unknown if this was really a security issue.<br />
<br />
The svcCreateThread changes with [[10.0.0-27|10.0.0-X]] definitely did fix a security issue.<br />
* Original code: "if(s32_processorid > <total_cores>)return 0xd8e007fd;"<br />
* New code: "if(s32_processorid >= <total_cores> || s32_processorid <= -4)return 0xd8e007fd;"<br />
This fixed an off-by-one issue: if one would use processorid=total_cores, which isn't actually a valid value, svcCreateThread would accept that value on <[[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:<br />
* Old3DS: Useless kernel-mode crash due to accessing unmapped memory.<br />
* New3DS: uncontrolled data write into a kernel-mode L1 MMU-table. This isn't really useful: the data can't be controlled, and the data which gets overwritten is all-zero anyway(this isn't anywhere near MMU L1 entries for actually mapped memory).<br />
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'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)).<br />
| Nothing useful<br />
| [[10.0.0-27|10.0.0-X]]<br />
| [[10.0.0-27|10.0.0-X]]<br />
| svcCreateThread issue: May 31, 2015. The rest: September 8, 2015, via v9.6->v10.0 ARM11-kernel code-diff.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| memchunkhax<br />
| 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.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs<br />
| The ARM11-kernel did access the 'key' 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:<br />
SlabHeap_free(KLinkedListNode);<br />
KObject *obj = KLinkedListNode->key; // the object there might have changed!<br />
This bug appeared all over the place.<br />
| ARM11-kernelmode code exec maybe<br />
| [[8.0.0-18|8.0.0-18]]<br />
| <br />
| April 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| FSDIR null-deref<br />
| [[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's just a null-deref.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| May 19(?)-20, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Timeframe this was added to wiki<br />
! Discovered by<br />
|-<br />
| AM stack/.bss infoleak via [[AM:ReadTwlBackupInfo]]([[AM:ReadTwlBackupInfoEx|Ex]])<br />
| 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.<br />
<br />
'''This was not tested on hardware.'''<br />
| Stack/.bss reading<br />
| None<br />
| [[10.0.0-27]](AM v9217)<br />
| Roughly October 17, 2016<br />
| October 25, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[MVD_Services|MVD]]: Stack buffer overflow with [[MVDSTD:SetupOutputBuffers]].<br />
| 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->physaddrs used there are also copied to stack(0x8-bytes of physaddrs per entry).<br />
<br />
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.<br />
| MVD-sysmodule crash.<br />
| None<br />
| [[9.0.0-20]]<br />
| April 22, 2016 (Tested on the 25th)<br />
| April 25, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]]: Using CTRSDK heap with UDS sharedmem from the user-process.<br />
| See the HTTP-sysmodule section below.<br />
<br />
CTRSDK heap is used with the sharedmem from [[NWMUDS:InitializeWithVersion]]. Buffers are allocated/freed under this heap using [[NWMUDS:Bind]] and [[NWMUDS:Unbind]].<br />
<br />
Hence, overwriting sharedmem with gspwn then using [[NWMUDS:Unbind]] results in the usual controlled CTRSDK memchunk-header write, similar to HTTP-sysmodule.<br />
<br />
This could be done by creating an UDS network, without any other nodes on the network.<br />
<br />
Besides CTRSDK memchunk-headers, there are no addresses stored under this sharedmem.<br />
| ROP under NWM-module.<br />
| None<br />
| [[9.0.0-20|9.0.0-X]]<br />
| April 10, 2016<br />
| April 16, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DLP_Services|DLP]]: Out-of-bounds memory access during spectator [[Download_Play|data-frame]] checksum calculation<br />
| DLP doesn'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'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.<br />
<br />
Hence, using a large frame_size like 0xFFFF will result in the checksum calculation code reading data out-of-bounds. This isn'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's about all(trying to infoleak with this likely isn't useful either).<br />
| DLP-sysmodule crash, handled by dlplay system-application by a "connection interrupted" error eventually then a fatal-error via ErrDisp.<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| April 8, 2016 (Tested on the 10th)<br />
| April 10, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DLP_Services|DLP]]: Out-of-bounds output data writing during spectator sysupdate titlelist [[Download_Play|data-frame]] handling<br />
| 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.<br />
<br />
There'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.<br />
<br />
There's no known way to exploit the above crash, since the linked-list code involves writes zeros(with a controlled start ptr).<br />
| <br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| April 8-9, 2016<br />
| April 10, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[IR_Services|IR]]: Stack buffer overflow with custom hardware<br />
| 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.<br />
<br />
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.<br />
| ROP under IR sysmodule.<br />
| [[10.6.0-31|10.6.0-31]]<br />
| <br />
| February 23, 2016 (Unknown if it was noticed before then)<br />
| February 23, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HTTP_Services|HTTP]]: Using CTRSDK heap with sharedmem from the user-process.<br />
| 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.<br />
Normally this sharedmem isn't accessible to the user-process once the sysmodule maps it, hence using it is supposed to be "safe".<br />
<br />
This isn'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.<br />
<br />
This is exploited by [https://github.com/yellows8/ctr-httpwn/ctr-httpwn ctr-httpwn].<br />
| ROP under HTTP sysmdule.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]] (Latest sysmodule version as of [[10.7.0-32|10.7.0-32]])<br />
| Late 2015<br />
| March 22, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NIM_Services|NIM]]: Downloading old title-versions from eShop<br />
| 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 ''if'' it's still available from CDN.<br />
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).<br />
<br />
Originally this was tested with a debugging-system via modded-FIRM, eventually smea implemented it in HANS for the 32c3 release.<br />
| Downloading old title-versions from eShop<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| October 24, 2015 (Unknown when exactly the first eShop title downgrade was actually tested, maybe November)<br />
| January 7, 2016 (Same day Ironfall v1.0 was removed from CDN via the main-CXI files)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| <br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| December 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWMUDS:DecryptBeaconData]] heap buffer overflow<br />
| input_size = 0x1E * <value the u8 from input_[[NWM_Services|networkstruct]]+0x1D>. Then input_tag0 is copied to a heap buffer. When input_size is larger than 0xFA-bytes, it will then copy input_tag1 to <end_address_of_previous_outbuf>, with size=input_size-0xFA.<br />
<br />
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.<br />
<br />
There'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't be controlled it seems(with just broadcasting a beacon at least). It's unknown whether this could be exploited from just using NWMUDS service-cmd(s) directly.<br />
| 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.<br />
| None<br />
| [[9.0.0-20]]<br />
| ~September 23, 2014(see the [[NWMUDS:DecryptBeaconData]] page history)<br />
| August 3, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
<br />
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.<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| <br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| <br />
| smea, [[User:Plutooo|plutoo]] joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| Last tested with [[10.1.0-27|10.1.0-X]].<br />
| June(?) 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| CTPK buffer overflow<br />
| 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'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.<br />
<br />
While CTPK(*.ctpk) are normally only loaded from RomFS, some application(s) load from elsewhere too.<br />
| ROP under the target application.<br />
| None?<br />
| "[SDK+NINTENDO:CTR_SDK-11_4_0_200_none]"<br />
| November 14, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=186523DS System Flaws2016-11-27T23:25:41Z<p>Derrek: </p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there's a [[SVC]] for this, but only [[RO_Services|RO-module]] has access to it). An 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.<br />
<br />
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).<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Fixed with hardware model/revision<br />
! Newest hardware model/revision this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| ARM9/ARM11 bootrom vectors point at unitialized RAM<br />
| ARM9's and ARM11's exception vectors are hardcoded to point at the CPU'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. <br />
Since RAM isn't cleared on boot (see below), one can immediately start execution of their own code here to dump bootrom, OTP, etc.<br />
The ARM9 bootrom does the following at reset: reset vector branches to another instruction, then branches to bootrom+0x8000. Hence, there's no way to know for certain when exactly the ARM9 exception-vector data stored in memory gets initialized.<br />
<br />
This requires *very* *precise* timing for triggering the hardware fault: it's unknown if anyone actually exploited this successfully at the time of writing(the one who attempted+discovered it *originally* as listed in this wiki section hasn't).<br />
| None: all available 3DS models at the time of writing have the exact same ARM9/ARM11 bootrom for the unprotected areas.<br />
| New3DS<br />
| End of February 2014<br />
| [[User:Derrek|derrek]], WulfyStylez (May 2015) independently<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
| None<br />
| New3DS<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No RAM clearing on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM/VRAM keeps its contents.<br />
| None<br />
| New3DS<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| 32bits of actual console-unique TWLNAND keydata<br />
| 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's highest bit is always ORed. only 31 bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.<br />
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).<br />
| None<br />
| New3DS<br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| None<br />
| New3DS<br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| 3DS key-generator<br />
| 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.<br />
<br />
Several such pairs of matching normal-keys and KeyY values were found, leading to deducing the key-generator function.<br />
| None<br />
| New3DS<br />
| February 2015<br />
| [[User:Yellows8|Yellows8]], [[User:Plutooo|plutoo]]<br />
|-<br />
| FIRM partitions known-plaintext<br />
| The [[Flash_Filesystem|FIRM partitions]] are encrypted with AES-CTR without a MAC. Since this works by XOR'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.<br />
<br />
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).<br />
<br />
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.<br />
| None<br />
| New3DS<br />
| <br />
| Everyone<br />
|}<br />
<br />
== ARM9 software ==<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Public disclosure timeframe<br />
! Discovered by<br />
|-<br />
| Rearrangable keys in the NAND keystore<br />
| Due to the keystore being encrypted with AES-ECB, one can rearrange blocks and still have the NAND keystore decrypt in a deterministic way. <br />
<br />
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.<br />
| arm9loaderhax given existing ARM9 code execution<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| Early 2016<br />
| 27 September 2016<br />
| Myria, [[User:Dark samus|dark_samus]]; mathieulh (independently); [[User:Plutooo|plutoo]] (independently) + others<br />
|-<br />
| Uncleared OTP hash keydata in console-unique 0x11 key-generation<br />
| 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.<br />
<br />
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.<br />
<br />
This can be performed by exploiting the "arm9loaderhax" 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 <[[3.0.0-6|3.0.0-X]].<br />
<br />
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.<br />
| Derivation of all New3DS keys generated via the NAND keystore (0x1B "Secure4" etc.)<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| ~April 2015, implemented in May 2015<br />
| 13 January 2016<br />
| [[User:WulfyStylez|WulfyStylez]], [[User:Dazzozo|Dazzozo]], [[User:Shinyquagsire23|shinyquagsire23]] (complimentary + implemented), [[User:Plutooo|plutoo]], Normmatt (discovered independently)<br />
|-<br />
| enhanced-arm9loaderhax<br />
| See the 32c3 3ds talk.<br />
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'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.<br />
| arm9loaderhax which automatically occurs at hard-boot.<br />
| See arm9loaderhax / description.<br />
| See arm9loaderhax / description.<br />
| Theorized around mid July, 2015. Later implemented+tested by [[User:Plutooo|plutoo]] and [[User:Derrek|derrek]].<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Missing verification-block for the 9.6 keys (arm9loaderhax)<br />
| 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.<br />
<br />
Writing an incorrect key to NAND will cause arm9loader to decrypt the ARM9 kernel as garbage and then jump to it.<br />
<br />
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'll find some garbage that jumps to your code.<br />
<br />
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. <br />
<br />
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.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key, access to uncleared OTP hash keydata<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| March, 2015<br />
| <br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Public disclosure timeframe<br />
! Discovered by<br />
|-<br />
| Leak of normal-key matching a key-scrambler key<br />
| 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 "fixed" 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.<br />
<br />
Nintendo'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 "Hardware" above), the key scrambler function could be deduced.<br />
| Deducing the keyX for keyslot 0x39 and the key scrambler algorithm<br />
| New 3DS [[9.3.0-21|9.3.0-X]], sort of<br />
| [[10.0.0-27|10.0.0-X]]<br />
| Sometime in 2015 after the hardware key-generator was broken.<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Leak of normal-key matching a key-generator key<br />
| During the 3DS' 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.<br />
<br />
<br />
Knowing the keyY and the normal-key for common-key index1, the devkit key-generator algorithm can be deduced (see "Hardware" above). Additionally the remaining devkit common-keys can be generated once the common-key keyX is recovered.<br />
<br />
Note the devkit key-generator was discovered to be the same as the retail key-generator.<br />
| Deducing the keyX for keyslot 0x3D and hardware key-generator algorithm. Generate remaining devkit common-keys.<br />
| pre-[[1.0.0-0|1.0.0-X]]<br />
| <br />
| Shortly after the key-generator was revealed to be flawed at the 32c3 3ds talk<br />
| January 20, 2016<br />
| [[User:Jakcron|jakcron]]<br />
|-<br />
| ntrcardhax<br />
| <br />
| ARM9 code execution<br />
| 10.4.0-29<br />
| <br />
| March 2015<br />
| 32c3 3ds talk (December 27, 2015)<br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| Title downgrading via [[Application_Manager_Services|AM]]([[Application_Manager_Services_PXI|PXI]])<br />
| 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.<br />
<br />
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't compare the input title-version with anything. Hence, titles can be downgraded this way.<br />
<br />
[[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.<br />
| Bypassing title version check at installation, which then allows downgrading any title.<br />
| [[11.0.0-33|11.0.0-X]], for key system titles.<br />
| NATIVE_FIRM / AM-sysmodule [[11.0.0-33|11.0.0-X]]<br />
| ?<br />
| <br />
| ?<br />
|-<br />
| FAT FS code null-deref<br />
| 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't check for NULL which then triggers a read based at NULL.<br />
<br />
Sample "fsck.vfat -n -v -V <fat image backup>" output for the above crash:<br />
<br />
<pre>...<br />
Starting check/repair pass.<br />
<FilePath0> and<br />
<FilePath1><br />
share clusters.<br />
Truncating second to 3375104 bytes.<br />
<FilePath1><br />
File size is 2787392 bytes, cluster chain length is 16384 bytes.<br />
Truncating file to 16384 bytes.<br />
Checking for unused clusters.<br />
Reclaimed 1 unused cluster (16384 bytes).<br />
Checking free cluster summary.<br />
Free cluster summary wrong (1404490 vs. really 1404491)<br />
Auto-correcting.<br />
Starting verification pass.<br />
Checking for unused clusters.<br />
Leaving filesystem unchanged.</pre><br />
| Useless null-based-read<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| July 8-9, 2015<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
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't really a problem here because there's proper padding check code which is executed prior to this.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ValidateDSiWareSectionMAC]] [[AES_Registers|AES]] keyslot reuse<br />
| When the input DSiWare section index is higher than <max number of DSiWare sections supported by this FIRM>, 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 >=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's unknown whether a timing attack would work with this.<br />
This is basically a different form of the pxips9 keyslot vuln, except with AESMAC etc.<br />
| See description.<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| March 15, 2015<br />
| December 29, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| pxips9 [[AES_Registers|AES]] keyslot reuse<br />
| 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 <=10.1.0-X(see 32c3 3ds talk).<br />
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't return any errors, Process9 will just continue to do crypto with whatever AES keyslot was selected before the PS command was sent.<br />
| Reusing the previously used keyslot, for crypto with PS.<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| Roughly the same time(same day?) as firmlaunch-hax.<br />
| December 29, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for (PXI) command replies<br />
| 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.<br />
Certain ARM11 service commands have this same issue as well.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.<br />
| 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.<br />
| Unknown, probably none.<br />
| ?<br />
| April 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| <br />
| [[User:Plutooo|plutoo]]/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| <br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]], maybe others(?)<br />
|}<br />
<br />
=== Kernel9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9<br />
| 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's never locked, you can dump it once you get ARM9 code execution.<br />
<br />
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).<br />
<br />
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 -> 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.<br />
| Dumping of the [[OTP Registers|OTP]] area<br />
| [[3.0.0-5|3.0.0-X]]<br />
|<br />
| February 2015<br />
| [[User:Plutooo|plutoo]], Normmatt independently<br />
|}<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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.<br />
| See description<br />
| [[11.0.0-33|11.0.0-X]] (deleted)<br />
| <br />
|<br />
| Everyone<br />
|-<br />
| veryslowpidhax<br />
| '''This is completely different from the kernelmode-code-execution vuln described in the below separate entry.'''<br />
<br />
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 <total ARM11 FIRM modules> to access ''all'' services, without checking exheader service-access-control. This alone does not affect access to [[SVC|SVCs]] at all.<br />
<br />
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.<br />
<br />
With launching+terminating a sysmodule repeatedly with this via ns:s, it would take weeks to finish(if not at least about a month?).<br />
| Access to all [[Services_API|services]].<br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2012 maybe?<br />
| <br />
|-<br />
| slowhax/waithax<br />
| 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.<br />
| ARM11 kernel-mode code execution<br />
| [[11.2.0-35|11.2.0-X]]<br />
| [[11.2.0-35|11.2.0-X]]<br />
| 2016<br />
| nedwill, [[User:Derrek|derrek]], others?<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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.<br />
| <br />
| None<br />
| [[11.2.0-35|11.2.0-X]]<br />
| <br />
| <br />
|-<br />
| memchunkhax2.1<br />
| Nintendo'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.<br />
derrek'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.<br />
| ARM11 kernel code execution<br />
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.<br />
| [[11.0.0-33|11.0.0-X]]<br />
|<br />
| [[User:Derrek|derrek]], aliaspider<br />
|-<br />
| memchunkhax2<br />
| When allocating a block of memory, the "next" pointer of the [[Memory_Management#MemoryBlockHeader|memchunkhdr]] is accessed without being checked after being mapped to userland.<br />
This allows a race condition, where the process can change the next pointer just before it'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. <br />
| ARM11 kernel code execution<br />
| [[10.4.0-29|10.4.0-X]] (partially, see memchunkhax2.1)<br />
| [[10.4.0-29|10.4.0-X]]<br />
|<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| heaphax<br />
| 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.<br />
| Code execution with access to all of NS's privileges. (including downgrading) Code execution within any applet.<br />
| [[11.0.0-33|11.0.0-X]], via the new [[Memory_Management#MemoryBlockHeader|memchunkhdr]] MAC which prevents modifying memchunkhdr data with DMA.<br />
| [[11.0.0-33|11.0.0-X]]<br />
| April 2015 ?<br />
| smea<br />
|-<br />
| snshax<br />
| Can force creation of Safe NS process into gspwn-able memory, allowing for takeover.<br />
| Code execution with access to all of NS's privileges. (including downgrading)<br />
| [[10.1.0-27|10.1.0-X]]<br />
| [[10.1.0-27|10.1.0-X]]<br />
| April 2015 ?<br />
| smea<br />
|-<br />
| AffinityMask/processorid validation<br />
| 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.<br />
The original code with the first 3 did the following: <br />
* if(u32_processorcount > ~0x80000001)return 0xe0e01bfd;<br />
* if(s32_processorcount > <total_cores>)return 0xd8e007fd;<br />
The following code replaced the above:<br />
* if(u32_processorcount >= <total_cores+1>)return 0xd8e007fd;<br />
In theory the latter should catch everything that the former did, so it's unknown if this was really a security issue.<br />
<br />
The svcCreateThread changes with [[10.0.0-27|10.0.0-X]] definitely did fix a security issue.<br />
* Original code: "if(s32_processorid > <total_cores>)return 0xd8e007fd;"<br />
* New code: "if(s32_processorid >= <total_cores> || s32_processorid <= -4)return 0xd8e007fd;"<br />
This fixed an off-by-one issue: if one would use processorid=total_cores, which isn't actually a valid value, svcCreateThread would accept that value on <[[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:<br />
* Old3DS: Useless kernel-mode crash due to accessing unmapped memory.<br />
* New3DS: uncontrolled data write into a kernel-mode L1 MMU-table. This isn't really useful: the data can't be controlled, and the data which gets overwritten is all-zero anyway(this isn't anywhere near MMU L1 entries for actually mapped memory).<br />
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'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)).<br />
| Nothing useful<br />
| [[10.0.0-27|10.0.0-X]]<br />
| [[10.0.0-27|10.0.0-X]]<br />
| svcCreateThread issue: May 31, 2015. The rest: September 8, 2015, via v9.6->v10.0 ARM11-kernel code-diff.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| memchunkhax<br />
| 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.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs<br />
| The ARM11-kernel did access the 'key' 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:<br />
SlabHeap_free(KLinkedListNode);<br />
KObject *obj = KLinkedListNode->key; // the object there might have changed!<br />
This bug appeared all over the place.<br />
| ARM11-kernelmode code exec maybe<br />
| [[8.0.0-18|8.0.0-18]]<br />
| <br />
| April 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Plutooo|plutoo]], [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| FSDIR null-deref<br />
| [[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's just a null-deref.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| May 19(?)-20, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Timeframe this was added to wiki<br />
! Discovered by<br />
|-<br />
| AM stack/.bss infoleak via [[AM:ReadTwlBackupInfo]]([[AM:ReadTwlBackupInfoEx|Ex]])<br />
| 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.<br />
<br />
'''This was not tested on hardware.'''<br />
| Stack/.bss reading<br />
| None<br />
| [[10.0.0-27]](AM v9217)<br />
| Roughly October 17, 2016<br />
| October 25, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[MVD_Services|MVD]]: Stack buffer overflow with [[MVDSTD:SetupOutputBuffers]].<br />
| 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->physaddrs used there are also copied to stack(0x8-bytes of physaddrs per entry).<br />
<br />
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.<br />
| MVD-sysmodule crash.<br />
| None<br />
| [[9.0.0-20]]<br />
| April 22, 2016 (Tested on the 25th)<br />
| April 25, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]]: Using CTRSDK heap with UDS sharedmem from the user-process.<br />
| See the HTTP-sysmodule section below.<br />
<br />
CTRSDK heap is used with the sharedmem from [[NWMUDS:InitializeWithVersion]]. Buffers are allocated/freed under this heap using [[NWMUDS:Bind]] and [[NWMUDS:Unbind]].<br />
<br />
Hence, overwriting sharedmem with gspwn then using [[NWMUDS:Unbind]] results in the usual controlled CTRSDK memchunk-header write, similar to HTTP-sysmodule.<br />
<br />
This could be done by creating an UDS network, without any other nodes on the network.<br />
<br />
Besides CTRSDK memchunk-headers, there are no addresses stored under this sharedmem.<br />
| ROP under NWM-module.<br />
| None<br />
| [[9.0.0-20|9.0.0-X]]<br />
| April 10, 2016<br />
| April 16, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DLP_Services|DLP]]: Out-of-bounds memory access during spectator [[Download_Play|data-frame]] checksum calculation<br />
| DLP doesn'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'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.<br />
<br />
Hence, using a large frame_size like 0xFFFF will result in the checksum calculation code reading data out-of-bounds. This isn'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's about all(trying to infoleak with this likely isn't useful either).<br />
| DLP-sysmodule crash, handled by dlplay system-application by a "connection interrupted" error eventually then a fatal-error via ErrDisp.<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| April 8, 2016 (Tested on the 10th)<br />
| April 10, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DLP_Services|DLP]]: Out-of-bounds output data writing during spectator sysupdate titlelist [[Download_Play|data-frame]] handling<br />
| 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.<br />
<br />
There'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.<br />
<br />
There's no known way to exploit the above crash, since the linked-list code involves writes zeros(with a controlled start ptr).<br />
| <br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| April 8-9, 2016<br />
| April 10, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[IR_Services|IR]]: Stack buffer overflow with custom hardware<br />
| 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.<br />
<br />
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.<br />
| ROP under IR sysmodule.<br />
| [[10.6.0-31|10.6.0-31]]<br />
| <br />
| February 23, 2016 (Unknown if it was noticed before then)<br />
| February 23, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HTTP_Services|HTTP]]: Using CTRSDK heap with sharedmem from the user-process.<br />
| 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.<br />
Normally this sharedmem isn't accessible to the user-process once the sysmodule maps it, hence using it is supposed to be "safe".<br />
<br />
This isn'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.<br />
<br />
This is exploited by [https://github.com/yellows8/ctr-httpwn/ctr-httpwn ctr-httpwn].<br />
| ROP under HTTP sysmdule.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]] (Latest sysmodule version as of [[10.7.0-32|10.7.0-32]])<br />
| Late 2015<br />
| March 22, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NIM_Services|NIM]]: Downloading old title-versions from eShop<br />
| 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 ''if'' it's still available from CDN.<br />
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).<br />
<br />
Originally this was tested with a debugging-system via modded-FIRM, eventually smea implemented it in HANS for the 32c3 release.<br />
| Downloading old title-versions from eShop<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| October 24, 2015 (Unknown when exactly the first eShop title downgrade was actually tested, maybe November)<br />
| January 7, 2016 (Same day Ironfall v1.0 was removed from CDN via the main-CXI files)<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| <br />
| [[User:Plutooo|plutoo]]<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| December 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWMUDS:DecryptBeaconData]] heap buffer overflow<br />
| input_size = 0x1E * <value the u8 from input_[[NWM_Services|networkstruct]]+0x1D>. Then input_tag0 is copied to a heap buffer. When input_size is larger than 0xFA-bytes, it will then copy input_tag1 to <end_address_of_previous_outbuf>, with size=input_size-0xFA.<br />
<br />
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.<br />
<br />
There'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't be controlled it seems(with just broadcasting a beacon at least). It's unknown whether this could be exploited from just using NWMUDS service-cmd(s) directly.<br />
| 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.<br />
| None<br />
| [[9.0.0-20]]<br />
| ~September 23, 2014(see the [[NWMUDS:DecryptBeaconData]] page history)<br />
| August 3, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
<br />
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.<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| <br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| <br />
| smea, [[User:Plutooo|plutoo]] joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| Last tested with [[10.1.0-27|10.1.0-X]].<br />
| June(?) 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| CTPK buffer overflow<br />
| 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'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.<br />
<br />
While CTPK(*.ctpk) are normally only loaded from RomFS, some application(s) load from elsewhere too.<br />
| ROP under the target application.<br />
| None?<br />
| "[SDK+NINTENDO:CTR_SDK-11_4_0_200_none]"<br />
| November 14, 2016<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=Homebrew_Exploits&diff=18547Homebrew Exploits2016-11-09T20:49:27Z<p>Derrek: Reverted edits by Thesmgcraft (talk) to last revision by Simon66</p>
<hr />
<div>==Payload==<br />
{| class="wikitable" border="1"<br />
|-<br />
! Works on latest fw<br />
! Name<br />
! Description<br />
! Supported firmwares<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [https://smealum.github.io/3ds/ *hax payload]<br />
| Booted by all of the below non-sysmodule exploits.<br />
| From '''9.0.0-7''' up to and including '''11.2.0-35'''.<br />
|}<br />
<br />
For the rest of this page, "Supported firmwares" refers to the exploit ''itself'', not whether *hax payload supports it.<br />
<br />
==Standalone Homebrew Launcher Exploits==<br />
The following homebrew exploits can be executed on a previously un-exploited system. ''Please'' see the above Payload section regarding what "Supported firmwares" indicates ''exactly''.<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Works on latest fw<br />
! Name<br />
! Supported firmwares<br />
! Requirements<br />
! Author<br />
! Install<br />
|-<br />
| style="background: salmon" | No<br />
| [[ninjhax|Ninjhax 1.1b]]<br />
| From '''4.0.0-7''' up to and including '''9.2.0-20'''.<br />
| A cartridge or eShop version (JPN-only) of "Cubic Ninja".<br />
| smea<br />
| [http://smealum.net/ninjhax/ Install]<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [[ninjhax|Ninjhax 2.x]]<br />
| From '''9.0.0-7''' up to and including '''11.2.0-35'''.<br />
| A cartridge or eShop version (JPN-only, not available anymore for purchase) of "Cubic Ninja".<br />
| smea<br />
| [https://smealum.github.io/ninjhax2/ Install]<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [http://plutooo.github.io/freakyhax/ freakyhax]<br />
| From '''9.0.0-7''' up to and including '''11.2.0-35'''.<br />
| A cartridge or eShop version (USA/EUR/JAP, not available anymore for purchase) of "Freakyform Deluxe".<br />
| plutoo<br />
| [http://plutooo.github.io/freakyhax/ Install]<br />
|-<br />
| style="background: salmon" | No<br />
| [http://plutooo.github.io/smilehax/ smilehax]<br />
| From '''9.0.0-7''' up to and including '''11.0.0-33'''<br />
| SmileBASIC (JPN all versions up to 3.32 excluded, USA 3.31 only)<br />
| plutoo<br />
| [http://plutooo.github.io/smilehax/ Install]<br />
|-<br />
| style="background: salmon" | No<br />
| [http://mrnbayoh.github.io/basicsploit/ BASICSploit]<br />
| From '''9.0.0-7''' up to and including '''11.0.0-33'''<br />
| SmileBASIC (USA all versions)<br />
| MrNbaYoh<br />
| [http://mrnbayoh.github.io/basicsploit/ Install]<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [[smashbroshax|smashbroshax]] (beaconhax)<br />
| (New 3DS only) From '''9.0.0-X''' up to and including '''11.2.0-35'''.<br />
| Super Smash Bros 3DS (full-game) and a way to broadcast raw wifi beacons. The demo (prior to the updated November 2015 [https://github.com/yellows8/3ds_smashbroshax version]) isn't usable with the *hax payloads. Game-version v1.1.3 fixed the vuln used with this, see the repo for a workaround for that.<br />
| [[User:Yellows8|Yellows8]]<br />
| [https://github.com/yellows8/3ds_smashbroshax Install]<br />
|-<br />
| style="background: salmon" | No<br />
| [[browserhax]]<br />
| From '''9.0.0-2''' to '''11.0.0-33'''<br />
Note that the browser-version-check bypass is only usable prior to [[10.7.0-32]].<br />
| A USA, EUR, JPN, or KOR system.<br />
| [[User:Yellows8|Yellows8]]<br />
| [http://yls8.mtheall.com/3dsbrowserhax.php Install]<br />
|}<br />
<br />
Note that ninjhax 1.x is still not obsolete. Even though ninjhax 2.x can be run on 9.3+, this was made possible (amongst other things) by sacrificing the memory remapping exploit used in ninjhax 1.x (rohax). Therefore, things like JIT engines for emulators can only be supported on ninjhax 1.x. Furthermore, ninjhax 2.x does not run on system versions below 9.0.0-X, while ninjhax 1.x does.<br />
<br />
==Secondary Exploits==<br />
Installation of these exploits requires a previously exploited system to install. After installation, they can be used on their own. ''Please'' see the above Payload section regarding what "Supported firmwares" indicates ''exactly''.<br />
<br />
{| class="wikitable" border="1"<br />
! Works on latest fw<br />
! Name<br />
! Supported firmwares<br />
! Requirements<br />
! Author<br />
! Install<br />
|-<br />
| style="background: salmon" | No<br />
| [[ironhax]]<br />
| From '''9.5.0-X''' up to and including '''10.3.0-X''', for '''X''' up to and including 28.<br />
| A copy of "Ironfall: Invasion" downloaded from eShop before August 11th, 2015. Note the updated version that was released on October 13th, 2015 is not supported.<br />
| smea<br />
| [http://smealum.github.io/3ds/ Install]<br />
|-<br />
| style="background: salmon" | No, exploit update required.<br />
| [http://vegaroxas.github.io/ steelhax]<br />
| From '''9.0.0-X''' up to and including '''11.1.0-X''', for '''X''' up to and including 34.<br />
| A copy of Steel Diver: Sub wars<br />
| Vegaroxas<br />
| [https://github.com/VegaRoXas/vegaroxas.github.io/raw/master/files/steelhax-installer.zip Install]<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [https://github.com/yellows8/oot3dhax oot3dhax]<br />
| From '''9.0.0-X''' up to and including '''11.2.0-X''', for '''X''' up to and including 35.<br />
| A gamecard or eShop-install of Legend of Zelda: Ocarina of Time 3D. Besides using the installer app, writing raw saveimages with a save dongle for example is another option. Before compression was introduced in the 2016-7-18 release, the size of the *hax payload meant the exploit can't coexist with regular saves on a physical version of the game.<br />
| Yellows8 / smea et al.<br />
| See [https://smealum.github.io/3ds/ here].<br />
|-<br />
| style="background: salmon" | No<br />
| [[menuhax]]<br />
| JPN/USA/EUR: From '''9.0.0-X''' up to and including '''11.0.0-X'''.<br />
KOR: From '''9.6.0-X''' up to and including '''11.0.0-X'''.<br />
| JPN/USA/EUR: Having created [[Home_Menu#Home_Menu_Theme_SD_ExtData|theme extdata]] through opening the official theme selector at least once.<br />
| [[User:Yellows8|Yellows8]]<br />
| [https://github.com/yellows8/3ds_homemenuhax/releases Download]<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [https://github.com/shinyquagsire23/supermysterychunkhax supermysterychunkhax]<br />
| From '''9.9.0-X''' (USA/JPN) / '''10.2.0-X''' (EUR) up to and including '''11.1.0-X''', for '''X''' up to and including 34.<br />
| A gamecard or eShop-install of Pokémon Super Mystery Dungeon.<br />
| Shiny Quagsire / SALT team<br />
| [https://smd.salthax.org/ Install].<br />
|-<br />
| style="background: salmon" | No<br />
| [https://github.com/shinyquagsire23/v_hax (v*)hax]<br />
| From '''9.0.0-X''' up to and including '''11.0.0-X''', for '''X''' up to and including 33.<br />
Note that '''9.0.0-X''' is only required for the Homebrew Launcher - the game itself only requires '''2.1.0-X''' for primitive userland code execution.<br />
| A copy of VVVVVV downloaded after March 2012 (v1). v1.1 patches out the overflow vulnerability used by (v*)hax.<br />
| Shiny Quagsire / SALT team<br />
| [https://vvvvvv.salthax.org/ Install].<br />
|-<br />
| style="background: salmon" | No, exploit update required.<br />
| [https://github.com/Dazzozo/humblehax humblehax]<br />
| From '''9.0.0-X''' (USA/EUR) up to and including '''11.0.0-X''', for '''X''' up to and including 33.<br />
| An eShop-install of Citizens of Earth (either v1 or v2), featured in the Humble "Friends of Nintendo" Bundle.<br />
| Dazzozo / SALT team<br />
| [https://citizens.salthax.org/ Install].<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [http://mrnbayoh.github.io/basehaxx/ basehaxx]<br />
| From '''9.0.0-X''' up to and including '''11.1.0-X''', for '''X''' up to and including 34.<br />
| A gamecard or eShop-install of Pokémon Omega Ruby / Alpha Sapphire.<br />
| MrNbaYoh<br />
| [http://mrnbayoh.github.io/basehaxx/ install]<br />
|-<br />
| style="background: lightgreen" | Yes<br />
| [https://github.com/yellows8/stickerhax stickerhax]<br />
| From '''9.0.0-X''' up to and including '''11.2.0-X'''(not including installation).<br />
| A gamecard or eShop-install of Paper Mario: Sticker Star.<br />
| [[User:Yellows8|Yellows8]]<br />
| [https://github.com/yellows8/stickerhax Here]<br />
|}<br />
<br />
==Exploits without Homebrew Launcher (Not recommended)==<br />
<br />
<u>'''Warning:'''</u> The following exploits can run code, but are missing a 3DSX launcher. They cannot launch any homebrew in the 3DSX format.<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Works on latest fw<br />
! Name<br />
! Supported firmwares<br />
! Requirements<br />
! Author<br />
! Install<br />
|-<br />
| style="background: salmon" | No<br />
| [[browserhax]] (Without the loader in the 3ds_browserhax_common repo)<br />
| (Old3DS) From '''5.0.0-2''' to '''11.0.0-33''' (Pre-v5.0 is supported for some versions if you manually modify the source)<br />
<br />
(New3DS) From '''9.0.0-20''' to '''11.0.0-33'''<br />
<br />
Note that the browser-version-check bypass is only usable prior to [[10.7.0-32]].<br />
| An USA, EUR, or JPN system.<br />
| [[User:Yellows8|Yellows8]]<br />
| [[browserhax|Install]]<br />
|-<br />
| style="background: salmon" | No<br />
| Ninjhax (with specialized payloads)<br />
| Up to '''9.2.0-20'''?<br />
| <br />
| smea + independent developers<br />
| N/A<br />
|}<br />
<br />
==Previous Exploits==<br />
<u>'''Warning:'''</u> These exploits '''do not work'''. They are exploits which no longer function at all, regardless of software or firmware revision.<br />
{| class="wikitable" border="1"<br />
! Works on latest fw<br />
! Name<br />
! Supported firmwares<br />
! Requirements<br />
! Author<br />
! Install<br />
|-<br />
| style="background: salmon" | No<br />
| [[tubehax|Tubehax]]<br />
| None. '''Was''': From '''9.0.0-X''' up to and including '''10.1.0-X''', for '''X''' up to and including 27.<br />
| The YouTube application and an Internet connection. As of October 15, 2015, this is no longer usable due to an update being released which fixes the vuln used by tubehax + app update being forced (see [[YouTube|here]]).<br />
| smea<br />
| [http://smealum.github.io/3ds/ Install]<br />
|}<br />
<br />
==Other Homebrew Loaders==<br />
The [https://github.com/yellows8/hblauncher_loader hblauncher_loader] title can be used when running under modded-FIRM which allows running unsigned titles, to boot the *hax payloads.<br />
<br />
==Sysmodule Exploits==<br />
This section is for system-module exploits, which can be run from the *hax payloads.<br />
<br />
{| class="wikitable" border="1"<br />
! Works on latest fw<br />
! Name<br />
! Supported firmwares<br />
! Requirements<br />
! Author<br />
|-<br />
| style="background: lightgreen" | Yes, that's not the intended default use however.<br />
| [https://github.com/yellows8/ctr-httpwn/releases ctr-httpwn]<br />
| From '''9.6.0-X''' up to and including '''11.2.0-X'''.<br />
| None<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
==WebKit vuln testing==<br />
See [https://github.com/yellows8/3ds_browserhax_common/issues/28 here].</div>Derrekhttps://www.3dbrew.org/w/index.php?title=NTRCARD_Registers&diff=18022NTRCARD Registers2016-09-03T17:41:06Z<p>Derrek: gbatek documentation link</p>
<hr />
<div>== Registers ==<br />
These registers are similar to the old NDS Cartridge registers, check http://problemkaputt.de/gbatek.htm#dscartridgeioports for more information.<br />
{| class="wikitable" border="1"<br />
! NAME<br />
! PHYSICAL ADDRESS<br />
! WIDTH<br />
|-<br />
| REG_NTRCARDMCNT<br />
| 0x10164000<br />
| 2<br />
|-<br />
| REG_NTRCARDMDATA<br />
| 0x10164002<br />
| 2<br />
|-<br />
| REG_NTRCARDROMCNT<br />
| 0x10164004<br />
| 4<br />
|-<br />
| REG_NTRCARDCMD<br />
| 0x10164008<br />
| 8<br />
|-<br />
| REG_NTRCARDSEEDX_L<br />
| 0x10164010<br />
| 4<br />
|-<br />
| REG_NTRCARDSEEDY_L<br />
| 0x10164014<br />
| 4<br />
|-<br />
| REG_NTRCARDSEEDX_H<br />
| 0x10164018<br />
| 1<br />
|-<br />
| REG_NTRCARDSEEDY_H<br />
| 0x1016401A<br />
| 1<br />
|-<br />
| REG_NTRCARDFIFO<br />
| 0x1016401C<br />
| 4<br />
|}<br />
<br />
== REG_NTRCARDMCNT ==<br />
{| class="wikitable" border="1"<br />
! Bit<br />
! Description<br />
|-<br />
| 14<br />
| Interrupt enable (1=Enable, 0=Disable)<br />
|-<br />
| 15<br />
| Enable (1=Enable, 0=Disable)<br />
|}<br />
<br />
<br />
== REG_NTRCARDROMCNT ==<br />
{| class="wikitable" border="1"<br />
! Bit<br />
! Description<br />
|-<br />
| 23<br />
| Data status (1=Ready, 0=Busy)<br />
|-<br />
| 31<br />
| Start (1=Busy, 0=Idle)<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=FSPXI:WriteFile&diff=18008FSPXI:WriteFile2016-08-30T12:54:58Z<p>Derrek: </p>
<hr />
<div>=Request=<br />
{| class="wikitable" border="1"<br />
|-<br />
! Index Word<br />
! Description<br />
|-<br />
| 0<br />
| Header code [0x000B0182]<br />
|-<br />
| 1<br />
| File handle lower word<br />
|-<br />
| 2<br />
| File handle upper word<br />
|-<br />
| 3<br />
| Offset lower word<br />
|-<br />
| 4<br />
| Offset upper word<br />
|-<br />
| 5<br />
| Flush flags<br />
|-<br />
| 6<br />
| Size<br />
|-<br />
| 7<br />
| (Size << 8) <nowiki>|</nowiki> 6<br />
|-<br />
| 8<br />
| Input buffer<br />
|}<br />
<br />
=Response=<br />
{| class="wikitable" border="1"<br />
|-<br />
! Index Word<br />
! Description<br />
|-<br />
| 0<br />
| Header code<br />
|-<br />
| 1<br />
| Result code<br />
|-<br />
| 2<br />
| Size written<br />
|-<br />
| 3<br />
| 4<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=IO_Registers&diff=17847IO Registers2016-07-29T22:46:37Z<p>Derrek: </p>
<hr />
<div>= Overview =<br />
<br />
{| class="wikitable" border="1"<br />
! Old3DS<br />
! A9/A11<br />
! Category<br />
! Physaddr<br />
! Used by<br />
! Comments<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[CONFIG Registers]]<br />
| 0x10000000<br />
| Boot9, Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[IRQ Registers]]<br />
| 0x10001000<br />
| Boot9, Process9, Kernel9<br />
| ARM9 Interrupt Masking<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[NDMA Registers]]<br />
| 0x10002000<br />
| Boot9, Process9<br />
| DMA Engine<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[TIMER Registers]]<br />
| 0x10003000<br />
| Boot9, Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[CTRCARD Registers]]<br />
| 0x10004000 / 0x10005000<br />
| Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[EMMC Registers]]<br />
| 0x10006000 / 0x10007000<br />
| Boot9, Process9<br />
| 0x10007000 is normally not enabled on retail, all-zeros when read.<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[PXI Registers]]<br />
| 0x10008000<br />
| Boot9, Process9<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[AES Registers]]<br />
| 0x10009000<br />
| Boot9, Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[SHA Registers]]<br />
| 0x1000A000<br />
| Boot9, Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[RSA Registers]]<br />
| 0x1000B000<br />
| Boot9, Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[Corelink DMA Engines|XDMA Registers]]<br />
| 0x1000C000<br />
| Boot9, Kernel9<br />
| [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0424d/index.html CoreLink™ DMA-330] (single-channel).<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[SPICARD Registers]]<br />
| 0x1000D800<br />
| Process9<br />
|<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A9<br />
| [[CONFIG Registers]]<br />
| 0x10010000<br />
| Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| PRNG Registers<br />
| 0x10011000<br />
| Process9<br />
| Used as entropy-source for seeding random number generators.<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[OTP Registers]]<br />
| 0x10012000<br />
| Kernel9, NewKernel9Loader<br />
| Top secret.<br />
|-<br />
| style="background: green" | Yes<br />
| A9<br />
| [[ARM7|ARM7 Registers]]<br />
| 0x10018000<br />
| TwlProcess9<br />
| Used to setup the ARM7 core for AGB/TWL<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| Debug WIFI SDIO Registers?<br />
| 0x10100000<br />
| <br />
| An SDIO controller is mapped here, NWM references this controller but doesn't have access to it.<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[HASH Registers]]<br />
| 0x10101000<br />
| [[Filesystem services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[Camera Registers]]<br />
| 0x10102000<br />
| [[Camera Services]]<br />
| y2r<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[CSND Registers]] / [[DSP Registers]]<br />
| 0x10103000<br />
| TwlBg, [[Codec Services]], [[CSND Services]], [[DSP Services]]<br />
| Sound hardware. For DSP regs, see the "DSi XpertTeak" section in [http://problemkaputt.de/gba.htm no$gba] help.<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| LGYFB0<br />
| 0x10110000<br />
| TwlBg<br />
| IO registers used to access legacy output framebuffer, as well as configure the upscaling filter.<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| LGYFB1<br />
| 0x10111000<br />
| TwlBg<br />
| IO registers used to access legacy output framebuffer, as well as configure the upscaling filter.<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[Camera Registers]] <br />
| 0x10120000<br />
| [[Camera Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[Camera Registers]]<br />
| 0x10121000<br />
| [[Camera Services]]<br />
| Mirror of 0x10120000?<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[WIFI Registers]]<br />
| 0x10122000<br />
| [[NWM Services]]<br />
| WIFI SDIO bus registers<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| ?<br />
| 0x10123000<br />
| [[NWM Services]]<br />
| WIFI?<br />
|-style="border-top: double"<br />
| style="background: red" | No<br />
| A11/A9<br />
| [[MVD Registers]]<br />
| 0x10130000<br />
| [[MVD Services]]<br />
| <br />
|-<br />
| style="background: red" | No<br />
| A11/A9<br />
| [[MVD Registers]]<br />
| 0x10131000<br />
| [[MVD Services]]<br />
| <br />
|-<br />
| style="background: red" | No<br />
| A11/A9<br />
| [[MVD Registers]]<br />
| 0x10132000<br />
| [[MVD Services]]<br />
| <br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[PDN Registers]]<br />
| 0x10140000<br />
| Process9, Boot11, Kernel11, TwlBg, [[DSP Services]], [[NWM Services]], [[SPI Services]]<br />
| Power management. <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[PDN Registers]]<br />
| 0x10141000<br />
| Process9, Boot11, Kernel11, TwlBg, [[Codec Services]], [[NWM Services]], [[SPI Services]], [[PDN Services]]<br />
| Power management<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[SPI Registers]]<br />
| 0x10142000<br />
| TwlBg, [[SPI Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[SPI Registers]]<br />
| 0x10143000<br />
| TwlBg, dmnt Module<br />
| Debugger related?<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[I2C Registers]]<br />
| 0x10144000<br />
| Boot11, Kernel11, TwlBg, [[I2C Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[CODEC Registers]]<br />
| 0x10145000<br />
| TwlBg, [[Codec Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[HID Registers]]<br />
| 0x10146000<br />
| Boot11, Kernel11, TwlBg, [[HID Services]], dlp Services<br />
| See [[PAD]].<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[GPIO Registers]]<br />
| 0x10147000<br />
| Boot11, TwlBg, [[GPIO Services]], [[DSP Services]](v0)<br />
| <br />
|- <br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[I2C Registers]]<br />
| 0x10148000<br />
| TwlBg, [[I2C Services]]<br />
| <br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[SPI Registers]]<br />
| 0x10160000<br />
| Boot9, TwlBg, [[SPI Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[I2C Registers]]<br />
| 0x10161000<br />
| Boot11, TwlBg, [[I2C Services]]<br />
| See [http://problemkaputt.de/gba.htm no$gba] help for some clues maybe.<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MIC Registers]]<br />
| 0x10162000<br />
| [[MIC Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[PXI Registers]]<br />
| 0x10163000<br />
| Boot11, Kernel11, TwlBg, [[PXI Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[NTRCARD Registers]]<br />
| 0x10164000<br />
| Boot9, Process9<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10165000<br />
| [[MP Services]]<br />
|<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10170000<br />
| [[MP Services]]<br />
| NTR WIFI Registers, see [http://problemkaputt.de/gbatek.htm#dswirelesscommunications GBATek].<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10171000<br />
| [[MP Services]]<br />
| NTR WIFI Registers (mirror)<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
|?<br />
| 0x10172000<br />
|?<br />
| NTR WIFI Unused?<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
|?<br />
| 0x10173000<br />
|?<br />
| NTR WIFI Unused?<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10174000<br />
| [[MP Services]]<br />
| NTR WIFI RAM<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10175000<br />
|?<br />
| NTR WIFI RAM<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10176000<br />
|?<br />
| NTR WIFI Registers (mirror)<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10177000<br />
|?<br />
| NTR WIFI Registers (mirror)<br />
|-<br />
| style="background: green" | Yes<br />
| A11/A9<br />
| [[MP Registers]]<br />
| 0x10178000 - 0x10180000<br />
| [[MP Services]]<br />
| NTR WIFI WS1 Region<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11<br />
| [[Corelink DMA Engines|CDMA]]<br />
| 0x10200000<br />
| Boot11, Kernel11<br />
| [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0424d/index.html CoreLink™ DMA-330]. Only used by bootrom on New3DS.<br />
|-<br />
| style="background: green" | Yes<br />
| A11<br />
| ?<br />
| 0x10201000<br />
| TwlBg<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A11<br />
| [[LCD Registers]]<br />
| 0x10202000<br />
| TwlBg, Kernel11, [[GSP Services]]<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| A11<br />
| [[DSP Registers]]<br />
| 0x10203000<br />
| [[DSP Services]]<br />
| <br />
|-<br />
| style="background: green" | Yes<br />
| A11<br />
| ?<br />
| 0x10204000<br />
| <br />
|<br />
|-style="border-top: double"<br />
| style="background: red" | No<br />
| A11<br />
| [[Corelink DMA Engines|CDMA]]<br />
| 0x10206000<br />
| NewKernel11<br />
| CDMA was moved (mirrored?) here on New 3DS. [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0424d/index.html CoreLink™ DMA-330].<br />
|-<br />
| style="background: red" | No<br />
| A11<br />
| [[MVD Registers]]<br />
| 0x10207000<br />
| [[MVD Services]]<br />
| New 3DS only?<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11<br />
| AXI<br />
| 0x1020F000<br />
| TwlBg, [[GSP Services]]<br />
| [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0422a/CHDGHIID.html CoreLink™ NIC-301 r1p0].<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11<br />
| DMA region<br />
| 0x10300000-0x10400000<br />
|<br />
| CDMA wants these addresses. Each page in this region corresponds to the same page in the 0x10100000-0x10200000 region. It is unknown if this is just a separate bus and/or if there are any differences in the registers.<br />
|-style="border-top: double"<br />
| style="background: green" | Yes<br />
| A11<br />
| [[GPU/External_Registers|GPU Registers]]<br />
| 0x10400000<br />
| Boot11, Kernel11, [[GSP Services]]<br />
||<br />
|}<br />
<br />
IO registers starting at physical address 0x10200000 are not accessible from the ARM9 (which includes all LCD/GPU registers). It seems IO registers below physical address 0x10100000 are not accessible from the ARM11 bus.<br />
<br />
ARM11 kernel virtual address mappings for these registers varies for different builds. For ARM11 user mode applications you have:<br />
physaddr = virtaddr - 0x1EC00000 + 0x10100000</div>Derrekhttps://www.3dbrew.org/w/index.php?title=11.0.0-33&diff=1738811.0.0-332016-05-13T17:47:57Z<p>Derrek: memchunkhax fix attempt</p>
<hr />
<div>The Old3DS+New3DS 11.0.0-33 system update was released on May 9, 2016. This Old3DS update was released for the following regions: USA, EUR, JPN, CHN, KOR, and TWN. This New3DS update was released for the following regions: USA, EUR, JPN, CHN, and KOR.<br />
<br />
Security flaws fixed: <fill this in manually later, see the updatedetails page from the ninupdates-report page(s) once available for now>.<br />
<br />
==Change-log==<br />
[http://en-americas-support.nintendo.com/app/answers/detail/a_id/667/p/430/c/267 Official] USA change-log:<br />
* Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience<br />
<br />
==System Titles==<br />
<fill this in (manually) later><br />
<br />
===NATIVE_FIRM===<br />
The ARM9 FIRM section is larger.<br />
<br />
The only updated FIRM sysmodules are loader and pm.<br />
<br />
svcBackdoor has been removed (on ARM11).<br />
<br />
====loader====<br />
Exactly one function was updated: L_140022b8 (same addr as previous version).<br />
<br />
The codebin physical-memory randomization code introduced with [[10.4.0-29]] was updated so that it's now used for OoT3D and Cubic Ninja (checked in the same aforementioned order), for the USA+EUR+JPN titles. This means oot3dhax and ninjhax need to be updated to handle this. Using the pre-sysupdate exploit versions will result in the title randomly crashing. However, if you retry enough times, it should run fine.<br />
<br />
====pm====<br />
Two functions were updated for calling a new function for exheader handling.<br />
<br />
This new function at L_101cfc immediately returns when the input programID isn't a CTR title / Cubic Ninja (USA/EUR/JPN uniqueID). This function removes all services in the exheader service-access-control which match services from a blacklist stored in pm-module. This blacklist contains two services: "http:C" and "soc:U".<br />
<br />
This breaks QR-code ninjhax with the version available at the time of sysupdate release, since the QR-code build downloads the payload via HTTPC.<br />
<br />
====ARM11-kernel====<br />
57 functions were updated, 47 of these are the actual functions used for handling SVCs (see below). The lone function updated with v10.4 was updated with this version again: Checks were added to make sure all the previously allocated memchunks are actually located within the requested memory region. This was implemented with the following checks which are done for each memchunk separately - right before clearing and mapping each one to the requested vaddr.<br />
if((region_base > memchunk_addr) || ((region_base + region_size) < (memchunk_addr + memchunk_size<<12))) { kernel_panic(); }<br />
The actual ToCToU race has not been fixed (see [[3DS System Flaws|memchunkhax2.1]]).<br />
<br />
3 new functions used for validation with memory management were added (kernelpanic() on failure). This is a new security feature for the kernel heaps. By adding a MAC to the kernel heap [[Memory Management#MemoryBlockHeader|memchunkhdr]] they can detect when it is modified by an outside DMA device ([[3DS System Flaws|gspwn]]).<br />
<br />
The MAC itself is custom based on xor-rot-sub-mul, and is calculated as follows (pseudo-code):<br />
<br />
u32* crypto_state = (u32*) r4; // Safe kernel memory. This is actually the [[Memory Management#RegionDescriptor|RegionDescriptor]].<br />
u32* data_ptr = (u32*) lr; // Unsafe FCRAM pointer.<br />
<br />
r0 = crypto_state[16/4] // Load "key".<br />
r1 = crypto_state[20/4]<br />
r2 = crypto_state[28/4]<br />
r3 = crypto_state[24/4]<br />
<br />
for(size_t i=0; i<2; i++) {<br />
for(size_t j=0; j<5; j++) {<br />
r0 -= (r1 >>> 3) - data_ptr[j]<br />
r1 -= (r3 >>> (r2 & 0xf + 3)) ^ (r2 >>> (r0 & 0xf + 13))<br />
r3 -= (r2 >>> r0) * r1<br />
r2 -= (r0 >>> r1) * r3<br />
}<br />
}<br />
<br />
// Verify MAC.<br />
if(data_ptr[5] != (r0 ^ r1)) {<br />
kernel_panic()<br />
}<br />
<br />
The function which initializes a memalloc heap had a major update (used for FCRAM memregions and the SlabHeap container). It generates a random MAC key based on svcGetSystemTick, like this:<br />
<br />
crypto_state[16/4] = 0 //This is actually the [[Memory Management#RegionDescriptor|RegionDescriptor]].<br />
crypto_state[20/4] = 0<br />
crypto_state[24/4] = 0<br />
crypto_state[28/4] = 0<br />
<br />
u32* key = &crypto_state[16/4];<br />
<br />
for(size_t i=0; i<0x40; i++) {<br />
for(size_t j=0; j<4; j++) { <br />
r0 = key[j] - GetSystemTick()<br />
key[j] = r0 ^ ((r0 >>> 7) - (key[(i+j) % 4] >>> 17))<br />
}<br />
}<br />
<br />
However, it's unknown how much the svcGetSystemTick() output really varies if anything(?) for each hard-boot during initialization of the heaps.<br />
<br />
6 memory management functions were updated to use the above new functions, these func-calls replaced the validation code previously used in these functions in some cases. These were also updated for the above heap security implementation. One function had a validation func-call added where previously there wasn't any validation done in the beginning of the function for previous versions.<br />
<br />
Another function(L_fff13b68 previously at L_fff13b68) was updated for offsets it uses, nothing else.<br />
<br />
The function handling the arm11kernel exheader descriptors was updated, if anything changed besides the kernel-version value it seems minor.<br />
<br />
The first 47 updated functions are used for the actual SVC handling. It seems each change just added code at the start of the function for initializing the output data. This includes SVCs which were already stubbed. All of the updated SVCs for this, in the same order as the arm11kernel code binary:<br />
{| class="wikitable" border="1"<br />
|-<br />
! SVC<br />
! Additional changes if any<br />
|-<br />
| svcCreatePort<br />
| None<br />
|-<br />
| svcOpenThread<br />
| None<br />
|-<br />
| svcCreateEvent<br />
| None<br />
|-<br />
| svcCreateMutex<br />
| None<br />
|-<br />
| svcCreateTimer<br />
| None<br />
|-<br />
| svcGetThreadId<br />
| None<br />
|-<br />
| svcRandomStub (SVC 0x74)<br />
| None<br />
|-<br />
| svcOpenProcess<br />
| None<br />
|-<br />
| svcQueryMemory<br />
| None<br />
|-<br />
| svcCreateThread<br />
| None<br />
|-<br />
| svcGetProcessId<br />
| None<br />
|-<br />
| svcAcceptSession<br />
| None<br />
|-<br />
| svcConnectToPort<br />
| None<br />
|-<br />
| svcControlMemory<br />
| None<br />
|-<br />
| svcCreateCodeSet (SVC 0x73)<br />
| None<br />
|-<br />
| svcCreateProcess (SVC 0x75)<br />
| None<br />
|-<br />
| svcCreateSession<br />
| None<br />
|-<br />
| svcGetHandleInfo<br />
| The code which clears the variables that get written into the output 8-byte buffer, was moved to before the code which checks the input type value (previously this was only executed for type 0x32107).<br />
|-<br />
| svcGetSystemInfo<br />
| None<br />
|-<br />
| svcGetThreadInfo<br />
| None<br />
|-<br />
| svcGetThreadList<br />
| None<br />
|-<br />
| svcSignalAndWait<br />
| None<br />
|-<br />
| svcGetProcessInfo<br />
| None<br />
|-<br />
| svcGetProcessList<br />
| None<br />
|-<br />
| svcCreateSemaphore<br />
| None<br />
|-<br />
| svcDuplicateHandle<br />
| None<br />
|-<br />
| svcReplyAndReceive<br />
| None<br />
|-<br />
| svcGetResourceLimit<br />
| None<br />
|-<br />
| svcReleaseSemaphore<br />
| None<br />
|-<br />
| svcReplyAndReceive1<br />
| None<br />
|-<br />
| svcReplyAndReceive2<br />
| None<br />
|-<br />
| svcReplyAndReceive3<br />
| None<br />
|-<br />
| svcReplyAndReceive4<br />
| None<br />
|-<br />
| svcCreateMemoryBlock<br />
| None<br />
|-<br />
| svcGetThreadPriority<br />
| None<br />
|-<br />
| svcDebugActiveProcess<br />
| None<br />
|-<br />
| svcQueryProcessMemory<br />
| None<br />
|-<br />
| svcCreateResourceLimit<br />
| None<br />
|-<br />
| svcCreateSessionToPort<br />
| None<br />
|-<br />
| svcCreateAddressArbiter<br />
| None<br />
|-<br />
| svcGetProcessIdOfThread<br />
| None<br />
|-<br />
| svcWaitSynchronizationN<br />
| None<br />
|-<br />
| svcGetThreadIdealProcessor<br />
| None<br />
|-<br />
| svcQueryDebugProcessMemory<br />
| None<br />
|-<br />
| svcGetProcessIdealProcessor<br />
| None<br />
|-<br />
| svcControlPerformanceCounter<br />
| None<br />
|-<br />
| svcStartInterProcessDma<br />
| None<br />
|}<br />
<br />
====Process9====<br />
Various data was moved around in the .data section (.data is 0x99C-bytes smaller than before).<br />
<br />
The only actual change in .text was that only one function was updated. This function is only called by [[AMPXI:InstallTitlesFinish]] and [[AMPXI:InstallTitlesFinishFIRM]]. Right after the mediatype validation at the very beginning of the function, a code block was added for the functionality described below which is only executed on [[CONFIG_Registers#CFG_UNITINFO|retail]].<br />
<br />
This AMPXI function will now check the high 6-bits of the title-version(major-version) of the title to finish-install against a hard-coded list of (titleID, minimumVersionRequired) pairs. This applies to MSET, Home Menu, spider, ErrDisp, SKATER, NATIVE_FIRM, and every retail system module. When the title-version is invalid, this returns the invalid title-version error(0xD8E08027).<br />
<br />
This is intended to prevent downgrading, which ''seems'' to be broken.<br />
<br />
====New3DS====<br />
The arm9loader wasn't changed at all.<br />
<br />
===friends-sysmodule===<br />
Only the value used for fpdver changed in the codebin, from 5 to 6. This is not required server-side yet, last checked on May 11, 2016.<br />
<br />
===IR-sysmodule===<br />
Exactly two functions were updated with the same changes: L_1053b0 and L_10547c.<br />
<br />
When the input value is zero, this now requires bitmask 0x2 to be clear in a certain state field before passing a ptr to a function, instead of 0x0.<br />
<br />
===0004001B00010802===<br />
The 1-byte content of "romfs:/dummy.txt" was changed from '2' to '3'.<br />
<br />
==See Also==<br />
System update report(s):<br />
* [https://yls8.mtheall.com/ninupdates/reports.php?date=05-09-16_08-00-49&sys=ctr]<br />
* [https://yls8.mtheall.com/ninupdates/reports.php?date=05-09-16_08-00-58&sys=ktr]</div>Derrekhttps://www.3dbrew.org/w/index.php?title=I2C_Registers&diff=14544I2C Registers2015-11-14T17:51:34Z<p>Derrek: /* Device 3 */</p>
<hr />
<div>= Registers =<br />
{| class="wikitable" border="1"<br />
! Old3DS<br />
! Name<br />
! Address<br />
! Width<br />
! Used by<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_DATA<br />
| 0x10161000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C1_CNT]]<br />
| 0x10161001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_CNTEX<br />
| 0x10161002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_SCL<br />
| 0x10161004<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_DATA<br />
| 0x10144000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C2_CNT]]<br />
| 0x10144001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_CNTEX<br />
| 0x10144002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_SCL<br />
| 0x10144004<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_DATA<br />
| 0x10148000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C3_CNT]]<br />
| 0x10148001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_CNTEX<br />
| 0x10148002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_SCL<br />
| 0x10148004<br />
| 2<br />
|<br />
|}<br />
<br />
== I2C_CNT ==<br />
{| class="wikitable" border="1"<br />
! BIT<br />
! DESCRIPTION<br />
|-<br />
| 0<br />
| Stop (0=No, 1=Stop/last byte)<br />
|-<br />
| 1<br />
| Start (0=No, 1=Start/first byte)<br />
|-<br />
| 2<br />
| Pause (0=Transfer Data, 1=Pause after Error, used with/after Stop)<br />
|-<br />
| 4<br />
| Ack Flag (0=Error, 1=Okay) (For DataRead: W, for DataWrite: R)<br />
|-<br />
| 5<br />
| Data Direction (0=Write, 1=Read)<br />
|-<br />
| 6<br />
| Interrupt Enable (0=Disable, 1=Enable)<br />
|-<br />
| 7<br />
| Start/busy (0=Ready, 1=Start/busy)<br />
|}<br />
<br />
= I2C Devices =<br />
{| class="wikitable" border="1"<br />
! [[I2C_Registers|Device id]]<br />
! Device bus id<br />
! Device Write Address<br />
! Accessible via I2C [[I2C_Services|service]]<br />
! Device description<br />
|-<br />
| 0<br />
| 1<br />
| 0x4a<br />
| "i2c::MCU"<br />
| Power management?(same device addr as the DSi power-management)<br />
|-<br />
| 1<br />
| 1<br />
| 0x7a<br />
| "i2c::CAM"<br />
| Camera0?(same dev-addr as DSi cam0)<br />
|-<br />
| 2<br />
| 1<br />
| 0x78<br />
| "i2c::CAM"<br />
| Camera1?(same dev-addr as DSi cam1)<br />
|-<br />
| 3<br />
| 2<br />
| 0x4a<br />
| "i2c::MCU"<br />
| MCU<br />
|-<br />
| 4<br />
| 2<br />
| 0x78<br />
| "i2c::CAM"<br />
| ?<br />
|-<br />
| 5<br />
| 2<br />
| 0x2c<br />
| "i2c::LCD"<br />
| ?<br />
|-<br />
| 6<br />
| 2<br />
| 0x2e<br />
| "i2c::LCD"<br />
| ?<br />
|-<br />
| 7<br />
| 2<br />
| 0x40<br />
| "i2c::DEB"<br />
| ?<br />
|-<br />
| 8<br />
| 2<br />
| 0x44<br />
| "i2c::DEB"<br />
| ?<br />
|-<br />
| 9<br />
| 3<br />
| 0xa6<br />
| "i2c::HID"<br />
| Unknown. The device table in I2C-module had the device address changed from 0xA6 to 0xD6 with [[8.0.0-18]].<br />
|-<br />
| 10<br />
| 3<br />
| 0xd0<br />
| "i2c::HID"<br />
| Gyroscope<br />
|-<br />
| 11<br />
| 3<br />
| 0xd2<br />
| "i2c::HID"<br />
| ?<br />
|-<br />
| 12<br />
| 3<br />
| 0xa4<br />
| "i2c::HID"<br />
| DebugPad<br />
|-<br />
| 13<br />
| 3<br />
| 0x9a<br />
| "i2c::IR"<br />
| IR<br />
|-<br />
| 14<br />
| 3<br />
| 0xa0<br />
| "i2c::EEP"<br />
| eeprom?<br />
|-<br />
| 15<br />
| 2<br />
| 0xee<br />
| "i2c::NFC"<br />
| New3DS-only [[NFC_Services|NFC]]<br />
|-<br />
| 16<br />
| 1<br />
| 0x40<br />
| "i2c::QTM"<br />
| New3DS-only [[QTM_Services|QTM]]<br />
|-<br />
| 17<br />
| 3<br />
| 0x54<br />
| "i2c::IR"<br />
| Used by IR-module starting with [[8.0.0-18]], for New3DS-only HID via "ir:rst". This deviceid doesn't seem to be supported by i2c module on [[8.0.0-18]](actual support was later added in New3DS i2c module).<br />
|}<br />
<br />
'''Notice''': These device addresses are used for writing to the respective device, for reading bit0 must be set (see I2C protocol). Thus, the actual device address is >> 1.<br />
<br />
== Device 3 ==<br />
{| class="wikitable" border="1"<br />
! REGISTER<br />
! WIDTH<br />
! DESCRIPTION <br />
|-<br />
| 0x03<br />
| 8<br />
| ?<br />
|-<br />
| 0x04<br />
| 8<br />
| ?<br />
|-<br />
| 0x08<br />
| 1<br />
| 3D slider position 0x9..0xFB<br />
|-<br />
| 0x09<br />
| 1<br />
| Sound volume: 0x0..0x3F.<br />
|-<br />
| 0xB<br />
| 1<br />
| Battery level: 0x0..0x40.<br />
|-<br />
| 0xF<br />
| 1<br />
| Flags: bit7-5 are read via [[MCU_Services|mcu::GPU]]. The rest of these are read via [[MCU_Services|mcu::RTC]]: bit4 = BatteryChargeState. bit3 = AdapterState. bit1 = ShellState.<br />
|-<br />
| 0x10<br />
| 1<br />
| Special HID status flags: bit0 = power button pressed, bit1 = power button pressed long, bit2 = home button pressed, bit3 = home button released, bit4 = wifi slider enabled, bit5 = shell got closed, bit6 = shell got opened. If nothing has changed this register is 0.<br />
|-<br />
| 0x12<br />
| 1<br />
| 0x40 if volume slider position changed<br />
|-<br />
| 0x18<br />
| 8<br />
| ?<br />
|-<br />
| 0x20<br />
| 8<br />
| Writing u8 value 4 here triggers a hardware system reboot. Writing u8 value 1 (repeatedly) triggers a shutdown via power-off?<br />
|-<br />
| 0x22<br />
| 8<br />
| ?<br />
|-<br />
| 0x23<br />
| 8<br />
| ?<br />
|-<br />
| 0x24<br />
| 8<br />
| ?<br />
|-<br />
| 0x28<br />
| 8<br />
| ?<br />
|-<br />
| 0x29<br />
| 8<br />
| ?<br />
|-<br />
| 0x2A<br />
| 8<br />
| ?<br />
|-<br />
| 0x2B<br />
| 8<br />
| ?<br />
|-<br />
| 0x2C<br />
| 8<br />
| ?<br />
|-<br />
| 0x2D<br />
| 0x64<br />
| This is used for [[MCURTC:SetInfoLEDPattern|controlling]] the notification LED(see [[MCURTC:SetInfoLEDPatternHeader]] as well), when this register is written.<br />
|-<br />
| 0x2E<br />
| 1<br />
| This [[MCURTC:GetInfoLEDStatus|returns]] the notification LED status when read.<br />
|-<br />
| 0x30<br />
| 8<br />
| RTC time (system clock)<br />
|-<br />
| 0x31<br />
| 8<br />
| ?<br />
|-<br />
| 0x32<br />
| 8<br />
| ?<br />
|-<br />
| 0x33<br />
| 8<br />
| ?<br />
|-<br />
| 0x34<br />
| 8<br />
| ?<br />
|-<br />
| 0x35<br />
| 8<br />
| ?<br />
|-<br />
| 0x36<br />
| 8<br />
| ?<br />
|-<br />
| 0x37<br />
| 8<br />
| ?<br />
|-<br />
| 0x38<br />
| 8<br />
| ?<br />
|-<br />
| 0x39<br />
| 8<br />
| ?<br />
|-<br />
| 0x3A<br />
| 8<br />
| ?<br />
|-<br />
| 0x3B<br />
| 8<br />
| ?<br />
|-<br />
| 0x3C<br />
| 8<br />
| ?<br />
|-<br />
| 0x41<br />
| 8<br />
| ?<br />
|-<br />
| 0x43<br />
| 8<br />
| ?<br />
|-<br />
| 0x4E<br />
| 8<br />
| ?<br />
|-<br />
| 0x50<br />
| 8<br />
| ?<br />
|-<br />
| 0x51<br />
| 8<br />
| ?<br />
|-<br />
| 0x58<br />
| 8<br />
| ?<br />
|-<br />
| 0x60<br />
| 8<br />
| ?<br />
|}<br />
<br />
== Device 5 & 6 ==<br />
LCD controllers for main/sub displays, most likely.<br />
<br />
{| class="wikitable" border="1"<br />
! Register<br />
! Width<br />
! Name<br />
! Description<br />
|-<br />
| 0x1<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x11<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x40<br />
| 8<br />
| CMD_IN/CMD_RESULT1<br />
| Write to trigger a command? Seen commands: 0xFF=Reset?, 0x62=IsFinished?. Result is stored in CMD_RESULT1:CMD_RESULT0.<br />
|-<br />
| 0x41<br />
| 8<br />
| CMD_RESULT0<br />
| Read result <br />
|-<br />
| 0x50<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x60<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0xFE<br />
| 8<br />
| ?<br />
| <br />
|}<br />
<br />
== Device 10 ==<br />
See the datasheet linked to on the [[Hardware]] page for reference.<br />
<br />
== Device 12 ==<br />
{| class="wikitable" border="1"<br />
! REGISTER<br />
! WIDTH<br />
! DESCRIPTION <br />
|-<br />
| 0x0<br />
| 21<br />
| DebugPad state.<br />
|}<br />
<br />
This is the DebugPad device, see [[HID_Shared_Memory|here]].<br />
<br />
== Device 13 ==<br />
{| class="wikitable" border="1"<br />
! Raw I2C register address<br />
! Internal register address<br />
! Width<br />
! Description <br />
|-<br />
| 0x0<br />
| 0x0<br />
| 0x40<br />
| RHR / THR (data receive/send FIFO)<br />
|-<br />
| 0x8<br />
| 0x1<br />
| 0x1<br />
| IER<br />
|-<br />
| 0x10<br />
| 0x2<br />
| 0x1<br />
| FCR/IIR<br />
|-<br />
| 0x18<br />
| 0x3<br />
| 0x1<br />
| LCR<br />
|-<br />
| 0x20<br />
| 0x4<br />
| 0x1<br />
| MCR<br />
|-<br />
| 0x28<br />
| 0x5<br />
| 0x1<br />
| LSR<br />
|-<br />
| 0x30<br />
| 0x6<br />
| 0x1<br />
| MSR/TCR<br />
|-<br />
| 0x38<br />
| 0x7<br />
| 0x1<br />
| SPR/TLR<br />
|-<br />
| 0x40<br />
| 0x8<br />
| 0x1<br />
| TXLVL<br />
|-<br />
| 0x48<br />
| 0x9<br />
| 0x1<br />
| RXLVL<br />
|-<br />
| 0x50<br />
| 0xA<br />
| 0x1<br />
| IODir<br />
|-<br />
| 0x58<br />
| 0xB<br />
| 0x1<br />
| IOState<br />
|-<br />
| 0x60<br />
| 0xC<br />
| 0x1<br />
| IoIntEna<br />
|-<br />
| 0x68<br />
| 0xD<br />
| 0x1<br />
| reserved<br />
|-<br />
| 0x70<br />
| 0xE<br />
| 0x1<br />
| IOControl<br />
|-<br />
| 0x78<br />
| 0xF<br />
| 0x1<br />
| EFCR<br />
|}<br />
<br />
See the datasheet linked to on the [[Hardware]] page for reference. From that datasheet, for the structure of the I2C register address u8: "Bit 0 is not used, bits 2:1 select the channel, bits 6:3 select one of the UART internal registers. Bit 7 is not used with the I2C-bus interface, but it is used by the SPI interface to indicate a read or a write operation."<br />
<br />
== Device 15 ==<br />
This the New3DS [[NFC_Services|NFC]] controller "I2C" interface. This device is accessed via the WriteDeviceRaw/ReadDeviceRaw I2C service [[I2C_Services|commands]].<br />
<br />
Since the *Raw commands are used with this, this device has no I2C registers. Instead, raw data is transfered after the I2C device is selected. Hence, WriteDeviceRaw is used for sending commands to the controller, while ReadDeviceRaw is for receiving responses from the controller. Certain commands may return multiple command responses.<br />
<br />
Command request / response structure:<br />
{| class="wikitable" border="1"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x0<br />
| 0x1<br />
| Normally 0x10?<br />
|-<br />
| 0x1<br />
| 0x1<br />
| Command source / destination.<br />
|-<br />
| 0x2<br />
| 0x1<br />
| CmdID<br />
|-<br />
| 0x3<br />
| 0x1<br />
| Payload size.<br />
|}<br />
<br />
Following the above header is the payload data(when payload size is non-zero), with the size specified in the header. The command response payload is usually at least 1-byte, where that byte appears to be normally 0x0. For command requests the payload data is the command parameters.<br />
<br />
For command requests sent to the NFC tag itself, Cmd[1]=0x0 and CmdID=0x0. The command request payload data here is the actual command request data for the NFC tag, starting with the CmdID u8 at payload+0.<br />
<br />
During NFC module startup, a certain command is sent to the controller which eventually(after various cmd-reply headers etc) returns the following the payload after the first byte in the payload:<br />
000000: 44 65 63 20 32 32 20 32 30 31 32 31 34 3a 35 33 Dec 22 201214:53 <br />
000010: 3a 35 30 01 05 0d 46 05 1b 79 20 07 32 30 37 39 :50...F..y .2079<br />
000020: 31 42 35 1B5<br />
<br />
Or that is: "Dec 22 201214:53:50<binary>20791B5". Therefore, this appears to return the part-number of the NFC controller(other command request(s) / response(s) use this part-number value too).<br />
<br />
=== NFC controller commands ===<br />
{| class="wikitable" border="1"<br />
! CmdRequest[1]<br />
! CmdID<br />
! Payload data for parameters<br />
! Description<br />
|-<br />
| 0x2E<br />
| 0x2F<br />
| Firmware image for this chunk, size varies.<br />
| This is used during NFC module startup to upload the firmware image to the NFC controller. This is used repeatedly to upload multiple chunks of the image.<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=I2C_Registers&diff=14543I2C Registers2015-11-14T17:00:48Z<p>Derrek: /* I2C Devices */</p>
<hr />
<div>= Registers =<br />
{| class="wikitable" border="1"<br />
! Old3DS<br />
! Name<br />
! Address<br />
! Width<br />
! Used by<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_DATA<br />
| 0x10161000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C1_CNT]]<br />
| 0x10161001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_CNTEX<br />
| 0x10161002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_SCL<br />
| 0x10161004<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_DATA<br />
| 0x10144000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C2_CNT]]<br />
| 0x10144001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_CNTEX<br />
| 0x10144002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_SCL<br />
| 0x10144004<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_DATA<br />
| 0x10148000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C3_CNT]]<br />
| 0x10148001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_CNTEX<br />
| 0x10148002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_SCL<br />
| 0x10148004<br />
| 2<br />
|<br />
|}<br />
<br />
== I2C_CNT ==<br />
{| class="wikitable" border="1"<br />
! BIT<br />
! DESCRIPTION<br />
|-<br />
| 0<br />
| Stop (0=No, 1=Stop/last byte)<br />
|-<br />
| 1<br />
| Start (0=No, 1=Start/first byte)<br />
|-<br />
| 2<br />
| Pause (0=Transfer Data, 1=Pause after Error, used with/after Stop)<br />
|-<br />
| 4<br />
| Ack Flag (0=Error, 1=Okay) (For DataRead: W, for DataWrite: R)<br />
|-<br />
| 5<br />
| Data Direction (0=Write, 1=Read)<br />
|-<br />
| 6<br />
| Interrupt Enable (0=Disable, 1=Enable)<br />
|-<br />
| 7<br />
| Start/busy (0=Ready, 1=Start/busy)<br />
|}<br />
<br />
= I2C Devices =<br />
{| class="wikitable" border="1"<br />
! [[I2C_Registers|Device id]]<br />
! Device bus id<br />
! Device Write Address<br />
! Accessible via I2C [[I2C_Services|service]]<br />
! Device description<br />
|-<br />
| 0<br />
| 1<br />
| 0x4a<br />
| "i2c::MCU"<br />
| Power management?(same device addr as the DSi power-management)<br />
|-<br />
| 1<br />
| 1<br />
| 0x7a<br />
| "i2c::CAM"<br />
| Camera0?(same dev-addr as DSi cam0)<br />
|-<br />
| 2<br />
| 1<br />
| 0x78<br />
| "i2c::CAM"<br />
| Camera1?(same dev-addr as DSi cam1)<br />
|-<br />
| 3<br />
| 2<br />
| 0x4a<br />
| "i2c::MCU"<br />
| MCU<br />
|-<br />
| 4<br />
| 2<br />
| 0x78<br />
| "i2c::CAM"<br />
| ?<br />
|-<br />
| 5<br />
| 2<br />
| 0x2c<br />
| "i2c::LCD"<br />
| ?<br />
|-<br />
| 6<br />
| 2<br />
| 0x2e<br />
| "i2c::LCD"<br />
| ?<br />
|-<br />
| 7<br />
| 2<br />
| 0x40<br />
| "i2c::DEB"<br />
| ?<br />
|-<br />
| 8<br />
| 2<br />
| 0x44<br />
| "i2c::DEB"<br />
| ?<br />
|-<br />
| 9<br />
| 3<br />
| 0xa6<br />
| "i2c::HID"<br />
| Unknown. The device table in I2C-module had the device address changed from 0xA6 to 0xD6 with [[8.0.0-18]].<br />
|-<br />
| 10<br />
| 3<br />
| 0xd0<br />
| "i2c::HID"<br />
| Gyroscope<br />
|-<br />
| 11<br />
| 3<br />
| 0xd2<br />
| "i2c::HID"<br />
| ?<br />
|-<br />
| 12<br />
| 3<br />
| 0xa4<br />
| "i2c::HID"<br />
| DebugPad<br />
|-<br />
| 13<br />
| 3<br />
| 0x9a<br />
| "i2c::IR"<br />
| IR<br />
|-<br />
| 14<br />
| 3<br />
| 0xa0<br />
| "i2c::EEP"<br />
| eeprom?<br />
|-<br />
| 15<br />
| 2<br />
| 0xee<br />
| "i2c::NFC"<br />
| New3DS-only [[NFC_Services|NFC]]<br />
|-<br />
| 16<br />
| 1<br />
| 0x40<br />
| "i2c::QTM"<br />
| New3DS-only [[QTM_Services|QTM]]<br />
|-<br />
| 17<br />
| 3<br />
| 0x54<br />
| "i2c::IR"<br />
| Used by IR-module starting with [[8.0.0-18]], for New3DS-only HID via "ir:rst". This deviceid doesn't seem to be supported by i2c module on [[8.0.0-18]](actual support was later added in New3DS i2c module).<br />
|}<br />
<br />
'''Notice''': These device addresses are used for writing to the respective device, for reading bit0 must be set (see I2C protocol). Thus, the actual device address is >> 1.<br />
<br />
== Device 3 ==<br />
{| class="wikitable" border="1"<br />
! REGISTER<br />
! WIDTH<br />
! DESCRIPTION <br />
|-<br />
| 0x03<br />
| 8<br />
| ?<br />
|-<br />
| 0x04<br />
| 8<br />
| ?<br />
|-<br />
| 0x08<br />
| 1<br />
| 3D slider position 0x9..0xFB<br />
|-<br />
| 0x09<br />
| 1<br />
| Sound volume: 0x0..0x3F.<br />
|-<br />
| 0xB<br />
| 1<br />
| Battery level: 0x0..0x40.<br />
|-<br />
| 0xF<br />
| 1<br />
| Flags: bit7-5 are read via [[MCU_Services|mcu::GPU]]. The rest of these are read via [[MCU_Services|mcu::RTC]]: bit4 = BatteryChargeState. bit3 = AdapterState. bit1 = ShellState.<br />
|-<br />
| 0x10<br />
| 1<br />
| Special HID status flags: bit0 = power button pressed, bit1 = power button released, bit2 = home button pressed, bit3 = home button released, bit4 = wifi slider enabled, bit5 = shell got closed, bit6 = shell got opened. If nothing has changed this register is 0.<br />
|-<br />
| 0x12<br />
| 1<br />
| 0x40 if volume slider position changed<br />
|-<br />
| 0x18<br />
| 8<br />
| ?<br />
|-<br />
| 0x20<br />
| 8<br />
| Writing u8 value 4 here triggers a hardware system reboot. Writing u8 value 1 (repeatedly) triggers a shutdown via power-off?<br />
|-<br />
| 0x22<br />
| 8<br />
| ?<br />
|-<br />
| 0x23<br />
| 8<br />
| ?<br />
|-<br />
| 0x24<br />
| 8<br />
| ?<br />
|-<br />
| 0x28<br />
| 8<br />
| ?<br />
|-<br />
| 0x29<br />
| 8<br />
| ?<br />
|-<br />
| 0x2A<br />
| 8<br />
| ?<br />
|-<br />
| 0x2B<br />
| 8<br />
| ?<br />
|-<br />
| 0x2C<br />
| 8<br />
| ?<br />
|-<br />
| 0x2D<br />
| 0x64<br />
| This is used for [[MCURTC:SetInfoLEDPattern|controlling]] the notification LED(see [[MCURTC:SetInfoLEDPatternHeader]] as well), when this register is written.<br />
|-<br />
| 0x2E<br />
| 1<br />
| This [[MCURTC:GetInfoLEDStatus|returns]] the notification LED status when read.<br />
|-<br />
| 0x30<br />
| 8<br />
| RTC time (system clock)<br />
|-<br />
| 0x31<br />
| 8<br />
| ?<br />
|-<br />
| 0x32<br />
| 8<br />
| ?<br />
|-<br />
| 0x33<br />
| 8<br />
| ?<br />
|-<br />
| 0x34<br />
| 8<br />
| ?<br />
|-<br />
| 0x35<br />
| 8<br />
| ?<br />
|-<br />
| 0x36<br />
| 8<br />
| ?<br />
|-<br />
| 0x37<br />
| 8<br />
| ?<br />
|-<br />
| 0x38<br />
| 8<br />
| ?<br />
|-<br />
| 0x39<br />
| 8<br />
| ?<br />
|-<br />
| 0x3A<br />
| 8<br />
| ?<br />
|-<br />
| 0x3B<br />
| 8<br />
| ?<br />
|-<br />
| 0x3C<br />
| 8<br />
| ?<br />
|-<br />
| 0x41<br />
| 8<br />
| ?<br />
|-<br />
| 0x43<br />
| 8<br />
| ?<br />
|-<br />
| 0x4E<br />
| 8<br />
| ?<br />
|-<br />
| 0x50<br />
| 8<br />
| ?<br />
|-<br />
| 0x51<br />
| 8<br />
| ?<br />
|-<br />
| 0x58<br />
| 8<br />
| ?<br />
|-<br />
| 0x60<br />
| 8<br />
| ?<br />
|}<br />
<br />
<br />
== Device 5 & 6 ==<br />
LCD controllers for main/sub displays, most likely.<br />
<br />
{| class="wikitable" border="1"<br />
! Register<br />
! Width<br />
! Name<br />
! Description<br />
|-<br />
| 0x1<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x11<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x40<br />
| 8<br />
| CMD_IN/CMD_RESULT1<br />
| Write to trigger a command? Seen commands: 0xFF=Reset?, 0x62=IsFinished?. Result is stored in CMD_RESULT1:CMD_RESULT0.<br />
|-<br />
| 0x41<br />
| 8<br />
| CMD_RESULT0<br />
| Read result <br />
|-<br />
| 0x50<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x60<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0xFE<br />
| 8<br />
| ?<br />
| <br />
|}<br />
<br />
== Device 10 ==<br />
See the datasheet linked to on the [[Hardware]] page for reference.<br />
<br />
== Device 12 ==<br />
{| class="wikitable" border="1"<br />
! REGISTER<br />
! WIDTH<br />
! DESCRIPTION <br />
|-<br />
| 0x0<br />
| 21<br />
| DebugPad state.<br />
|}<br />
<br />
This is the DebugPad device, see [[HID_Shared_Memory|here]].<br />
<br />
== Device 13 ==<br />
{| class="wikitable" border="1"<br />
! Raw I2C register address<br />
! Internal register address<br />
! Width<br />
! Description <br />
|-<br />
| 0x0<br />
| 0x0<br />
| 0x40<br />
| RHR / THR (data receive/send FIFO)<br />
|-<br />
| 0x8<br />
| 0x1<br />
| 0x1<br />
| IER<br />
|-<br />
| 0x10<br />
| 0x2<br />
| 0x1<br />
| FCR/IIR<br />
|-<br />
| 0x18<br />
| 0x3<br />
| 0x1<br />
| LCR<br />
|-<br />
| 0x20<br />
| 0x4<br />
| 0x1<br />
| MCR<br />
|-<br />
| 0x28<br />
| 0x5<br />
| 0x1<br />
| LSR<br />
|-<br />
| 0x30<br />
| 0x6<br />
| 0x1<br />
| MSR/TCR<br />
|-<br />
| 0x38<br />
| 0x7<br />
| 0x1<br />
| SPR/TLR<br />
|-<br />
| 0x40<br />
| 0x8<br />
| 0x1<br />
| TXLVL<br />
|-<br />
| 0x48<br />
| 0x9<br />
| 0x1<br />
| RXLVL<br />
|-<br />
| 0x50<br />
| 0xA<br />
| 0x1<br />
| IODir<br />
|-<br />
| 0x58<br />
| 0xB<br />
| 0x1<br />
| IOState<br />
|-<br />
| 0x60<br />
| 0xC<br />
| 0x1<br />
| IoIntEna<br />
|-<br />
| 0x68<br />
| 0xD<br />
| 0x1<br />
| reserved<br />
|-<br />
| 0x70<br />
| 0xE<br />
| 0x1<br />
| IOControl<br />
|-<br />
| 0x78<br />
| 0xF<br />
| 0x1<br />
| EFCR<br />
|}<br />
<br />
See the datasheet linked to on the [[Hardware]] page for reference. From that datasheet, for the structure of the I2C register address u8: "Bit 0 is not used, bits 2:1 select the channel, bits 6:3 select one of the UART internal registers. Bit 7 is not used with the I2C-bus interface, but it is used by the SPI interface to indicate a read or a write operation."<br />
<br />
== Device 15 ==<br />
This the New3DS [[NFC_Services|NFC]] controller "I2C" interface. This device is accessed via the WriteDeviceRaw/ReadDeviceRaw I2C service [[I2C_Services|commands]].<br />
<br />
Since the *Raw commands are used with this, this device has no I2C registers. Instead, raw data is transfered after the I2C device is selected. Hence, WriteDeviceRaw is used for sending commands to the controller, while ReadDeviceRaw is for receiving responses from the controller. Certain commands may return multiple command responses.<br />
<br />
Command request / response structure:<br />
{| class="wikitable" border="1"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x0<br />
| 0x1<br />
| Normally 0x10?<br />
|-<br />
| 0x1<br />
| 0x1<br />
| Command source / destination.<br />
|-<br />
| 0x2<br />
| 0x1<br />
| CmdID<br />
|-<br />
| 0x3<br />
| 0x1<br />
| Payload size.<br />
|}<br />
<br />
Following the above header is the payload data(when payload size is non-zero), with the size specified in the header. The command response payload is usually at least 1-byte, where that byte appears to be normally 0x0. For command requests the payload data is the command parameters.<br />
<br />
For command requests sent to the NFC tag itself, Cmd[1]=0x0 and CmdID=0x0. The command request payload data here is the actual command request data for the NFC tag, starting with the CmdID u8 at payload+0.<br />
<br />
During NFC module startup, a certain command is sent to the controller which eventually(after various cmd-reply headers etc) returns the following the payload after the first byte in the payload:<br />
000000: 44 65 63 20 32 32 20 32 30 31 32 31 34 3a 35 33 Dec 22 201214:53 <br />
000010: 3a 35 30 01 05 0d 46 05 1b 79 20 07 32 30 37 39 :50...F..y .2079<br />
000020: 31 42 35 1B5<br />
<br />
Or that is: "Dec 22 201214:53:50<binary>20791B5". Therefore, this appears to return the part-number of the NFC controller(other command request(s) / response(s) use this part-number value too).<br />
<br />
=== NFC controller commands ===<br />
{| class="wikitable" border="1"<br />
! CmdRequest[1]<br />
! CmdID<br />
! Payload data for parameters<br />
! Description<br />
|-<br />
| 0x2E<br />
| 0x2F<br />
| Firmware image for this chunk, size varies.<br />
| This is used during NFC module startup to upload the firmware image to the NFC controller. This is used repeatedly to upload multiple chunks of the image.<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=I2C_Registers&diff=14542I2C Registers2015-11-14T16:52:27Z<p>Derrek: mcu regs</p>
<hr />
<div>= Registers =<br />
{| class="wikitable" border="1"<br />
! Old3DS<br />
! Name<br />
! Address<br />
! Width<br />
! Used by<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_DATA<br />
| 0x10161000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C1_CNT]]<br />
| 0x10161001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_CNTEX<br />
| 0x10161002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C1_SCL<br />
| 0x10161004<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_DATA<br />
| 0x10144000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C2_CNT]]<br />
| 0x10144001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_CNTEX<br />
| 0x10144002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C2_SCL<br />
| 0x10144004<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_DATA<br />
| 0x10148000<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| [[#I2C_CNT|I2C3_CNT]]<br />
| 0x10148001<br />
| 1<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_CNTEX<br />
| 0x10148002<br />
| 2<br />
|<br />
|-<br />
| style="background: green" | Yes<br />
| I2C3_SCL<br />
| 0x10148004<br />
| 2<br />
|<br />
|}<br />
<br />
== I2C_CNT ==<br />
{| class="wikitable" border="1"<br />
! BIT<br />
! DESCRIPTION<br />
|-<br />
| 0<br />
| Stop (0=No, 1=Stop/last byte)<br />
|-<br />
| 1<br />
| Start (0=No, 1=Start/first byte)<br />
|-<br />
| 2<br />
| Pause (0=Transfer Data, 1=Pause after Error, used with/after Stop)<br />
|-<br />
| 4<br />
| Ack Flag (0=Error, 1=Okay) (For DataRead: W, for DataWrite: R)<br />
|-<br />
| 5<br />
| Data Direction (0=Write, 1=Read)<br />
|-<br />
| 6<br />
| Interrupt Enable (0=Disable, 1=Enable)<br />
|-<br />
| 7<br />
| Start/busy (0=Ready, 1=Start/busy)<br />
|}<br />
<br />
= I2C Devices =<br />
{| class="wikitable" border="1"<br />
! [[I2C_Registers|Device id]]<br />
! Device bus id<br />
! Device address<br />
! Accessible via I2C [[I2C_Services|service]]<br />
! Device description<br />
|-<br />
| 0<br />
| 1<br />
| 0x4a<br />
| "i2c::MCU"<br />
| Power management?(same device addr as the DSi power-management)<br />
|-<br />
| 1<br />
| 1<br />
| 0x7a<br />
| "i2c::CAM"<br />
| Camera0?(same dev-addr as DSi cam0)<br />
|-<br />
| 2<br />
| 1<br />
| 0x78<br />
| "i2c::CAM"<br />
| Camera1?(same dev-addr as DSi cam1)<br />
|-<br />
| 3<br />
| 2<br />
| 0x4a<br />
| "i2c::MCU"<br />
| MCU<br />
|-<br />
| 4<br />
| 2<br />
| 0x78<br />
| "i2c::CAM"<br />
| ?<br />
|-<br />
| 5<br />
| 2<br />
| 0x2c<br />
| "i2c::LCD"<br />
| ?<br />
|-<br />
| 6<br />
| 2<br />
| 0x2e<br />
| "i2c::LCD"<br />
| ?<br />
|-<br />
| 7<br />
| 2<br />
| 0x40<br />
| "i2c::DEB"<br />
| ?<br />
|-<br />
| 8<br />
| 2<br />
| 0x44<br />
| "i2c::DEB"<br />
| ?<br />
|-<br />
| 9<br />
| 3<br />
| 0xa6<br />
| "i2c::HID"<br />
| Unknown. The device table in I2C-module had the device address changed from 0xA6 to 0xD6 with [[8.0.0-18]].<br />
|-<br />
| 10<br />
| 3<br />
| 0xd0<br />
| "i2c::HID"<br />
| Gyroscope<br />
|-<br />
| 11<br />
| 3<br />
| 0xd2<br />
| "i2c::HID"<br />
| ?<br />
|-<br />
| 12<br />
| 3<br />
| 0xa4<br />
| "i2c::HID"<br />
| DebugPad<br />
|-<br />
| 13<br />
| 3<br />
| 0x9a<br />
| "i2c::IR"<br />
| IR<br />
|-<br />
| 14<br />
| 3<br />
| 0xa0<br />
| "i2c::EEP"<br />
| eeprom?<br />
|-<br />
| 15<br />
| 2<br />
| 0xee<br />
| "i2c::NFC"<br />
| New3DS-only [[NFC_Services|NFC]]<br />
|-<br />
| 16<br />
| 1<br />
| 0x40<br />
| "i2c::QTM"<br />
| New3DS-only [[QTM_Services|QTM]]<br />
|-<br />
| 17<br />
| 3<br />
| 0x54<br />
| "i2c::IR"<br />
| Used by IR-module starting with [[8.0.0-18]], for New3DS-only HID via "ir:rst". This deviceid doesn't seem to be supported by i2c module on [[8.0.0-18]](actual support was later added in New3DS i2c module).<br />
|}<br />
<br />
== Device 3 ==<br />
{| class="wikitable" border="1"<br />
! REGISTER<br />
! WIDTH<br />
! DESCRIPTION <br />
|-<br />
| 0x03<br />
| 8<br />
| ?<br />
|-<br />
| 0x04<br />
| 8<br />
| ?<br />
|-<br />
| 0x08<br />
| 1<br />
| 3D slider position 0x9..0xFB<br />
|-<br />
| 0x09<br />
| 1<br />
| Sound volume: 0x0..0x3F.<br />
|-<br />
| 0xB<br />
| 1<br />
| Battery level: 0x0..0x40.<br />
|-<br />
| 0xF<br />
| 1<br />
| Flags: bit7-5 are read via [[MCU_Services|mcu::GPU]]. The rest of these are read via [[MCU_Services|mcu::RTC]]: bit4 = BatteryChargeState. bit3 = AdapterState. bit1 = ShellState.<br />
|-<br />
| 0x10<br />
| 1<br />
| Special HID status flags: bit0 = power button pressed, bit1 = power button released, bit2 = home button pressed, bit3 = home button released, bit4 = wifi slider enabled, bit5 = shell got closed, bit6 = shell got opened. If nothing has changed this register is 0.<br />
|-<br />
| 0x12<br />
| 1<br />
| 0x40 if volume slider position changed<br />
|-<br />
| 0x18<br />
| 8<br />
| ?<br />
|-<br />
| 0x20<br />
| 8<br />
| Writing u8 value 4 here triggers a hardware system reboot. Writing u8 value 1 (repeatedly) triggers a shutdown via power-off?<br />
|-<br />
| 0x22<br />
| 8<br />
| ?<br />
|-<br />
| 0x23<br />
| 8<br />
| ?<br />
|-<br />
| 0x24<br />
| 8<br />
| ?<br />
|-<br />
| 0x28<br />
| 8<br />
| ?<br />
|-<br />
| 0x29<br />
| 8<br />
| ?<br />
|-<br />
| 0x2A<br />
| 8<br />
| ?<br />
|-<br />
| 0x2B<br />
| 8<br />
| ?<br />
|-<br />
| 0x2C<br />
| 8<br />
| ?<br />
|-<br />
| 0x2D<br />
| 0x64<br />
| This is used for [[MCURTC:SetInfoLEDPattern|controlling]] the notification LED(see [[MCURTC:SetInfoLEDPatternHeader]] as well), when this register is written.<br />
|-<br />
| 0x2E<br />
| 1<br />
| This [[MCURTC:GetInfoLEDStatus|returns]] the notification LED status when read.<br />
|-<br />
| 0x30<br />
| 8<br />
| RTC time (system clock)<br />
|-<br />
| 0x31<br />
| 8<br />
| ?<br />
|-<br />
| 0x32<br />
| 8<br />
| ?<br />
|-<br />
| 0x33<br />
| 8<br />
| ?<br />
|-<br />
| 0x34<br />
| 8<br />
| ?<br />
|-<br />
| 0x35<br />
| 8<br />
| ?<br />
|-<br />
| 0x36<br />
| 8<br />
| ?<br />
|-<br />
| 0x37<br />
| 8<br />
| ?<br />
|-<br />
| 0x38<br />
| 8<br />
| ?<br />
|-<br />
| 0x39<br />
| 8<br />
| ?<br />
|-<br />
| 0x3A<br />
| 8<br />
| ?<br />
|-<br />
| 0x3B<br />
| 8<br />
| ?<br />
|-<br />
| 0x3C<br />
| 8<br />
| ?<br />
|-<br />
| 0x41<br />
| 8<br />
| ?<br />
|-<br />
| 0x43<br />
| 8<br />
| ?<br />
|-<br />
| 0x4E<br />
| 8<br />
| ?<br />
|-<br />
| 0x50<br />
| 8<br />
| ?<br />
|-<br />
| 0x51<br />
| 8<br />
| ?<br />
|-<br />
| 0x58<br />
| 8<br />
| ?<br />
|-<br />
| 0x60<br />
| 8<br />
| ?<br />
|}<br />
<br />
<br />
== Device 5 & 6 ==<br />
LCD controllers for main/sub displays, most likely.<br />
<br />
{| class="wikitable" border="1"<br />
! Register<br />
! Width<br />
! Name<br />
! Description<br />
|-<br />
| 0x1<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x11<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x40<br />
| 8<br />
| CMD_IN/CMD_RESULT1<br />
| Write to trigger a command? Seen commands: 0xFF=Reset?, 0x62=IsFinished?. Result is stored in CMD_RESULT1:CMD_RESULT0.<br />
|-<br />
| 0x41<br />
| 8<br />
| CMD_RESULT0<br />
| Read result <br />
|-<br />
| 0x50<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0x60<br />
| 8<br />
| ?<br />
| <br />
|-<br />
| 0xFE<br />
| 8<br />
| ?<br />
| <br />
|}<br />
<br />
== Device 10 ==<br />
See the datasheet linked to on the [[Hardware]] page for reference.<br />
<br />
== Device 12 ==<br />
{| class="wikitable" border="1"<br />
! REGISTER<br />
! WIDTH<br />
! DESCRIPTION <br />
|-<br />
| 0x0<br />
| 21<br />
| DebugPad state.<br />
|}<br />
<br />
This is the DebugPad device, see [[HID_Shared_Memory|here]].<br />
<br />
== Device 13 ==<br />
{| class="wikitable" border="1"<br />
! Raw I2C register address<br />
! Internal register address<br />
! Width<br />
! Description <br />
|-<br />
| 0x0<br />
| 0x0<br />
| 0x40<br />
| RHR / THR (data receive/send FIFO)<br />
|-<br />
| 0x8<br />
| 0x1<br />
| 0x1<br />
| IER<br />
|-<br />
| 0x10<br />
| 0x2<br />
| 0x1<br />
| FCR/IIR<br />
|-<br />
| 0x18<br />
| 0x3<br />
| 0x1<br />
| LCR<br />
|-<br />
| 0x20<br />
| 0x4<br />
| 0x1<br />
| MCR<br />
|-<br />
| 0x28<br />
| 0x5<br />
| 0x1<br />
| LSR<br />
|-<br />
| 0x30<br />
| 0x6<br />
| 0x1<br />
| MSR/TCR<br />
|-<br />
| 0x38<br />
| 0x7<br />
| 0x1<br />
| SPR/TLR<br />
|-<br />
| 0x40<br />
| 0x8<br />
| 0x1<br />
| TXLVL<br />
|-<br />
| 0x48<br />
| 0x9<br />
| 0x1<br />
| RXLVL<br />
|-<br />
| 0x50<br />
| 0xA<br />
| 0x1<br />
| IODir<br />
|-<br />
| 0x58<br />
| 0xB<br />
| 0x1<br />
| IOState<br />
|-<br />
| 0x60<br />
| 0xC<br />
| 0x1<br />
| IoIntEna<br />
|-<br />
| 0x68<br />
| 0xD<br />
| 0x1<br />
| reserved<br />
|-<br />
| 0x70<br />
| 0xE<br />
| 0x1<br />
| IOControl<br />
|-<br />
| 0x78<br />
| 0xF<br />
| 0x1<br />
| EFCR<br />
|}<br />
<br />
See the datasheet linked to on the [[Hardware]] page for reference. From that datasheet, for the structure of the I2C register address u8: "Bit 0 is not used, bits 2:1 select the channel, bits 6:3 select one of the UART internal registers. Bit 7 is not used with the I2C-bus interface, but it is used by the SPI interface to indicate a read or a write operation."<br />
<br />
== Device 15 ==<br />
This the New3DS [[NFC_Services|NFC]] controller "I2C" interface. This device is accessed via the WriteDeviceRaw/ReadDeviceRaw I2C service [[I2C_Services|commands]].<br />
<br />
Since the *Raw commands are used with this, this device has no I2C registers. Instead, raw data is transfered after the I2C device is selected. Hence, WriteDeviceRaw is used for sending commands to the controller, while ReadDeviceRaw is for receiving responses from the controller. Certain commands may return multiple command responses.<br />
<br />
Command request / response structure:<br />
{| class="wikitable" border="1"<br />
! Offset<br />
! Size<br />
! Description<br />
|-<br />
| 0x0<br />
| 0x1<br />
| Normally 0x10?<br />
|-<br />
| 0x1<br />
| 0x1<br />
| Command source / destination.<br />
|-<br />
| 0x2<br />
| 0x1<br />
| CmdID<br />
|-<br />
| 0x3<br />
| 0x1<br />
| Payload size.<br />
|}<br />
<br />
Following the above header is the payload data(when payload size is non-zero), with the size specified in the header. The command response payload is usually at least 1-byte, where that byte appears to be normally 0x0. For command requests the payload data is the command parameters.<br />
<br />
For command requests sent to the NFC tag itself, Cmd[1]=0x0 and CmdID=0x0. The command request payload data here is the actual command request data for the NFC tag, starting with the CmdID u8 at payload+0.<br />
<br />
During NFC module startup, a certain command is sent to the controller which eventually(after various cmd-reply headers etc) returns the following the payload after the first byte in the payload:<br />
000000: 44 65 63 20 32 32 20 32 30 31 32 31 34 3a 35 33 Dec 22 201214:53 <br />
000010: 3a 35 30 01 05 0d 46 05 1b 79 20 07 32 30 37 39 :50...F..y .2079<br />
000020: 31 42 35 1B5<br />
<br />
Or that is: "Dec 22 201214:53:50<binary>20791B5". Therefore, this appears to return the part-number of the NFC controller(other command request(s) / response(s) use this part-number value too).<br />
<br />
=== NFC controller commands ===<br />
{| class="wikitable" border="1"<br />
! CmdRequest[1]<br />
! CmdID<br />
! Payload data for parameters<br />
! Description<br />
|-<br />
| 0x2E<br />
| 0x2F<br />
| Firmware image for this chunk, size varies.<br />
| This is used during NFC module startup to upload the firmware image to the NFC controller. This is used repeatedly to upload multiple chunks of the image.<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=134743DS System Flaws2015-10-02T14:56:45Z<p>Derrek: /* Hardware */</p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there's a [[SVC]] for this, but only [[RO_Services|RO-module]] has access to it). An 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.<br />
<br />
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).<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Fixed with hardware model/revision<br />
! Newest hardware model/revision this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| ARM9/ARM11 bootrom vectors point at unitialized RAM<br />
| ARM9's and ARM11's exception vectors are hardcoded to point at the CPU'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. <br />
Since RAM isn't cleared on boot (see below), one can immediately start execution of their own code here to dump bootrom, OTP, etc.<br />
The ARM9 bootrom does the following at reset: reset vector branches to another instruction, then branches to bootrom+0x8000. Hence, there's no way to know for certain when exactly the ARM9 exception-vector data stored in memory gets initialized.<br />
<br />
This requires *very* *precise* timing for triggering the hardware fault: it's unknown if anyone actually exploited this successfully at the time of writing(the one who attempted+discovered it *originally* as listed in this wiki section hasn't).<br />
| None: all available 3DS models at the time of writing have the exact same ARM9/ARM11 bootrom for the unprotected areas.<br />
| New3DS<br />
| End of February 2014<br />
| [[User:Derrek|derrek]], WulfyStylez (May 2015) independently<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
| None<br />
| New3DS<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No RAM clearing on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM/VRAM keeps its contents.<br />
| None<br />
| New3DS<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| 32bits of actual console-unique TWLNAND keydata<br />
| 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's highest bit is always ORed. only 31 bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.<br />
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).<br />
| None<br />
| New3DS<br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| <br />
| <br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
== ARM9 software ==<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| Missing verification-block for the 9.6 keys<br />
| 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.<br />
<br />
Writing an incorrect key to NAND will cause arm9loader to decrypt the ARM9 kernel as garbage and then jump to it.<br />
<br />
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'll find some garbage that jumps to your code.<br />
<br />
This should give 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. <br />
<br />
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.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| March, 2015<br />
| plutoo<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| FAT FS code null-deref<br />
| 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't check for NULL which then triggers a read based at NULL.<br />
<br />
Sample "fsck.vfat -n -v -V <fat image backup>" output for the above crash:<br />
<br />
<pre>...<br />
Starting check/repair pass.<br />
<FilePath0> and<br />
<FilePath1><br />
share clusters.<br />
Truncating second to 3375104 bytes.<br />
<FilePath1><br />
File size is 2787392 bytes, cluster chain length is 16384 bytes.<br />
Truncating file to 16384 bytes.<br />
Checking for unused clusters.<br />
Reclaimed 1 unused cluster (16384 bytes).<br />
Checking free cluster summary.<br />
Free cluster summary wrong (1404490 vs. really 1404491)<br />
Auto-correcting.<br />
Starting verification pass.<br />
Checking for unused clusters.<br />
Leaving filesystem unchanged.</pre><br />
| Useless null-based-read<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| July 8-9, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
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't really a problem here because there's proper padding check code which is executed prior to this.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for (PXI) command replies<br />
| 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.<br />
Certain ARM11 service commands have this same issue as well.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.<br />
| 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.<br />
| Unknown, probably none.<br />
| ?<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| plutoo/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| plutoo, [[User:Yellows8|Yellows8]], maybe others(?)<br />
|}<br />
<br />
=== Kernel9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9<br />
| 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's never locked, you can dump it once you get ARM9 code execution. See [[OTP Registers|here]] regarding the data stored there.<br />
<br />
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.<br />
| Dumping of the [[OTP Registers|OTP]] area<br />
| [[3.0.0-5|3.0.0-X]]<br />
|<br />
| February 2015<br />
| plutoo, Normmatt independently<br />
|}<br />
<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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) requires patching the kernel .text or modifying SVC-access-control.<br />
| See description<br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
|<br />
| Everyone<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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, this never seems to be used after that, however.<br />
| <br />
| None<br />
| [[10.0.0-27|10.0.0-X]]<br />
| <br />
| <br />
|-<br />
| AffinityMask/processorid validation<br />
| 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.<br />
The original code with the first 3 did the following: <br />
* if(u32_processorcount > ~0x80000001)return 0xe0e01bfd;<br />
* if(s32_processorcount > <total_cores>)return 0xd8e007fd;<br />
The following code replaced the above:<br />
* if(u32_processorcount >= <total_cores+1>)return 0xd8e007fd;<br />
In theory the latter should catch everything that the former did, so it's unknown if this was really a security issue.<br />
<br />
The svcCreateThread changes with [[10.0.0-27|10.0.0-X]] definitely did fix a security issue.<br />
* Original code: "if(s32_processorid > <total_cores>)return 0xd8e007fd;"<br />
* New code: "if(s32_processorid >= <total_cores> || s32_processorid <= -4)return 0xd8e007fd;"<br />
This fixed an off-by-one issue: if one would use processorid=total_cores, which isn't actually a valid value, svcCreateThread would accept that value on <[[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:<br />
* Old3DS: Useless kernel-mode crash due to accessing unmapped memory.<br />
* New3DS: uncontrolled data write into a kernel-mode L1 MMU-table. This isn't really useful: the data can't be controlled, and the data which gets overwritten is all-zero anyway(this isn't anywhere near MMU L1 entries for actually mapped memory).<br />
| Nothing useful<br />
| [[10.0.0-27|10.0.0-X]]<br />
| [[10.0.0-27|10.0.0-X]]<br />
| svcCreateThread issue: May 31, 2015. The rest: September 8, 2015, via v9.6->v10.0 ARM11-kernel code-diff.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| memchunkhax<br />
| 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.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs<br />
| The ARM11-kernel did access the 'key' 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:<br />
SlabHeap_free(KLinkedListNode);<br />
KObject *obj = KLinkedListNode->key; // the object there might have changed!<br />
This bug appeared all over the place.<br />
| ARM11-kernelmode code exec maybe<br />
| [[8.0.0-18|8.0.0-18]]<br />
| <br />
| April 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| plutoo, [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| plutoo<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| plutoo, [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| FSDIR null-deref<br />
| [[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's just a null-deref.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| May 19(?)-20, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Timeframe this was added to wiki<br />
! Discovered by<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| <br />
| plutoo<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| December 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWMUDS:DecryptBeaconData]] heap buffer overflow<br />
| input_size = 0x1E * <value the u8 from input_[[NWM_Services|networkstruct]]+0x1D>. Then input_tag0 is copied to a heap buffer. When input_size is larger than 0xFA-bytes, it will then copy input_tag1 to <end_address_of_previous_outbuf>, with size=input_size-0xFA.<br />
<br />
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.<br />
<br />
There'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't be controlled it seems(with just broadcasting a beacon at least). It's unknown whether this could be exploited from just using NWMUDS service-cmd(s) directly.<br />
| 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.<br />
| None<br />
| [[9.0.0-20]]<br />
| ~September 23, 2014(see the [[NWMUDS:DecryptBeaconData]] page history)<br />
| August 3, 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
<br />
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.<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| <br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| <br />
| smea, plutoo joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| Last tested with [[10.1.0-27|10.1.0-X]].<br />
| June(?) 2014<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| <br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=Bootloader&diff=13331Bootloader2015-09-24T18:21:23Z<p>Derrek: booting other FIRMs</p>
<hr />
<div>When the 3DS does not find the NAND chip, the following error is displayed:<br />
<br />
[[Image:CTR_Bootrom_Error.jpg|240px]]<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Error<br />
! Description<br />
|-<br />
| <tt>00F800FE 00000000 00000000 00000200 00000000</tt><br />
| Error when having SD-card reader connected to NAND during boot.<br />
|-<br />
| <tt>00F800FE 00000000 00000000 00000400 00000000</tt><br />
| NAND not found error (?)<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000080 00800000</tt><br />
| NAND error when DAT1 was used as DAT0.<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000005 00800000</tt><br />
| NAND error when DAT2 was used as DAT0.<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000005 00000000</tt><br />
| NAND error when DAT3 was used as DAT0.<br />
|-<br />
| <tt>00F800FF F8F8FFFF FFFFFFFF 00000000 00000000</tt><br />
| Both the firm0 and firm1 partitions are corrupt (failed signature checks).<br />
|-<br />
| <tt>00F800EE FFFFFFFF FFFFFFFF 00000000 00000000</tt><br />
| [[NCSD]] header in sector 0 is corrupt (failed signature check).<br />
|}<br />
<br />
== NAND Reads ==<br />
During a successful boot on 6.x, the bootloader (and firm) reads the following sectors from NAND (in this order):<br />
00000000 (NCSD Partition Table)<br />
<br />
Only verify 'FIRM' magic? (A second Header-read will be attempted even if everything except the magic is 0xFF...)<br />
0B130000 (FIRM Partition)<br />
0B530000 (Secondary FIRM Partition)<br />
<br />
Verify RSA signature and parse Header:<br />
0B130000 (FIRM: Header)<br />
0B130200 (FIRM: Section 1)<br />
0B163E00 (FIRM: Section 2)<br />
0B193E00 (FIRM: Section 3)<br />
<br />
00013000 .. Below is probably NATIVE_FIRM booting ..<br />
00014000<br />
00015000<br />
00016000<br />
00017000<br />
<br />
09011A00<br />
09011C00<br />
09012000<br />
09012400<br />
...<br />
<br />
== The 3DS' Boot procedure: ==<br />
<br />
* 0 Seconds - unit is powered on the ARM9 and ARM11 [[Memory_layout|bootroms]] begins execution<br />
<br />
* 2 Seconds - ARM9 bootrom attempts to initialize the NAND. If the NAND is successfully initialized, the ARM9 bootrom loads the [[FIRM|firmware]] stored in the NAND [[FIRM]] partition which handles booting the rest of the system(if verification for NAND firm0 fails, the ARM9 bootrom will attempt to use firm1 instead). The ARM11 kernel loaded from FIRM then launches the [[NCCH#CXI|CXI]] ARM11 system modules loaded from FIRM(Note that the ARM11 kernel does not handle any encryption/RSA verification, this is handled by the [[FIRM|ARM9]]). If the NAND cannot be initialized, (i.e. the NAND chip is not connected/damaged etc) a blue error screen similar to the screen above appears.<br />
<br />
* 3 Seconds - all essential hardware is active. The [[Process_Manager_Services|PM]] module launches [[NS]], [[NS]] then launches [[ErrDisp]] and the [[Configuration Memory#ACTIVEMENUTID|current active menu]] via PM module. For retail units this menu is usually the [[Home Menu]]. NS will [[NS|auto-boot]] titles instead of launching ErrDisp/Home Menu, if auto-booting is needed. Note that PM module first launches the module dependencies when launching a process, prior to actually launching the process.<br />
<br />
* 4 Seconds - the LCD screens are initialized<br />
<br />
* 7 Seconds - [[Home Menu]] is fully initialized/loaded<br />
<br />
== BootROM ==<br />
The non-protected areas of the ARM9 and ARM11 bootROMs are identical, for launch-day regular Old3DS, 2DS, and regular New3DS.<br />
Besides NATIVE_FIRM, the bootloader is also capable to boot other firmwares (such as TWL_FIRM and AGB_FIRM). However, this will result either in a japanese Error-screen or a system shutdown, directly after FIRM-Launching.</div>Derrekhttps://www.3dbrew.org/w/index.php?title=Bootloader&diff=13330Bootloader2015-09-24T17:39:49Z<p>Derrek: NAND sniffing...</p>
<hr />
<div>When the 3DS does not find the NAND chip, the following error is displayed:<br />
<br />
[[Image:CTR_Bootrom_Error.jpg|240px]]<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Error<br />
! Description<br />
|-<br />
| <tt>00F800FE 00000000 00000000 00000200 00000000</tt><br />
| Error when having SD-card reader connected to NAND during boot.<br />
|-<br />
| <tt>00F800FE 00000000 00000000 00000400 00000000</tt><br />
| NAND not found error (?)<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000080 00800000</tt><br />
| NAND error when DAT1 was used as DAT0.<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000005 00800000</tt><br />
| NAND error when DAT2 was used as DAT0.<br />
|-<br />
| <tt>00F800FE FFFFFFFF FFFFFFFF 00000005 00000000</tt><br />
| NAND error when DAT3 was used as DAT0.<br />
|-<br />
| <tt>00F800FF F8F8FFFF FFFFFFFF 00000000 00000000</tt><br />
| Both the firm0 and firm1 partitions are corrupt (failed signature checks).<br />
|-<br />
| <tt>00F800EE FFFFFFFF FFFFFFFF 00000000 00000000</tt><br />
| [[NCSD]] header in sector 0 is corrupt (failed signature check).<br />
|}<br />
<br />
== NAND Reads ==<br />
During a successful boot on 6.x, the bootloader (and firm) reads the following sectors from NAND (in this order):<br />
00000000 (NCSD Partition Table)<br />
<br />
Only verify 'FIRM' magic? (A second Header-read will be attempted even if everything except the magic is 0xFF...)<br />
0B130000 (FIRM Partition)<br />
0B530000 (Secondary FIRM Partition)<br />
<br />
Verify RSA signature and parse Header:<br />
0B130000 (FIRM: Header)<br />
0B130200 (FIRM: Section 1)<br />
0B163E00 (FIRM: Section 2)<br />
0B193E00 (FIRM: Section 3)<br />
<br />
00013000 .. Below is probably NATIVE_FIRM booting ..<br />
00014000<br />
00015000<br />
00016000<br />
00017000<br />
<br />
09011A00<br />
09011C00<br />
09012000<br />
09012400<br />
...<br />
<br />
== The 3DS' Boot procedure: ==<br />
<br />
* 0 Seconds - unit is powered on the ARM9 and ARM11 [[Memory_layout|bootroms]] begins execution<br />
<br />
* 2 Seconds - ARM9 bootrom attempts to initialize the NAND. If the NAND is successfully initialized, the ARM9 bootrom loads the [[FIRM|firmware]] stored in the NAND [[FIRM]] partition which handles booting the rest of the system(if verification for NAND firm0 fails, the ARM9 bootrom will attempt to use firm1 instead). The ARM11 kernel loaded from FIRM then launches the [[NCCH#CXI|CXI]] ARM11 system modules loaded from FIRM(Note that the ARM11 kernel does not handle any encryption/RSA verification, this is handled by the [[FIRM|ARM9]]). If the NAND cannot be initialized, (i.e. the NAND chip is not connected/damaged etc) a blue error screen similar to the screen above appears.<br />
<br />
* 3 Seconds - all essential hardware is active. The [[Process_Manager_Services|PM]] module launches [[NS]], [[NS]] then launches [[ErrDisp]] and the [[Configuration Memory#ACTIVEMENUTID|current active menu]] via PM module. For retail units this menu is usually the [[Home Menu]]. NS will [[NS|auto-boot]] titles instead of launching ErrDisp/Home Menu, if auto-booting is needed. Note that PM module first launches the module dependencies when launching a process, prior to actually launching the process.<br />
<br />
* 4 Seconds - the LCD screens are initialized<br />
<br />
* 7 Seconds - [[Home Menu]] is fully initialized/loaded<br />
<br />
== BootROM ==<br />
The non-protected areas of the ARM9 and ARM11 bootROMs are identical, for launch-day regular Old3DS, 2DS, and regular New3DS.</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=126113DS System Flaws2015-05-14T10:50:02Z<p>Derrek: Added more information about the bootrom fail</p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there's a [[SVC]] for this, but only [[RO_Services|RO-module]] has access to it). An 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.<br />
<br />
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).<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| ARM9/ARM11 bootrom vectors point at unitialized RAM<br />
| ARM9's and ARM11's exception vectors are hardcoded to point at the CPU'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 to trigger an exception (such as an invalid instruction) will cause execution to fall into ARM9 RAM. <br />
Since RAM isn't cleared on boot (see below), one can immediately start execution of their own code here to dump bootrom, OTP, etc.<br />
| End of February 2014<br />
| [[User:Derrek|derrek]], WulfyStylez (May 2015) independently<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
This applies for New3DS too.<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No RAM clearing on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM keeps its contents.<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| 32bits of actual console-unique TWLNAND keydata<br />
| 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. Therefore, only the first 32bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.<br />
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).<br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
== ARM9 software ==<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| Missing verification-block for the 9.6 keys<br />
| Starting with [[9.6.0-24|9.6.0-X]] a new set of NAND-based keys were introduced. However, they forgot to add a verification block to verify that the new key read from NAND is correct. This was an issue from the very [[8.1.0-0_New3DS|beginning]] with the original sector+0 keydata, however the below is only possible with the sector+0x10 keydata.<br />
<br />
Thus, by writing an incorrect key to NAND you can make arm9loader decrypt ARM9 kernel as garbage and then jump to it.<br />
<br />
This allows an hardware-based NAND-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 eventually you'll find some garbage that jumps to your code.<br />
<br />
This should give you very early ARM9 code execution (pre-ARM9 kernel). For example, you can 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. 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 offset0 and has dumped the OTP area of the Old3DS.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| March, 2015<br />
| plutoo<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
The main 3DS RSA padding check code(non-certificate) uses the function used with the above to extract PKCS padding + the actual hash from the message. This is not a problem here however.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for (PXI) command replies<br />
| 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.<br />
Certain ARM11 service commands have this same issue as well.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.<br />
| 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.<br />
| Unknown, probably none.<br />
| ?<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| plutoo/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| plutoo, [[User:Yellows8|Yellows8]], maybe others(?)<br />
|}<br />
<br />
=== Kernel9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9<br />
| 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's never locked, you can dump it once you get ARM9 code execution. See [[OTP Registers|here]] regarding the data stored there.<br />
<br />
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.<br />
| Dumping of the [[OTP Registers|OTP]] area<br />
| [[3.0.0-5|3.0.0-X]]<br />
|<br />
| February 2015<br />
| plutoo, Normmatt independently<br />
|}<br />
<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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) requires patching the kernel .text or modifying SVC-access-control.<br />
| See description<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
|<br />
| Everyone<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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, this never seems to be used after that, however.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| <br />
| <br />
|-<br />
| memchunkhax<br />
| The kernel originally did not validate the data stored in the FCRAM kernel heap memchunk-headers for free-memory at all. Exploiting this requires raw R/W access to these memchunk-headers, like physical-memory access with gspwn.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs<br />
| The ARM11-kernel did access the 'key' 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:<br />
SlabHeap_free(KLinkedListNode);<br />
KObject *obj = KLinkedListNode->key; // the object there might have changed!<br />
This bug appeared all over the place.<br />
| ARM11-kernelmode code exec maybe<br />
| [[8.0.0-18|8.0.0-18]]<br />
| <br />
| April 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| plutoo, [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| plutoo<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| plutoo, [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| plutoo<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| December 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
<br />
FCRAM is gpu-accessible up to physaddr 0x26400000 on Old3DS, and 0x2DC00000 on New3DS.<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| smea, plutoo joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| June(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=KLinkedListNode&diff=12582KLinkedListNode2015-05-09T17:01:25Z<p>Derrek: </p>
<hr />
<div>[[Category:Kernel objects]]<br />
<br />
<br />
Size : 0xC bytes<br />
<br />
{| class="wikitable" border="1"<br />
|-<br />
! Offset<br />
! Type<br />
! Description<br />
|-<br />
| 0x0<br />
| KLinkedListNode* <br />
| Next<br />
|-<br />
| 0x4<br />
| KLinkedListNode* <br />
| Previous<br />
|-<br />
| 0x8<br />
| void*<br />
| Pointer to the node's data ('key' field).<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=125813DS System Flaws2015-05-09T17:00:37Z<p>Derrek: /* Kernel11 */ Multiple KLinkedListNode SlabHeap use after free bugs</p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there's a [[SVC]] for this, but only [[RO_Services|RO-module]] has access to it). An 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.<br />
<br />
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).<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
This applies for New3DS too.<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No RAM clearing on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM keeps its contents.<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| 32bits of actual console-unique TWLNAND keydata<br />
| 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. Therefore, only the first 32bits of the TWL console-unique keydata / TWL consoleID are actually console-unique.<br />
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).<br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
== ARM9 software ==<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| Missing verification-block for the 9.6 keys<br />
| Starting with [[9.6.0-24|9.6.0-X]] a new set of NAND-based keys were introduced. However, they forgot to add a verification block to verify that the new key read from NAND is correct. This was an issue from the very [[8.1.0-0_New3DS|beginning]] with the original sector+0 keydata, however the below is only possible with the sector+0x10 keydata.<br />
<br />
Thus, by writing an incorrect key to NAND you can make arm9loader decrypt ARM9 kernel as garbage and then jump to it.<br />
<br />
This allows an hardware-based NAND-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 eventually you'll find some garbage that jumps to your code.<br />
<br />
This should give you very early ARM9 code execution (pre-ARM9 kernel). For example, you can 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.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| March, 2015<br />
| plutoo<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
The main 3DS RSA padding check code(non-certificate) uses the function used with the above to extract PKCS padding + the actual hash from the message. This is not a problem here however.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for (PXI) command replies<br />
| 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.<br />
Certain ARM11 service commands have this same issue as well.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.<br />
| 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.<br />
| Unknown, probably none.<br />
| ?<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| plutoo/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| plutoo, [[User:Yellows8|Yellows8]], maybe others(?)<br />
|}<br />
<br />
=== Kernel9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Kernel9<br />
| 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's never locked, you can dump it once you get ARM9 code execution. See [[OTP Registers|here]] regarding the data stored there.<br />
<br />
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.<br />
| Dumping of the [[OTP Registers|OTP]] area<br />
| [[3.0.0-5|3.0.0-X]]<br />
|<br />
| February 2015<br />
| plutoo, Normmatt independently<br />
|}<br />
<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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) requires patching the kernel .text or modifying SVC-access-control.<br />
| See description<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
|<br />
| Everyone<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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, this never seems to be used after that, however.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| <br />
| <br />
|-<br />
| memchunkhax<br />
| The kernel originally did not validate the data stored in the FCRAM kernel heap memchunk-headers for free-memory at all. Exploiting this requires raw R/W access to these memchunk-headers, like physical-memory access with gspwn.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Multiple [[KLinkedListNode|KLinkedListNode]] SlabHeap use after free bugs<br />
| The ARM11-kernel did access the 'key' 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:<br />
SlabHeap_free(KLinkedListNode);<br />
KObject *obj = KLinkedListNode->key; // the object there might have changed!<br />
This bug appeared all over the place.<br />
| ARM11-kernelmode code exec maybe<br />
| [[8.0.0-18|8.0.0-18]]<br />
| <br />
| April 2015<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| plutoo, [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| plutoo<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| plutoo, [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| plutoo<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| December 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
<br />
FCRAM is gpu-accessible up to physaddr 0x26400000 on Old3DS, and 0x2DC00000 on New3DS.<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| smea, plutoo joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| [[9.7.0-25|9.7.0-X]]<br />
| June(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrekhttps://www.3dbrew.org/w/index.php?title=3DS_System_Flaws&diff=121723DS System Flaws2015-03-30T12:13:40Z<p>Derrek: digging up some old logs</p>
<hr />
<div>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]].<br />
<br />
=Stale / Rejected Efforts=<br />
* Neimod has been working on a RAM dumping setup for a little while now. He's de-soldered the 3DS's RAM chip and hooked it and the RAM pinouts on the 3DS' 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.<br />
<br />
* Someone (who will remain unnamed) has released CFW and CIA installers, all of which is copied from the work of others, or copyrighted material.<br />
<br />
==Tips and info==<br />
The 3DS uses the XN feature of the ARM11 processor. There's no official way from applications to enable executable permission for memory containing arbitrary unsigned code(there's a [[SVC]] for this, but only [[RO_Services|RO-module]] has access to it). An 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.<br />
<br />
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).<br />
<br />
Note that the publicly-available <v5.0 total-control exploits are [[FIRM|Process9]] exploits, not "kernel exploits".<br />
<br />
=System flaws=<br />
== Hardware ==<br />
{| class="wikitable" border="1"<br />
! Summary<br />
! Description<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| Missing AES key clearing<br />
| The hardware AES engine does not clear keys when doing a hard reset/reboot.<br />
This applies for New3DS too.<br />
| August 2014<br />
| Mathieulh/Others<br />
|-<br />
| No clearing on RAM on reboots<br />
| On an MCU-triggered reboot all RAM including FCRAM/ARM9 memory/AXIWRAM keeps its contents.<br />
| March 2014<br />
| [[User:Derrek|derrek]]<br />
|-<br />
| DSi / 3DS-TWL key-generator<br />
| 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.<br />
This applies to the keyX/keyY too.<br />
<br />
This attack does not work for the 3DS key-generator because keyslots 0-3 are only for TWL keys.<br />
| 2011<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
== ARM9 software ==<br />
=== arm9loader ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| Missing verification-block for the 9.6 keys<br />
| Starting with [[9.6.0-24|9.6.0-X]] a new set of NAND-based keys were introduced. However, they forgot to add a verification block to verify that the new key read from NAND is correct. This was an issue from the very [[8.1.0-0_New3DS|beginning]] with the original sector+0 keydata, however the below is only possible with the sector+0x10 keydata.<br />
<br />
Thus, by writing an incorrect key to NAND you can make arm9loader decrypt ARM9 kernel as garbage and then jump to it.<br />
<br />
This allows an hardware-based NAND-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 eventually (I approximated within 1-10 days) you'll find some garbage that jumps to your code.<br />
<br />
This should give you very early ARM9 code execution (pre-ARM9 kernel). For example, you can dump RSA keyslots with this and calculate the 6.x [[Savegames#6.0.0-11_Savegame_keyY|save]], and 7.x [[NCCH]] keys.<br />
| Recovery of 6.x [[Savegames#6.0.0-11_Savegame_keyY|save key]]/7.x [[NCCH]] key<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| March, 2015<br />
| plutoo<br />
|-<br />
| Uncleared New3DS keyslot 0x11<br />
| 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.<br />
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 <=v9.5 New3DS keyXs which are generated by keyslot 0x11.<br />
<br />
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]].<br />
| New3DS keyXs generation<br />
| 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]].<br />
| <br />
| February 3, 2015 (one day after [[9.5.0-22|9.5.0-X]] release)<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Process9 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| RSA signature padding checks<br />
| The TWL_FIRM RSA sig padding check code used for all TWL RSA sig-checks has issues, see [[FIRM|here]].<br />
The main 3DS RSA padding check code(non-certificate) uses the function used with the above to extract PKCS padding + the actual hash from the message. This is not a problem here however.<br />
| <br />
| None<br />
| [[9.5.0-22|9.5.0-X]]<br />
| March 2015<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| firmlaunch-hax: FIRM header ToCToU<br />
| This can't be exploited from ARM11 userland.<br />
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't expect "anything" besides the ARM9 to access this data.<br />
With [[9.5.0-22]] the address of this FIRM header was changed from a FCRAM address, to ARM9-only address 0x01fffc00.<br />
| ARM9 code execution<br />
| [[9.5.0-22]]<br />
| <br />
| 2012, 3 days after [[User:Yellows8|Yellows8]] started Process9 code RE.<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| Uninitialized data output for PXI command replies<br />
| 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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| ?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Filesystem_services_PXI|FSPXI]] OpenArchive SD permissions<br />
| Process9 does not use the exheader ARM9 access-mount permission flag for SD at all.<br />
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.<br />
| <br />
| None<br />
| [[9.3.0-21|9.3.0-X]]<br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[AMPXI:ExportDSiWare]] export path<br />
| 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 "<mountpoint>:/<path>".<br />
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.<br />
| Exporting of DSiWare to arbitrary Process9 file-paths, such as "nand:/<path>" etc. This isn't really useful since the data which gets written can't be controlled.<br />
| None<br />
| [[9.5.0-22]]<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[DSiWare_Exports]] [[CTCert]] verification<br />
| 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's still not(?) fixed.<br />
On 3DS however this is rather useless, due to the entire DSiWare .bin being encrypted with the console-unique movable.sed keyY.<br />
| 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.<br />
| Unknown, probably none.<br />
| ?<br />
| April 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Gamecard_Services_PXI]] unchecked REG_CTRCARDCNT transfer-size<br />
| 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't checked, thus out-of-bounds reads could be triggered(which is rather useless in this case).<br />
| Out-of-bounds read for a value which gets written to a register.<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] cmdbuf buffer overrun<br />
| The Process9 code responsible [[PXI_Registers|PXI]] communications didn't verify the size of the incoming command before writing it to a C++ member variable. <br />
| Probably ARM9 code execution<br />
| [[5.0.0-11|5.0.0-11]]<br />
| <br />
| March 2015, original timeframe if any unknown<br />
| plutoo/[[User:Yellows8|Yellows8]]/maybe others(?)<br />
|-<br />
| [[Application_Manager_Services_PXI|PXIAM]] command 0x003D0108(See also [[Application_Manager_Services|this]])<br />
| 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 <=0x2800.<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| May 2013<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[Process_Services_PXI|PS RSA]] commands buffer overflows<br />
| pxips9 cmd1(not accessible via ps:ps) and VerifyRsaSha256: unchecked copy to a buffer in Process9's .bss, from the input FCRAM buffer. The buffer is located before the pxi cmdhandler threads' stacks. SignRsaSha256 also has a buf overflow, but this isn't exploitable.<br />
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]].<br />
| ARM9 code execution<br />
| [[5.0.0-11|5.0.0-X]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[PXI_Registers|PXI]] pxi_id bad check<br />
| The Process9 code responsible for [[PXI_Registers|PXI]] communications read pxi_id as a signed char. There were two flaws:<br />
* They used it as index to a lookup-table without checking the value at all.<br />
* Another function verified that pxi_id < 7, allowing negative values to pass the check. This would also cause an out-of-range table-lookup.<br />
| Maybe ARM9 code execution<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| March 2015, originally 2012 for the first issue at least<br />
| plutoo, [[User:Yellows8|Yellows8]], maybe others(?)<br />
|-<br />
| [[CONFIG Registers#CFG_SYSPROT9|CFG_SYSPROT9]] bit1 not set by Process9<br />
| Old versions of Process9 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's never locked, you can dump it once you get ARM9 code execution. It is unknown what this region contains, but most likely per-console keys.<br />
<br />
From [[3.0.0-5|3.0.0-5]] this was fixed by setting the bit in Process9 after poking some registers in that region. On New3DS arm9loader sets this bit instead of Process9.<br />
<br />
| Dumping of per-console keys, probably<br />
| [[3.0.0-5|3.0.0-5]]<br />
|<br />
| February 2015<br />
| plutoo, Normmatt independently<br />
|}<br />
<br />
== ARM11 software ==<br />
=== Kernel11 ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SVC]] table too small<br />
| The table of function pointers for SVC'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.<br />
<br />
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't mapped as executable.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| 2012<br />
| Everyone<br />
|-<br />
| [[SVC|svcBackdoor (0x7B)]]<br />
| 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) requires patching the kernel .text or modifying SVC-access-control.<br />
| See description<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
|<br />
| Everyone<br />
|-<br />
| [[Memory_layout#ARM11_Detailed_virtual_memory_map|0xEFF00000]] / 0xDFF00000 ARM11 kernel virtual-memory<br />
| 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, this never seems to be used after that, however.<br />
| <br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| <br />
| <br />
|-<br />
| memchunkhax<br />
| The kernel originally did not validate the data stored in the FCRAM kernel heap memchunk-headers for free-memory at all. Exploiting this requires raw R/W access to these memchunk-headers, like physical-memory access with gspwn.<br />
<br />
There are ''multiple'' 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.<br />
<br />
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.<br />
| When combined with other flaws: ARM11-kernelmode code execution<br />
| [[9.3.0-21|9.3.0-21]]<br />
| <br />
| February 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| PXI [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11-kernel didn'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.<br />
| <br />
| [[6.0.0-11|6.0.0-11]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcStartInterProcessDma]]<br />
| For svcStartInterProcessDma, the kernel code had the following flaws:<br />
<br />
* 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.<br />
<br />
* Integer overflows for srcaddr+size and dstaddr+size are now checked(with [[6.0.0-11]]), which were not checked before.<br />
<br />
* 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 >=0x20000000 would result in the kernel reading from the process L1 MMU table, beyond the memory allocated for that MMU table(for vaddr->physaddr conversion). <br />
| <br />
| [[6.0.0-11]]<br />
| <br />
| DmaConfig issue: unknown. The rest: 2014<br />
| plutoo, [[User:Yellows8|Yellows8]] independently<br />
|-<br />
| [[SVC|svcControlMemory]] Parameter checks<br />
| For svcControlMemory the parameter check had these two flaws:<br />
<br />
* 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't actually use the input address for LINEAR memory-mapping at all besides the range-checks, so this isn'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.<br />
<br />
* Integer overflows on (addr0+size) are now checked that previously weren't (this also applies to most other address checks elsewhere in the kernel).<br />
<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
|<br />
| plutoo<br />
|-<br />
| [[RPC_Command_Structure|Command]] request/response buffer overflow<br />
| 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.<br />
<br />
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 <nowiki>((size<<14) | 2)</nowiki> to write arbitrary memory to any RW userland memory in the destination process.<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|SVC stack allocation overflows]]<br />
| <br />
* 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. <br />
* The alignment (size+7)&~7 calculation before allocation was not checked for integer overflow.<br />
<br />
This might allow for ARM11 kernel code-execution.<br />
<br />
(Applies to svcSetResourceLimitValues, svcGetThreadList, svcGetProcessList, svcReplyAndReceive, svcWaitSynchronizationN.)<br />
| <br />
| [[5.0.0-11]]<br />
| <br />
| v4.1 FIRM -> v5.0 code diff<br />
| plutoo, [[User:Yellows8|Yellows8]] complementary<br />
|-<br />
| [[SVC|svcControlMemory]] MemoryOperation MAP memory-permissions<br />
| 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't check memory permissions for addr1. Therefore .text as addr1 could be mapped elsewhere as RW- memory, which allowed ARM11 userland code-execution.<br />
| <br />
| [[4.1.0-8]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[RPC_Command_Structure|Command]] input/output buffer permissions<br />
| Originally the ARM11 kernel didn'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't have the required memory permissions. For example, this allowed a FSUSER file-read to .text, which therefore allowed ARM11-userland code execution.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[SVC|svcReadProcessMemory/svcWriteProcessMemory memory]] permissions<br />
| 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.<br />
| <br />
| [[4.0.0-7]]<br />
| <br />
| 2012?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== [[FIRM]] Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in [[FIRM]] system version<br />
! Last [[FIRM]] system version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[Services|"srv:pm"]] process registration<br />
| Originally any process had access to the port "srv:pm". The PID's used for the (un)registration commands are not checked either. This allowed any process to re-register itself with "srv:pm", and therefore allowed the process to give itself access to any service, bypassing the exheader service-access-control list.<br />
<br />
This was fixed in [[7.0.0-13]]: starting with [[7.0.0-13]] "srv:pm" is now a service instead of a globally accessible port. Only processes with PID'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 "srv:pm" 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.<br />
<br />
This flaw was needed for exploiting the <=v4.x Process9 PXI vulnerabilities from ARM11 userland ROP, since most applications don't have access to those service(s).<br />
| Access to arbitrary services<br />
| [[7.0.0-13]]<br />
| <br />
| 2012<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== Standalone Sysmodules ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in system-module system-version<br />
! Last system-module system-version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[SPI_Services|SPI]] service out-of-bounds write<br />
| cmd1 has out-of-bounds write allowing overwrite of some static variables in .data.<br />
| <br />
| None<br />
| [[9.5.0-22]]<br />
| March 2015<br />
| plutoo<br />
|-<br />
| [[NFC_Services|NFC]] module service command buf-overflows<br />
| NFC module copies data with certain commands, from command input buffers to stack without checking the size. These commands include the following, it's unknown if there's more commands with similar issues: "nfc:dev" <0x000C....> and "nfc:s" <0x0037....>.<br />
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.<br />
<br />
There's no known retail titles which have access to either of these services.<br />
| ROP under NFC module.<br />
| New3DS: None<br />
| New3DS: [[9.5.0-22]]<br />
| December 2014?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[News_Services|NEWSS]] service command notificationID validation failure<br />
| This module does not validate the input notificationID for <nowiki>"news:s"</nowiki> 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).<br />
| ROP under news module.<br />
| None<br />
| [[9.0.0-20]]<br />
| December 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[HID_Services|HID]] module shared-mem<br />
| 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.<br />
| ROP under HID module, but this is *very* unlikely to be exploitable since the data written is HID data.<br />
| None<br />
| [[9.3.0-21]]<br />
| 2014?<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| gspwn<br />
| 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're running under, and gain real code-execution from a ROP-chain. Normally applets' .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).<br />
| User-mode code execution.<br />
| None<br />
| [[9.6.0-24|9.6.0-X]]<br />
| Early 2014<br />
| smea, [[User:Yellows8|Yellows8]]/others before then<br />
|-<br />
| rohax<br />
| 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.<br />
<br />
This was fixed after [[ninjhax]] release by adding checks on [[CRO0]]-based pointers before writing to them.<br />
| Memory-mapping syscalls.<br />
| [[9.3.0-21]]<br />
| [[9.4.0-21]]<br />
| <br />
| smea, plutoo joint effort<br />
|-<br />
| Region free<br />
| Only [[Home Menu]] itself checks gamecards' 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.<br />
This essentially means launching the gamecard with the [[NS_and_APT_Services|"ns:s"]] 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]].<br />
| Launching gamecards from any region + bypassing Home Menu gamecard-sysupdate installation<br />
| None<br />
| [[9.5.0-22]]<br />
| June(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|-<br />
| [[NWM_Services|NWM]] service-cmd state null-ptr deref<br />
| 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.<br />
It's unknown whether any NWM services besides NWMUDS have this issue.<br />
| This is rather useless since it's only a crash caused by a state ptr based at 0x0.<br />
| None<br />
| [[9.0.0-20]]<br />
| 2013?<br />
| [[User:Yellows8|Yellows8]]<br />
|}<br />
<br />
=== General/CTRSDK ===<br />
{| class="wikitable" border="1"<br />
|-<br />
! Summary<br />
! Description<br />
! Successful exploitation result<br />
! Fixed in version<br />
! Last version this flaw was checked for<br />
! Timeframe this was discovered<br />
! Discovered by<br />
|-<br />
| [[NWM_Services|UDS]] beacon additional-data buffer overflow<br />
| 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.<br />
This was discovered while doing code RE with an old dlp-module version. It's unknown in what specific CTRSDK version this was fixed, or even what system-version updated titles with a fixed version.<br />
<br />
It's unknown if there's any titles using a vulnerable CTRSDK version which are also exploitable with this(dlp module can't be exploited with this).<br />
<br />
The maximum number of bytes that can be written beyond the end of the outbuf is 0x37-bytes, with additionaldata_size=0xFF.<br />
| Perhaps ROP, very difficult if possible with anything at all<br />
| ?<br />
| <br />
| September(?) 2014<br />
| [[User:Yellows8|Yellows8]]<br />
|}</div>Derrek