Editing Vulnerabilities

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 279: Line 279:
|?
|?
|Jak X: Combat Racing (PAL and NTSC, PAL has more symbols)
|Jak X: Combat Racing (PAL and NTSC, PAL has more symbols)
|Two exploits: String Buffer Overflow via unchecked profile name length (implemented) and Custom code injection via patch.bin file (not implemented)
|Two exploits: String Buffer Overflow via unchecked profile name copy during saving and Custom code injection via patch.bin file
|When saving data, the profile name can be copied out-of-bounds, allowing to redirect code execution. By injecting a signed file named patch.bin in the savedata folder, custom code can be executed by the game.
|When saving data, the profile name can be copied out-of-bounds. By injecting a signed file named patch.bin in the savedata folder, custom code can be executed by the game.
|Maybe in Greatest Hits/Platinum release (to be documented)
|Maybe in Greatest Hits/Platinum release
|September 26th, 2024
|September 26th, 2024
|CelesteBlue
|CelesteBlue
Line 433: Line 433:
See also [https://jakanddaxter.fandom.com/wiki/Bugs Jak and Daxter games bugs on jakanddaxter.fandom.com].
See also [https://jakanddaxter.fandom.com/wiki/Bugs Jak and Daxter games bugs on jakanddaxter.fandom.com].


===== Profile name string overflow during saving - Jak a dit a dit haX =====
===== Profile name string overflow during saving =====


Discovered and exploited by CelesteBlue on September 26th, 2024.
A profile name is asked to the player when starting a new game, and the length is limited to 12 characters by keyboard. However, by crafting a custom savedata, it is possible to use longer profile names.  


A profile name is asked to the player when starting a new game, and the length is limited to 12 characters by keyboard. However, by crafting a custom savedata, it is possible to use a longer profile name where the 20, 21, 22 and 23th bytes overwrite the $v1 register when the game saves. This leads to $pc redirection and so to code execution by planting a shellcode in the savedata body.
The game displays up to ?32? characters of the profile name, loaded from the header of each savedata file. The header profile name is only used for display and does not create any bug when overflown except visual ones during savedata loading. The body profile name must not be too long else the game freezes during loading savedata. If it is short enough, the savedata loads fine, but being long enough it can overflow and be used for exploitation when saving data. When the body filename length is intermediate, the savedata can be loaded, the overflow occurs, but when saving data, instead of saving properly or crashing, the game enters an infinite loop like with the other classical savedata bug.


Before loading a savedata, the game asks the user to choose between available ones. The game displays the profile names of the savedata, loaded from the header of each savedata file. The header profile name is only used for display and does not create any bug when overflown except visual ones during savedata loading. The body profile name must not be too long else the game freezes during loading savedata. If it is short enough, the savedata loads fine, but being long enough it can overflow and be used for exploitation when saving data. When the body filename length is intermediate, the savedata can be loaded, the overflow occurs, but when saving data, instead of saving properly or crashing, the game enters an infinite loop like with the other classical savedata bug.
* Normal profile name should be between 1 and 12 characters.
 
The profile name length is an important parameter of the behaviour of the game:
* Profile name should be between 1 and 12 characters if no hack was used.
* Extending profile name to between 13 and 19 characters does not create any bug.
* Extending profile name to between 13 and 19 characters does not create any bug.
* With a profile name of 20 characters or more, the game will be affected. During the load of an evil savedata, there is not necessarily any strange behaviour except the graphical glitches of too long profile name, however when saving with this extended profile name, the game crashes.
* With a profile name of 20 characters or more, the game will be affected. During the load of an evil savedata, there is not necessarily any strange behaviour except the graphical glitches of profile name display, however when saving with this extended profile name, the game crashes.
* Between 20 and 23 characters, the savedata can be loaded and when saving data, the game crashes with user-controlled $pc. The best choice is 23 characters since it allows to control the four bytes of the $v1 register, whilst using 20 characters only control one byte of $v1.
* Between 20 and 23 characters, the savedata can be loaded and when saving data, the game crashes with user-controlled $pc. Sadly in this case, the $pc can only be set to 256 hardcoded values of which none points to user-controlled memory, so there is no easy way to launch a shellcode.
* Between 24 and ? characters, the savedata can be loaded but when saving data, the game enters an infinite loop.
* Between 24 and ? characters, the savedata can be loaded but when saving data, the game enters an infinite loop.
* With ? or more characters, the savedata cannot be loaded because the game freezes.
* With ? or more characters, the savedata cannot be loaded because the game freezes.
* It is not possible to load a profile name longer than (0x6400-0x50=0x63B0) characters because the body size and profile name offset are hardcoded.
* It is not possible to load a profile name longer than (0x6400-0x50=0x63B0) characters because the body size and profile name offset are hardcoded.


Using a profile name longer than 19 characters overwrites $v1 with the DWORD at offset 19 of the profile name in the savedata body. The game remains stable when using 23 characters and there is no advantage in using more characters.
Tests has shown that the final $pc is 0 and that $v1 contains the DWORD at offset 19 of the profile name. Other registers have not been controlled by now.
 
The constants for exploitation of Jak X NTSC (SCUS-97429) are:
<pre>
shellcode_ptr_addr = 0x248838 - 0x34 = 0x248804
shellcode_addr = 0x71C728
shellcode size = 0x6400 - 0x50 - 0x13 - 4 = 0x6399 (about 25 kB)
shelldata_size = 0x400 - 0x40 - 4 - 4 = 0x3B8 (about 1 kB)
</pre>
 
It is required to craft valid header and footer in the savedata files else the game loops infinitely on the savedata loading screen. A Jak X savedata contains a few files of name format "saveX-Y-ZZZZZZZZ.bin" where X, Y, and Z are some decimal numbers. The default savedata files that are created by the player are:
* save0-3-00000001.bin
* save1-1-00000000.bin
* save2-2-00000000.bin
* save3-3-00000000.bin
* save4-0-00000000.bin


The Jak X savedata files follow mostly the same structure as Jak 1, 2 and 3 but with a different magic (0xc0dfaced) and a different checksum algorithm (CRC32). The file is made of a 0x400-byte header followed by 0x6400 bytes of body and a footer that is just a 1:1 copy of the header. To craft a valid Jak X savedata, the steps are:
It is required to craft valid header and footer in the savedata else the game loops infinitely on the save data loading screen. A Jak X (NTSC version) savedata contains a few files of name "saveX-Y-ZZZZZZZZ.bin" where X, Y, and Z are valid decimal numbers. They follow mostly the same structure as Jak 1, 2 and 3 but with a different magic (0xc0dfaced) and different checksum algorithm (CRC32). The file is made of a 0x400-byte header followed by 0x6400 bytes of body and a footer that is just a 1:1 copy of the header. To craft a valid Jak X savedata, the steps are:
* generate a valid body, eventually with extended profile name
* generate a valid body, eventually with extended profile name
* generate a default header with valid magic, profile name, etc.
* generate a default header with valid magic, profile name, etc.
Please note that all contributions to PS2 Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PS2 Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)