[00:00.000 --> 00:06.640] So we have a pre-recorded video, pre-recording from the speakers, and we're going to get started right now. [00:07.140 --> 00:07.900] Thanks. [00:30.000 --> 00:36.500] I completed this work together with my colleague Lishuang Song, and we were really looking forward to presenting in person. [00:36.500 --> 00:42.480] But unfortunately, due to visa application issue, we are unable to attend the event on site. [00:42.480 --> 00:45.300] And we sincerely apologize for this. [00:45.300 --> 00:51.060] And as a result, we have to share our presentations through a pre-recorded video instead. [00:51.060 --> 00:54.560] And if you have any questions, please feel free to contact us. [00:55.140 --> 00:57.020] So here, this is the agenda. [00:57.020 --> 00:59.040] So first is the introduction section. [00:59.040 --> 01:07.480] And after that, we will share where the story begins, and then I will analyze how it only works, and introduce the TorchScript engine. [01:07.480 --> 01:13.260] And finally, I will share the impact of this vulnerability, and share some defense recommendations and summary. [01:13.660 --> 01:15.380] So first, introduction. [01:15.920 --> 01:24.340] And PyTorch is a machine learning framework based on Torch Machine Learning Library, and it was developed by Facebook, and now it is an open source project. [01:24.340 --> 01:27.760] And it is very easy to use and has some really great features. [01:28.480 --> 01:37.440] And PyTorch is widely used in the field of deep learning research, natural language processing, or Corning LP, and computer vision. [01:37.900 --> 01:46.720] And to be honest, in the field of machine learning, there are many, many popular frameworks, and well-known projects like TensorFlow and Keras. [01:47.040 --> 01:55.560] But however, according to the paper with Kodo website, and you can see that PyTorch has undoubtedly been the most popular machine learning framework. [01:55.560 --> 02:01.640] If someone can find some bugs in such a famous AI framework, and that will be a really cool thing. [02:02.000 --> 02:05.720] And next comes the second part, where it all began. [02:06.240 --> 02:11.550] And in the early days, PyTorch used Pico to load and save models for convenience. [02:11.980 --> 02:23.710] However, Pico is one of the most well-known security issues in Python, and in fact, the official Python document was that using Pico can be unsafe, especially when loading untrusted data. [02:24.350 --> 02:32.510] So in 2021, someone raised an exception on GitHub and called for a solution to address the Pico issue in PyTorch. [02:32.510 --> 02:39.030] And finally, in 2022, PyTorch released a notable update introducing the waste-loading parameter. [02:39.910 --> 02:42.870] And let's briefly analyze the implementation of waste-loading. [02:42.870 --> 02:49.930] As you can see that by default, waste-loading is set to false, and it will use Pico to load the model. [02:49.930 --> 02:58.830] And if we set waste-loading equal true, you can see that it will use something called waste-only and Pico, and you can consider it as a restricted Pico. [02:59.030 --> 03:01.290] So now, let's try it out. [03:01.290 --> 03:06.510] So first, since by default, the waste-loading is false, and we will use Pico to load the model. [03:06.510 --> 03:12.670] So here we can easily create an eval model and use this reduce magic method. [03:12.670 --> 03:24.590] And you can see that after we save the model, and then we load this model, and you can see that we successfully execute the system command and we get the output route. [03:26.030 --> 03:36.170] And however, if we set waste-loading equal true, and you can see that it just threw an exception, and it seems that the vulnerability is effectively mitigated. [03:36.470 --> 03:43.790] And also on the official PyTorch website, and you can see that the consider-toys-to-load with waste-loading equal true is also secure. [03:43.790 --> 03:49.870] And it also warns that loading and trusting checkpoint with waste-loading equals false must never be done. [03:49.870 --> 03:59.250] And additionally, very similar security issues are discovered in other PyTorch-based components, and they often fix it by using waste-loading equal true. [03:59.250 --> 04:01.110] And here is an example. [04:01.110 --> 04:08.110] So initially, VLM used torch.load with all waste-loading equal true, and which introduced a security risk. [04:08.110 --> 04:12.610] And they fix it by simply add the waste-loading equal true parameter. [04:13.890 --> 04:24.490] And so not only VLM, and in general, the number of software is found to be using torch.load without waste-loading equal true, and the fix is also the same way, just adding the parameter. [04:24.490 --> 04:29.810] But here comes the question, can we blend in trust and security or waste-loading? [04:31.310 --> 04:36.110] So next part, we will dive deeper into it, how waste-loading actually works. [04:36.870 --> 04:40.890] And earlier, we point out that waste-loading is something like a restricted Pico. [04:40.890 --> 04:46.810] So before we analyze how waste-loading is implemented, and we need to understand how Pico works. [04:47.450 --> 04:56.290] And Pico is something like an interpreter, and it reads and interprets each opcode in sequence, and it's executing the corresponding operation. [04:56.290 --> 05:03.750] So for example, here, we first encounter the global opcode, and it will use the load global function. [05:03.750 --> 05:08.150] And you can see that it will call found class, and it will import this model. [05:08.150 --> 05:15.610] And so here, after we execute this command, and you can see that it will get the system function and push it onto the stack. [05:16.150 --> 05:20.190] And since now, we get the function, and we need to get the arguments. [05:20.230 --> 05:25.250] And so here, we can use the unicode opcode to read the string. [05:25.250 --> 05:27.810] And so here, we will get the Huamai. [05:27.870 --> 05:33.850] And since arguments must be in turbo format, and we need to wrap this string into a turbo. [05:33.850 --> 05:39.150] So we use this turbo1 opcode, and you can see that it will replace it with the turbo. [05:39.250 --> 05:44.850] And so here, after we execute the load turbo, and you can see that we wrap this string into a turbo. [05:44.850 --> 05:47.870] Now, we get the function and its arguments. [05:48.250 --> 05:52.710] So now, we can use the reduce opcode to execute this function. [05:52.710 --> 05:56.550] So here, we use the reduce, and it will execute the load reduce function. [05:56.650 --> 06:01.350] And you can see that it will get the arguments, get the function, and call it. [06:01.350 --> 06:03.490] So finally, we can get a command execution. [06:04.290 --> 06:06.910] So how does Visconi address this issue? [06:07.670 --> 06:16.210] And through the above example, and we can roughly say that the most dangerous part of the pcode deserialization is load global and load reduce. [06:16.210 --> 06:20.690] So Visconi and pcode just add some restriction to this dangerous opcode. [06:20.690 --> 06:27.330] Looking at the code, you can see that the load global function has some blacklist and whitelist. [06:28.810 --> 06:33.830] And also, load reduce is restricted in a similar way, and it has a whitelist. [06:35.610 --> 06:40.290] And so in general, Visconi is implemented using a whitelist and a blacklist. [06:40.290 --> 06:41.790] So how can we bypass? [06:42.750 --> 06:50.490] And a common approach is to analyze the whitelist and check whether there are any potential dangerous functions that could be exploited. [06:50.570 --> 06:54.670] And I did the same, but I didn't find anything useful in the end. [06:55.090 --> 06:58.530] And we are also limited by fixed ways of thinking. [06:58.530 --> 07:05.990] So for example, here in this case, most of us may only see the obvious whitelist and blacklist mechanism and stop here. [07:05.990 --> 07:12.310] But however, in reality, the loading process of Torch.load with Visconi equal true is quite complex. [07:12.310 --> 07:17.290] So is it possible that there might be some issues as well in the loading process? [07:17.290 --> 07:23.150] So I tried to conduct a complete analysis of the Visconi workflow to ensure nothing is missed. [07:24.070 --> 07:33.210] So I started analyzing the entire Torch.load process and stepping into the code and debugging the code line by line. [07:33.210 --> 07:38.970] And during one of my analysis, I noticed something very strange in the Torch.g.load. [07:38.970 --> 07:40.390] So what is that? [07:40.450 --> 07:42.170] And I had no idea with this. [07:42.170 --> 07:51.110] So I just searched it on Google and the document just said that Torch.g.load is something to use to load models in the TorchScript format. [07:51.110 --> 07:54.530] So now you can understand that why we named this topic. [07:54.830 --> 07:58.550] Yes, we will analyze and exploit the TorchScript engine. [07:59.290 --> 08:00.610] Hello, everyone. [08:00.610 --> 08:05.630] This part will cover the basics of TorchScript and its code implementation. [08:07.070 --> 08:14.730] TorchScript is used for deploying models in environments without a Python interpreter, such as CPP and mobile. [08:14.730 --> 08:24.390] It can be compiled from Python code through scripting or tracing, and saved as a PDF file which can be loaded and run in CPP and mobile. [08:24.390 --> 08:28.670] The save and load process involves serialization. [08:28.670 --> 08:41.830] I will explain how Python code is compiled to TorchScript, the serialization and deserialization process, the structure of PDF files, and finally, how it executes. [08:42.290 --> 08:50.130] First, we can use TorchJIT Creator to script one Python function to TorchScript. [08:50.130 --> 08:57.070] The steps to compile are, first, press Python source code into a Python AST. [08:57.070 --> 09:01.310] Second, convert the Python AST to a JIT AST. [09:01.310 --> 09:05.550] Third, transform the JIT AST into an AR graph. [09:06.150 --> 09:16.950] The AR graph initially contains many unnecessary nodes, which are eliminated through optimization to make it more concise. [09:18.270 --> 09:21.890] Let's take a deep look about the compile process. [09:21.890 --> 09:26.670] Before we start, I need to show what is the function and model in this context. [09:27.070 --> 09:32.470] You can see that one is a function, the other is a class. [09:32.470 --> 09:39.500] The scripting process for these two are somewhat different, so we will introduce them separately. [09:40.650 --> 09:43.830] Let's look at the function first. [09:43.850 --> 09:49.670] The compile process is handled within the script mpl function. [09:49.670 --> 09:55.530] There are two main functions, getJITDev and JITScriptCompile. [09:55.530 --> 10:00.210] The getJITDev function performs two main tasks. [10:00.330 --> 10:06.370] First, it uses the AST library to convert Python code into a Python AST. [10:06.370 --> 10:15.110] And second, it calls buildDev to transform that Python AST into a self-implemented JIT AST. [10:17.050 --> 10:21.290] JITScriptCompile is a function bound from CPP to Python. [10:21.290 --> 10:31.110] With its implementation in the CPP layer, it further converts the JIT AST to AR within the CPP code. [10:32.070 --> 10:41.510] It eventually invokes the toAR function, which finishes the transformation from JIT AST to AR. [10:41.610 --> 10:49.070] Additionally, toAR also calls some optimization functions to simplify the AR graph. [10:49.070 --> 10:52.530] Now the function compile process is done. [10:52.530 --> 10:57.010] A high-level understanding of the process is enough for this sharing. [10:57.010 --> 11:06.590] If you are interested in the compile source code details, you can use the code stack I have provided to navigate through the source code. [11:07.350 --> 11:09.750] Then let's look at the model. [11:09.950 --> 11:14.470] The overall process is similar to that of functions. [11:14.470 --> 11:18.150] Expect that there is an additional step at the beginning. [11:18.150 --> 11:21.330] Retrieving all functions from the model. [11:21.330 --> 11:26.870] It needs to retrieve functions and compile functions one by one. [11:26.870 --> 11:31.870] The stub fn function is responsible for handling this. [11:32.490 --> 11:38.630] Stub's fn is analyzed for infer methods to compile in this connect. [11:38.630 --> 11:43.710] Let's see what the infer method to compile function does. [11:44.270 --> 11:55.310] In the infer methods to compile function, it first uses dir to get all attributes and methods of the model. [11:55.310 --> 12:07.390] After filtering, it saves the methods that need to be exported, thereby collecting all functions in the model that requires compilation. [12:08.750 --> 12:24.550] The make stub fn method converts the collected functions into JLTST using the getJLTDEF function, which is the same one used during function compilation. [12:25.510 --> 12:50.600] Back to create a separate model MPL, the method stubs variable stores the JLTST we just converted, and the create methods and properties from stubs fn takes two method stubs as input and is responsible for converting it to AR. [12:52.220 --> 12:59.780] We can see that this call stack is similar to the call stack for function compilation. [13:00.190 --> 13:05.450] Both eventually finish the conversion into AR function. [13:05.450 --> 13:11.310] Now the model compile process is done. [13:11.310 --> 13:15.330] Overall, some key steps are the same as for function. [13:15.330 --> 13:23.070] Both use getJLTDEF to convert Python to JLTST, then convert it to AR through toAR. [13:24.270 --> 13:30.470] The serialization filter can save models and deploy them to other environments. [13:30.470 --> 13:34.090] Use touchsave to save model as pdfile. [13:34.090 --> 13:37.250] Use touchload to load pdfile as model. [13:37.450 --> 13:40.650] The Python code here is converted from AR. [13:40.650 --> 13:44.750] You will notice it's slightly different than the original code. [13:46.070 --> 13:52.390] Let's see how separate function and separate model is serialized. [13:52.570 --> 13:58.330] Separate function has an additional step compared to separate model. [13:58.330 --> 14:02.470] It needs to be converted to separate model first. [14:02.470 --> 14:06.370] After that, both call serialize for serialization. [14:06.430 --> 14:15.630] During the serialization process, some information is stored in the data.pkl and constants.pkl in big format. [14:15.630 --> 14:23.010] Additionally, it saves the Python code converted from AR and debug info to the code folder. [14:24.830 --> 14:32.990] To summarize the save process, for touch function, first convert it to touch model. [14:32.990 --> 14:36.030] The remaining process is the same. [14:36.030 --> 14:43.950] First, the app value corresponding to the model is serialized in PQL format as data.pkl. [14:44.330 --> 14:51.270] Second, obtain code and debug info via Python print and write to code directory. [14:51.970 --> 14:56.730] Third, save tensor constants to constants.pkl. [14:56.730 --> 14:59.710] Now the serialization is done. [14:59.710 --> 15:03.670] Let's look at the detail of the PTFEW. [15:05.030 --> 15:11.310] The PTFEW is compressed achieve using ZIP compression. [15:11.870 --> 15:16.410] The field tree after decompression is shown above. [15:16.410 --> 15:21.250] And we can use PicoTools to disassemble it. [15:21.270 --> 15:26.750] Above is the disassembled output of data.pkl. [15:26.750 --> 15:38.210] The meaning of this PicoTools is create an object named touch placeholder model and set its training attribute to true. [15:38.210 --> 15:43.130] And the touch placeholder model object is a secret model. [15:43.150 --> 15:49.070] So when interpreting data.pkl, secret model object is created. [15:51.270 --> 15:58.970] The constants.pkl contains Pico code, which can create a value object with tensor. [15:59.230 --> 16:03.550] The touch.py field contains Python code strings. [16:03.550 --> 16:12.150] It's the same as the content of the code attribute in secret model because they are obtained in the same way. [16:12.150 --> 16:20.750] OK, now we understand the three most important parts saved in the serialized field. [16:20.750 --> 16:27.110] Data.pkl, constants.pkl, and the source code in the code directory. [16:27.450 --> 16:34.690] Let's see how these parts are restored into a secret model. [16:35.890 --> 16:48.610] We can see that in the deserialized function, the three main parts of the serialized field are converted into a secret model. [16:48.610 --> 16:51.970] Let's look at the function implementation. [16:53.530 --> 17:00.210] Deserialize will call read achieve to read constants.pkl and data.pkl. [17:00.210 --> 17:07.250] Then we'll get one model in CPP, which is a secret model in Python. [17:07.830 --> 17:21.870] During the deserialization process, first I'm picking constants.pkl to obtain tensor constants, then save them in constants.table. [17:21.870 --> 17:29.450] Second, I'm picking data.pkl during the process of I'm picking data.pkl. [17:31.710 --> 17:44.750] Relevant source code is read from the code directory and pressed as needed, and the related constants are also read from the constants.table. [17:44.750 --> 17:57.910] The code processing process includes converting Python code to custom tokens, and then transforming tokens into JIT-ST, and finally into AR. [17:57.910 --> 18:06.950] This process differs significantly from the earlier Python-to-Tetrascript compilation. [18:08.570 --> 18:17.710] To summarize the load process, first, reach main logic via deserialization. [18:17.710 --> 18:29.430] Second, call read achieve to read constants.pkl, convert constants to n-values by I'm picking and save them to constants.table. [18:30.230 --> 18:36.930] Third, call read achieve to read data.pkl, restore corresponding n-values by I'm picking data. [18:38.410 --> 18:55.570] Fourth, during data.pkl I'm picking, source importer reads code fields and constants.table to restore AR through pressTab to find namedTab to import namedTab. [18:55.570 --> 19:04.510] Now the deserialization is done, let's take a look at how Tetrascript is running. [19:04.930 --> 19:18.090] The AR graph contains many nodes, and every node contains three parts, yin, output, and opcode. [19:18.090 --> 19:21.190] Opcode is the key to execution. [19:21.770 --> 19:33.730] The process of executing Tetrascript is to iterate through the AR and convert it into instructions. [19:33.730 --> 19:37.870] Then interpret the instructions. [19:37.870 --> 19:41.410] Every instruction has one opcode. [19:41.410 --> 19:52.370] There is a switch table here that finds the corresponding process logic through the op and the execute set. [19:52.590 --> 20:00.030] Now we have a basic understanding of the Tetrascript workflow. [20:00.940 --> 20:05.010] While reading the code, I discovered something interesting. [20:05.010 --> 20:11.150] There is one opcode named op, and it can do a call on operator table. [20:11.150 --> 20:15.990] An operator table contains many functions corresponding to operators. [20:15.990 --> 20:20.070] I'm curious about what operators they are. [20:21.500 --> 20:31.470] Some built-in functions register themselves as operators, requiring op instructions to call corresponding functions. [20:31.670 --> 20:41.850] The registerOperator class manages these operators, and registers them by registerOperator function. [20:41.850 --> 20:48.110] I page the PyTorch code and add one function to output all operators. [20:48.110 --> 20:53.130] You can see there are over 2000 operators here. [20:54.570 --> 20:58.890] Are all these operators safe? [20:59.530 --> 21:10.910] During our code audit of these operators, we discovered two interesting operators, save and fulfill. [21:11.510 --> 21:17.990] Here we can see the corresponding implementations of these two functions. [21:17.990 --> 21:24.630] The save function will save specified value as a model to specified field. [21:25.370 --> 21:30.390] This can lead to arbitrary field writes. [21:30.390 --> 21:36.150] But the saved field contains a lot of dirty data, which model information. [21:36.170 --> 21:46.290] The fulfill function will read the field which I specified, and convert the field contained to tensor. [21:46.290 --> 21:51.310] Then return the tensor, we can get the field contained from the tensor. [21:52.810 --> 21:57.210] Now we know these two operators have vulnerabilities. [21:58.650 --> 22:01.550] But there is still a problem. [22:01.550 --> 22:04.210] How to call them from touch script? [22:05.470 --> 22:12.230] To get the answer, we need to first understand the operator registering process. [22:12.230 --> 22:19.930] The getBuildingTable function registers some object member functions to building of ops. [22:20.050 --> 22:27.790] And during this process, it also adds prefixes to the member functions for rename. [22:27.790 --> 22:37.730] Finally, the address of these functions and their modified names will be placed into built-in table. [22:37.730 --> 22:52.370] During the touch script compilation process, two shrugged values will be triggered, where it checks whether the Python object exists in the built-in table. [22:52.370 --> 22:56.910] If it exists, it returns a built-in function. [22:57.630 --> 23:05.990] Finally, this built-in function will be inserted into the AR graph through emitter built-in call. [23:06.650 --> 23:20.930] Back to the built-in registering process, we now understand that add and save may come from one of these objects in models containing built-ins. [23:20.930 --> 23:35.950] By testing each object individually for the presence of a save function, we will find that the save function exists in the touch object. [23:36.090 --> 23:40.710] Adding from field can also be obtained in the same way. [23:41.350 --> 23:50.130] So, we just need to call touchSave() or touchFromField() to get arbitrary field write ability in touch script. [23:50.830 --> 24:05.290] Now, we can try writing a field to get RCE, but since there are some dirty characters, only specified special fields will work. [24:06.710 --> 24:26.790] Though we want to call and type a field because of a permission mismatch, our script uses touchSave(), which writes a field with 644 permissions, but the current demo requires 6000 permissions. [24:27.690 --> 24:30.370] Here is one poke video. [25:06.270 --> 25:08.820] Okay, you can see we get RCE. [25:12.180 --> 25:20.770] The vulnerabilities we have discussed so far might be more similar to logic vulnerabilities. [25:20.850 --> 25:26.910] On the other hand, some hackers may prefer memory-related vulnerabilities. [25:26.910 --> 25:31.750] We have also discovered a few overflow issues. [25:32.470 --> 25:40.950] Here you can see that when we load this modelpt field, it triggers a heap overflow. [25:40.950 --> 25:49.290] As a result, we can observe that the heap address and the loaded address of the library are leaked. [25:51.630 --> 25:54.230] This is one poke video. [26:10.270 --> 26:15.430] Okay, you can see we get RCE by memory bug. [26:16.510 --> 26:23.030] But due to time limited, we won't go into them in great detail here. [26:23.030 --> 26:25.710] We hope to share them in the future. [26:27.950 --> 26:31.890] This is the full details of the CVE. [26:33.010 --> 26:37.190] The fix is also relatively simple. [26:37.190 --> 26:43.970] It prevents the use of touchscript when voice-only is enabled. [26:44.510 --> 26:47.370] So what is the impact of this vulnerability? [26:47.830 --> 26:55.210] The entire AI ecosystem, like this house and petology, is one of the fundamental components. [26:55.210 --> 27:03.970] If there is an issue with the petology, just like we have removed one of the bottom-level components, the entire AI ecosystem is then compromised. [27:04.690 --> 27:08.350] We did a simple search on GitHub for projects using voice-only code. [27:08.470 --> 27:12.990] We can see that in fact, many projects use it in this way. [27:13.230 --> 27:19.170] Here we select two well-known projects as an example to illustrate the impact of this vulnerability. [27:19.390 --> 27:22.490] One is VOM and the other is Transformers. [27:22.490 --> 27:30.610] VOM is a high-performance library for efficient large-language model inference and optimized for speed and memory usage. [27:30.990 --> 27:32.390] So why did I choose it? [27:32.390 --> 27:42.190] Because it has a CVE number and you can see that it uses the torch.load function and the voice-only parameter is the default value of force, so it has an RCE vulnerability. [27:42.650 --> 27:46.190] The fix is very simple, just add the voice-only parameter. [27:46.550 --> 27:53.650] This seems to solve the problem, but because of the petology issue, mitigation ends up being ineffective. [27:54.730 --> 27:58.950] And the sea harbor you once saw was actually also waters. [28:00.030 --> 28:11.470] And at the same time, I found a very interesting phenomenon and you can see that when I check this requirements.cpu.txt and you can see that it just hard-coded the torch version. [28:11.850 --> 28:16.990] And also in the GPU version, you can see that it also hard-coded the torch version. [28:17.350 --> 28:18.750] So what does this mean? [28:18.750 --> 28:28.210] It means that even if PyTorch released a new patched version and users of VRM cannot update it timely because VRM has hard-coded the version. [28:28.210 --> 28:33.650] So as a result, the users will remain exposed to this vulnerability for a long period. [28:34.430 --> 28:36.410] And so now let's set up the environment. [28:36.410 --> 28:45.290] Since the latest VRM has already patched its issue, so we need to install the old version, exactly 0.7.3. [28:45.290 --> 28:51.070] And you can see that when you install VRM, then it will install the exact version of torch. [28:52.250 --> 28:58.310] And so here we will use this function as an example to illustrate the existence of the vulnerability. [28:59.330 --> 29:02.230] And at first, I didn't think too much about that. [29:02.230 --> 29:08.410] I just want to take the poke from the previous vulnerability and just hoping for one should succeed. [29:08.430 --> 29:14.570] And you can see that finally, we will definitely enter the logic we want and it will load our email model. [29:14.570 --> 29:15.990] So we are ready to proceed. [29:16.570 --> 29:20.950] But it failed and you can see that we don't create this fail, so why? [29:21.970 --> 29:34.610] And let's take a look at the previous poke and you can see that after we use torch.load to load this model and we need to call the model to invoke the model in order to trigger this forward logic. [29:35.050 --> 29:40.090] But here you can see after we load this evil model and it didn't invoke the model. [29:40.090 --> 29:43.190] It just fetched the items and then deleted the model. [29:43.190 --> 29:45.370] So this model was not invoked. [29:46.170 --> 29:48.810] And is it really an end? [29:49.750 --> 29:56.230] And at that point, I noticed the error message and it says that the model don't have the attribute items. [29:56.230 --> 29:59.130] And this error message gave me some inspiration. [30:00.490 --> 30:08.070] And items is essentially a keyword in Python and it is used to iterate the dictionary type object. [30:08.170 --> 30:11.390] So you can see that in fact, items is a function. [30:11.390 --> 30:14.390] So here can we spoof the function name? [30:15.130 --> 30:22.590] And so here I just try for the first time and you can see that I change the function name from forward to item and just run the code. [30:22.590 --> 30:27.690] And you can see that why it is still saying that our model don't have the items attribute. [30:28.910 --> 30:43.110] But if we write in this way and you can see that we just call the items function in our forward logic and we run a code and you can see that we successfully create a field and this means we succeed. [30:43.330 --> 30:52.790] And this is very strange and the reason is that when retrieving model functions, it determines whether these functions need to be exported. [30:52.790 --> 31:04.750] For functions not decorated as exports and a lazy export strategy is adopted, meaning that they are only exported if called within the exported function. [31:04.790 --> 31:11.330] So here you can see that in the left picture, we just decorated our items function with exported. [31:11.330 --> 31:16.850] So here it will export the item function and we can get this item attribute. [31:16.930 --> 31:26.730] And in the right picture and you can see that since we call it in our exported function forward and our object, we also have this item function. [31:27.670 --> 31:34.990] And so finally, we report our ability to the official team and who highly acknowledge our work. [31:35.010 --> 31:40.970] And you can see that I said it's very interesting since PyTorch document claims it is safe. [31:41.670 --> 31:45.630] And the patch is very simple, just change this version. [31:46.570 --> 31:48.170] And next, Transformers. [31:48.210 --> 31:59.030] Transformers is a popular open source library by Hugging Face and provided pre-trained models and tools for natural language processing tasks using the transformer-based architecture. [31:59.970 --> 32:03.790] And Transformers also implemented some security hardening measures. [32:03.790 --> 32:09.210] For example, here you can see that it just used which only equals true to load the model. [32:10.150 --> 32:21.210] And for now, we set our environment and you can see that since the latest version of Transformers also fixed this issue and we need to install our old version 4.51.3. [32:21.390 --> 32:34.290] And here, this is the official document example from Transformers and you can see that we need to load the model from Hugging Face and create a pipeline and then we can create our conversation. [32:34.290 --> 32:36.670] So, here, for example, we just ask a question. [32:36.670 --> 32:41.670] And you can see that just give me some answer. [32:42.390 --> 32:52.530] And here, this is my demo project and you can see that we only have three fields, readme, config.json, and a test PyTorch field. [32:52.530 --> 32:54.390] And it doesn't contain any evil code. [32:55.150 --> 33:02.610] And if we run the code and you can see that it will use Torch.load to load our remote PyTorch model. [33:03.030 --> 33:10.510] And let me introduce this code and when we load a remote Hugging Face repo, then it will load this model. [33:10.510 --> 33:15.770] And by default, fields in C tensors or PyTorch is allowed. [33:16.950 --> 33:22.950] And just like the previous VRM vulnerability and it will call the keys function. [33:23.570 --> 33:31.250] So, we can just change the function from items to keys and we save the project in our local repo. [33:31.890 --> 33:38.430] And, of course, if we run this code and you can see that we can exploit and we can create this field. [33:39.290 --> 33:46.490] And after that, we call this vulnerability to Hugging Face and you can see that it just patched it. [33:46.490 --> 33:48.330] And the patch is also very simple. [33:48.330 --> 33:51.690] You can see that it can check Torch.load is safe. [33:51.690 --> 33:56.530] It checks the Torch version greater or equal than 2.6. [33:57.250 --> 34:00.370] And finally, it defends a summary. [34:00.690 --> 34:05.110] So, now, if you are still using your own version of PyTorch, please update. [34:05.850 --> 34:07.910] And here is also some recommendations. [34:07.910 --> 34:15.910] So, for example, from the model format perspective, we should use more secure format like safe tensors. [34:16.150 --> 34:26.090] And also from the model community perspective, we should scan and flag malicious models and Hugging Face has already done the relevant work. [34:26.270 --> 34:33.250] And also from the user perspective, we should not load untrusted models and it is better to load them in a sandbox. [34:34.650 --> 34:36.610] So, any questions? [34:38.530 --> 34:40.410] And thanks again for listening. [34:40.410 --> 34:44.290] And if you have any questions, please feel free to contact us at any time.