<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[The MLSecOps Hacker Newsletter]]></title><description><![CDATA[Mapping The AI Security Landscape: weekly insights on AI governance, GenAI threat modeling and deep-dives on MLSecOps best practices, tooling and attack vectors. 
 
FOR CISOs, Security Professionals and AI Engineers.]]></description><link>https://themlsecopshacker.com</link><image><url>https://substackcdn.com/image/fetch/$s_!671Q!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c61e7d-4b6d-4195-8592-5cdde6d3f82e_1024x1024.png</url><title>The MLSecOps Hacker Newsletter</title><link>https://themlsecopshacker.com</link></image><generator>Substack</generator><lastBuildDate>Thu, 07 May 2026 08:25:16 GMT</lastBuildDate><atom:link href="https://themlsecopshacker.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Riccardo Biosas]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[riccardobiosas@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[riccardobiosas@substack.com]]></itunes:email><itunes:name><![CDATA[Riccardo Biosas]]></itunes:name></itunes:owner><itunes:author><![CDATA[Riccardo Biosas]]></itunes:author><googleplay:owner><![CDATA[riccardobiosas@substack.com]]></googleplay:owner><googleplay:email><![CDATA[riccardobiosas@substack.com]]></googleplay:email><googleplay:author><![CDATA[Riccardo Biosas]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[AI Security: Model Serialization Attacks]]></title><description><![CDATA[Navigating the Pitfalls of Model Serialization And ML Supply Chain Vulnerabilities: Best Practices for AI Security]]></description><link>https://themlsecopshacker.com/p/ai-security-model-serialization-attacks</link><guid isPermaLink="false">https://themlsecopshacker.com/p/ai-security-model-serialization-attacks</guid><dc:creator><![CDATA[Riccardo Biosas]]></dc:creator><pubDate>Mon, 04 Nov 2024 12:42:17 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <strong>AI security</strong> landscape is fraught with <strong>novel attack vectors that exploit the unique vulnerabilities of machine learning systems</strong>: <strong><a href="https://owasp.org/www-project-machine-learning-security-top-10/docs/ML10_2023-Model_Poisoning">model poisoning</a></strong> and <strong><a href="https://scaling-attacks.net/">image scaling attacks</a></strong>, for example, represent a new wave of threats that are distinctly different from those found in the more traditional AppSec or Cloud security ecosystems.</p><p>Unlike the previous examples, this article focuses on a familiar attack vector: <strong>the execution of untrusted code</strong>. This long-standing issue has plagued application security for decades, and the AI field is no exception. In fact, the problem of dealing with untrusted code is just as relevant in AI as it is in other areas of cybersecurity.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://gist.github.com/RiccardoBiosas/e5a43cdd58699d6c2e9f3372281f3a05" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dSCw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 424w, https://substackcdn.com/image/fetch/$s_!dSCw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 848w, https://substackcdn.com/image/fetch/$s_!dSCw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!dSCw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dSCw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png" width="1120" height="1080" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1080,&quot;width&quot;:1120,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:196578,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:&quot;https://gist.github.com/RiccardoBiosas/e5a43cdd58699d6c2e9f3372281f3a05&quot;,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dSCw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 424w, https://substackcdn.com/image/fetch/$s_!dSCw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 848w, https://substackcdn.com/image/fetch/$s_!dSCw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!dSCw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F868ec3a7-1a1d-447f-959e-1adbfc615441_1120x1080.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><h5><strong><a href="https://gist.github.com/RiccardoBiosas/e5a43cdd58699d6c2e9f3372281f3a05">A vulnerable Flask API</a> that feeds unsanitized user input to the <a href="https://docs.python.org/3/library/functions.html#eval">infamous Python `eval`</a>:           </strong></h5></blockquote><p>One of the core principles in InfoSec is to <strong>never run untrusted code without first thoroughly validating and sanitizing</strong> its inputs, strictly limiting its execution environment through <strong>sandboxing</strong> or virtualization, and applying the <strong>principle of least privilege</strong> to minimize the blast radius in case of a compromise.</p><p>As we mentioned in <a href="https://themlsecopshacker.com/i/145901045/temporary-security-weaknesses-in-the-ai-industry">our first article</a><strong>, the machine learning industry is at a less mature stage in terms of security culture</strong> than the cloud and application development ecosystems. This is partly because, until not too long ago, the AI field was partially decoupled from customer-facing commercial applications as a substantial portion of its practitioners were scholars. </p><h2><strong>Understanding Model Serialization Attacks</strong></h2><p><strong>Model Serialization Attacks are one of the main security blind-spots in the ML industry</strong>. They are, essentially, a form of <strong>arbitrary code execution</strong>: the only novelty is that <strong>they target the MLOps lifecycle</strong> rather than <a href="https://gist.github.com/RiccardoBiosas/e5a43cdd58699d6c2e9f3372281f3a05">Web API endpoints</a>.</p><p><strong>Serialization</strong> is the process of converting an object into a format that is more portable and that can be more easily stored and shared. Conversely, <strong>deserialization reconstructs the original artifact from its serialized format.</strong></p><p><strong> </strong>In the machine learning field, ML models are often serialized for storage and distribution and then deserialized before their production deployment. As complex and valuable digital artifacts, <strong>machine learning models move across the software supply chain</strong> and they are shared across many different systems, <a href="https://owasp.org/www-project-machine-learning-security-top-10/docs/ML06_2023-AI_Supply_Chain_Attacks">making them </a><strong><a href="https://owasp.org/www-project-machine-learning-security-top-10/docs/ML06_2023-AI_Supply_Chain_Attacks">vulnerable to supply chain attacks</a>.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qHcJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qHcJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 424w, https://substackcdn.com/image/fetch/$s_!qHcJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 848w, https://substackcdn.com/image/fetch/$s_!qHcJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 1272w, https://substackcdn.com/image/fetch/$s_!qHcJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qHcJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png" width="553" height="473" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:473,&quot;width&quot;:553,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:462440,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qHcJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 424w, https://substackcdn.com/image/fetch/$s_!qHcJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 848w, https://substackcdn.com/image/fetch/$s_!qHcJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 1272w, https://substackcdn.com/image/fetch/$s_!qHcJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0082bc79-6533-44a6-a8d6-87a12fb2e7ed_553x473.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><p><strong>Model Serialization Attacks are a form of supply chain attack.</strong></p><p><strong>When you deserialize an ML model, you are running untrusted code in your machine</strong>. Unsurprisingly, this is one of the main gateways that attackers use to hack the <a href="https://www.ncsc.gov.uk/collection/guidelines-secure-ai-system-development/guidelines/secure-development#section_1">AI supply chain</a>. </p><p>Platforms like <strong><a href="https://huggingface.co/docs/hub/en/index">Hugging Face</a></strong><a href="https://huggingface.co/docs/hub/en/index"> - which enables users to share ML models and datasets- </a>are especially exposed to this security risk: there have already been a few occurrences where <strong><a href="https://jfrog.com/blog/data-scientists-targeted-by-malicious-hugging-face-ml-models-with-silent-backdoor/">MLSecOps researchers detected malicious models in public hubs</a></strong>. </p><p>Downloading one of these seemingly harmless ML models could potentially <strong>enable an attacker to spawn a shell in the victim&#8217;s machine</strong>.</p><p>More generally<strong>, compromising a machine learning model with remote code execution (RCE) can weaponize the <a href="https://www.schneier.com/blog/archives/2021/07/hiding-malware-in-ml-models.html">AI supply chain into a distribution channel for malwares</a>.</strong></p><p>But what specific <strong>serialization weaknesses</strong> do RCE exploits leverage to compromise ML assets?</p><p>All the most popular ML development libraries - such as <strong><a href="https://www.tensorflow.org/guide/keras/serialization_and_saving">Tensorflow</a></strong> or <strong><a href="https://pytorch.org/tutorials/beginner/introyt/introyt1_tutorial.html">PyTorch</a></strong>- come with built-in serialization utils, but <strong>only few are reasonably safe</strong>. The most widely used serialization library happens to be also the most unsafe: <strong>Pickle.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!41Ik!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!41Ik!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!41Ik!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!41Ik!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!41Ik!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!41Ik!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png" width="542" height="542" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:542,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;generate an image where there is a pickle with an animated dystopian cyberpunk aesthetic from the scifi anime in the 80s.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="generate an image where there is a pickle with an animated dystopian cyberpunk aesthetic from the scifi anime in the 80s.png" title="generate an image where there is a pickle with an animated dystopian cyberpunk aesthetic from the scifi anime in the 80s.png" srcset="https://substackcdn.com/image/fetch/$s_!41Ik!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!41Ik!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!41Ik!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!41Ik!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7887db0-1881-4123-89b2-89f57c280fb6_1024x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><h5><strong>Pickle is THE Python serialization module in terms of popularity - image courtesy of DALL-E</strong></h5></blockquote><p>In the Pickle library jargon, serialization and deserialization are referred to as, respectively, <strong>pickling</strong> and <strong>unpickling: </strong>when you pickle an object, <strong>you</strong> <strong>transform it into a byte stream</strong> with either <strong>.pkl</strong> or <strong>.pickle</strong> as file extensions - whereas unpickling <strong>reconstructs the binary file into its original format</strong>. </p><p>Some<strong> other ML serialization utils are built on top of Pickle</strong>, <a href="https://pytorch.org/tutorials/recipes/recipes/saving_and_loading_models_for_inference.html">most notably PyTorch&#8217; saving/loading model methods</a>: PyTorch code has, in fact, already been found vulnerable of a few <a href="https://www.securityweek.com/critical-pytorch-vulnerability-can-lead-to-sensitive-ai-data-theft/">RCE exploits</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Cu6p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Cu6p!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 424w, https://substackcdn.com/image/fetch/$s_!Cu6p!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 848w, https://substackcdn.com/image/fetch/$s_!Cu6p!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 1272w, https://substackcdn.com/image/fetch/$s_!Cu6p!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Cu6p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png" width="654" height="328.3475274725275" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:731,&quot;width&quot;:1456,&quot;resizeWidth&quot;:654,&quot;bytes&quot;:271408,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Cu6p!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 424w, https://substackcdn.com/image/fetch/$s_!Cu6p!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 848w, https://substackcdn.com/image/fetch/$s_!Cu6p!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 1272w, https://substackcdn.com/image/fetch/$s_!Cu6p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ea03125-fe30-42e8-9e31-696b6fe099fb_2080x1044.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>Exploiting Python Pickle</strong></h3><p>The main downside of Pickle is its lack of safety: <strong>it grants unrestricted execution to untrusted code</strong>, which makes it easily exploitable.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OIgJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OIgJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 424w, https://substackcdn.com/image/fetch/$s_!OIgJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 848w, https://substackcdn.com/image/fetch/$s_!OIgJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 1272w, https://substackcdn.com/image/fetch/$s_!OIgJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OIgJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png" width="1456" height="786" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:786,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:531510,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OIgJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 424w, https://substackcdn.com/image/fetch/$s_!OIgJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 848w, https://substackcdn.com/image/fetch/$s_!OIgJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 1272w, https://substackcdn.com/image/fetch/$s_!OIgJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f1b89df-7e3c-48df-a09a-ffbd22b2aa44_3096x1672.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><h5><strong><a href="https://github.com/RiccardoBiosas/damn-vulnerable-ML-serialization/blob/main/unsafe_pickle.py">unsafe_pickle.py file</a> in the <a href="https://github.com/RiccardoBiosas/damn-vulnerable-ML-serialization">damn-vulnerable-ML-serialization</a> repository</strong></h5></blockquote><p>In the above example, the attacker defines a MaliciousPayload class which, <strong>when deserialized, executes arbitrary shell commands</strong> on the victim's machine. The <strong>malicious instructions are embedded at the pickling stage</strong>, which are then triggered when <code>pickle.dumps()</code><strong> </strong>deserializes the MaliciousPayload class instance.</p><h3><strong>A brief anatomy of the Pickle lifecycle</strong></h3><p>When the victim runs the <em>unsafe_pickle.py</em> file,  the <em>pickle.dump</em> operation converts the MaliciousPayload instance into a byte-stream,  which is then saved as the file <em>damn_vuln_pickle_model.pkl</em>. Furthermore, upon pickling, the `<strong>__reduce__()` method of the MaliciousPayload class is <a href="https://python.readthedocs.io/en/latest/library/pickle.html#object.__reduce__">automatically invoked</a>. </strong></p><p>Let&#8217;s review the return signature of the  `<strong>__reduce__()</strong>` method:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zdyk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zdyk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 424w, https://substackcdn.com/image/fetch/$s_!zdyk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 848w, https://substackcdn.com/image/fetch/$s_!zdyk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 1272w, https://substackcdn.com/image/fetch/$s_!zdyk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zdyk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png" width="728" height="212.8" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:304,&quot;width&quot;:1040,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:93834,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zdyk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 424w, https://substackcdn.com/image/fetch/$s_!zdyk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 848w, https://substackcdn.com/image/fetch/$s_!zdyk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 1272w, https://substackcdn.com/image/fetch/$s_!zdyk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc15c0a35-7ac9-4049-9695-1aa8f1dc7ef6_1040x304.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>where:</p><ul><li><p>`<strong>callable_object</strong>` is a <a href="https://docs.python.org/3/library/functions.html#callable">Python callable</a>: namely, an object that can be called like a function.</p></li><li><p>`<strong>tuple_args</strong>` is a <a href="https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences">tuple</a> of arguments that will be passed to the `callable_object`</p></li></ul><p>The reason why `<strong>__reduce__()</strong>` is such a security liability is because <strong>it serializes the callable_object</strong> <strong>and its arguments:</strong> - in our proof-of-concept, the <strong>callable_object</strong> is <em>os_system</em><code> </code>and <strong>tuple_args</strong> is a crafted payload of bash commands. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Kr8m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Kr8m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 424w, https://substackcdn.com/image/fetch/$s_!Kr8m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 848w, https://substackcdn.com/image/fetch/$s_!Kr8m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 1272w, https://substackcdn.com/image/fetch/$s_!Kr8m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Kr8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png" width="282" height="1043" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1043,&quot;width&quot;:282,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:75377,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Kr8m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 424w, https://substackcdn.com/image/fetch/$s_!Kr8m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 848w, https://substackcdn.com/image/fetch/$s_!Kr8m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 1272w, https://substackcdn.com/image/fetch/$s_!Kr8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4b5e9d95-d39a-4d1f-97ee-10acc17c5da7_282x1043.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><h5><strong>high-level walk-through of the serialization exploit</strong></h5></blockquote><p>Finally, during unpickling, <strong>the callable and tuple are reconstructed into an executable and its arguments</strong>.</p><p>This means that when the code <strong>reaches the  </strong><code>pickle.loads()</code><strong> instruction, the exploit runs </strong>the malicious shell commands.</p><p>In a real-world scenario, <strong>this type of exploit could be used to mount a backdoor on the victim&#8217;s machine, exfiltrate sensitive data or conduct a poisoning attack</strong>.</p><p>In the case of Pickle vulnerabilities, <strong>the exploit is embedded during the serialization stage </strong> - however, there are other variants of the exploit which <strong>target a  different stages of a model&#8217;s lifecycle</strong>. </p><div class="pullquote"><p>If you want to know more about MLSecOps, become a newsletter subscriber!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://themlsecopshacker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://themlsecopshacker.com/subscribe?"><span>Subscribe now</span></a></p></div><h2><strong>Mitigation Strategies</strong></h2><p>The three key action items for an effective prevention strategy against serialization attacks and enforce secure ML practices are:</p><ul><li><p><strong>Replacing Pickle with safer alternatives</strong>: Hugging Face, as one of the main targets of model serialization attacks, allocated its engineering resources to develop <a href="https://huggingface.co/docs/diffusers/main/en/using-diffusers/using_safetensors#load-safetensors"> a much safer alternative to pickle</a> called <strong><a href="https://huggingface.co/docs/safetensors/en/index">safetensors</a></strong>.</p></li><li><p><strong>Set up a model registry to have greater visibility on the data provenance of your ML artifacts</strong>: supply chain security is even more critical in AI than it is in application development - and just as code repositories have tools like <a href="https://backstage.io/docs/overview/what-is-backstage/">Backstage</a> for better inventory management, the machine learning world has <strong><a href="https://mlflow.org/docs/latest/model-registry.html">MLFlow</a></strong>.</p></li><li><p><strong>Implement MLSecOps CI/CD in your model lifecycle</strong>: the two main security tools specialized in ML serialization attacks are <a href="https://github.com/protectai/modelscan">ProtectAI&#8217;s ModelScan</a> and <a href="https://github.com/trailofbits/fickling">Trail of Bits&#8217; Fickling</a>. </p><p></p><p>The companies that developed the aforementioned scanners are already established in the MLSecOps space in general and, in particular, they are not new to model serialization exploits:  <strong><a href="https://protectai.com/blog/hacking-ai-system-takeover-in-mlflow-strikes-again-and-again">ProtectAI unconvered a few vulnerabilities in the MLFlow platform</a></strong>, whereas <strong>Trail of Bits (ToB) <a href="https://huggingface.co/blog/safetensors-security-audit">audited Hugging Face&#8217;s safetensors</a></strong>. </p><p></p><p>Both scanners are developer-friendly open-source Python packages that can be easily run from CLI, but they come with their own design trade-offs:</p><ul><li><p><strong>ModelScan is more of a blue team tool</strong>, which can be easily integrated with CI/CD in your MLOps lifecycle and helps your organization to identify dangerous serialization patterns. While it has less functionalities than Fickling, it <strong> </strong>supports<strong> <a href="https://github.com/protectai/modelscan/blob/main/README.md#what-models-and-frameworks-are-supported">more serialization utils and formats</a> </strong>than the ToB&#8217;s scanner.</p></li><li><p> <strong>Fickling has a more red-team design,</strong> which includes <strong> a decompiler and the ability to perform code injection - </strong>as such, <strong>Fickling has a richer feature set than ModelScan</strong>, . On the downside, unlike the ProtectAI&#8217;s counterpart, ToB&#8217;s tool supports only Pickle or Pickle-based serialization utils - such as PyTorch.</p></li></ul><p></p><p>Let&#8217;s now have a look at how we can <a href="https://github.com/RiccardoBiosas/damn-vulnerable-ML-serialization?tab=readme-ov-file#scan-the-models">run them against the vulnerable unsafe_pickle.py&#8217;s output</a>:</p><ul><li><p>ModelScan CLI command and output:</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6e6w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6e6w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 424w, https://substackcdn.com/image/fetch/$s_!6e6w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 848w, https://substackcdn.com/image/fetch/$s_!6e6w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 1272w, https://substackcdn.com/image/fetch/$s_!6e6w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6e6w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png" width="1456" height="220" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/20874990-2ca2-4882-a158-13c05e790e57_3392x512.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:220,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:387309,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6e6w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 424w, https://substackcdn.com/image/fetch/$s_!6e6w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 848w, https://substackcdn.com/image/fetch/$s_!6e6w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 1272w, https://substackcdn.com/image/fetch/$s_!6e6w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F20874990-2ca2-4882-a158-13c05e790e57_3392x512.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gD8m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gD8m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 424w, https://substackcdn.com/image/fetch/$s_!gD8m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 848w, https://substackcdn.com/image/fetch/$s_!gD8m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 1272w, https://substackcdn.com/image/fetch/$s_!gD8m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gD8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png" width="831" height="401" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/df088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:401,&quot;width&quot;:831,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:29534,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gD8m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 424w, https://substackcdn.com/image/fetch/$s_!gD8m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 848w, https://substackcdn.com/image/fetch/$s_!gD8m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 1272w, https://substackcdn.com/image/fetch/$s_!gD8m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdf088d7b-147a-4fdc-a726-be5fbc4bdb42_831x401.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><ul><li><p> Fickling CLI command &#8217;s safety-check flag and output:</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UpCE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UpCE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 424w, https://substackcdn.com/image/fetch/$s_!UpCE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 848w, https://substackcdn.com/image/fetch/$s_!UpCE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 1272w, https://substackcdn.com/image/fetch/$s_!UpCE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UpCE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png" width="1456" height="220" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:220,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:402234,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UpCE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 424w, https://substackcdn.com/image/fetch/$s_!UpCE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 848w, https://substackcdn.com/image/fetch/$s_!UpCE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 1272w, https://substackcdn.com/image/fetch/$s_!UpCE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F92ec3546-e07a-4703-9e87-1ce00d5c6b7a_3392x512.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!K_eO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!K_eO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 424w, https://substackcdn.com/image/fetch/$s_!K_eO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 848w, https://substackcdn.com/image/fetch/$s_!K_eO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 1272w, https://substackcdn.com/image/fetch/$s_!K_eO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!K_eO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png" width="728" height="61.213213213213216" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:112,&quot;width&quot;:1332,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:23417,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!K_eO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 424w, https://substackcdn.com/image/fetch/$s_!K_eO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 848w, https://substackcdn.com/image/fetch/$s_!K_eO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 1272w, https://substackcdn.com/image/fetch/$s_!K_eO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05787467-6a37-47d8-b1af-cc962c8c371e_1332x112.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Bingo! Both scanners detected the security issue. If you want to <strong>check other vulnerable ML serialization examples with tensorflow and pytorch, then clone the <a href="https://github.com/RiccardoBiosas/damn-vulnerable-ML-serialization">damn-vulnerable-ML-serialization repository</a></strong>.</p><h2><strong>This is the end, my only friend</strong></h2><p>Time to wrap up our second MLSecOps article - in summary, understanding the risks associated with <a href="https://www.ncsc.gov.uk/collection/guidelines-secure-ai-system-development/guidelines/secure-development#section_1">AI supply chain</a> in general and model serialization in particular is critical to secure MLOps pipelines. </p><div class="pullquote"><p>If you found this article informative, help us by sharing it on social media.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://themlsecopshacker.com/p/ai-security-model-serialization-attacks?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://themlsecopshacker.com/p/ai-security-model-serialization-attacks?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p>The next deep-dives in our content pipeline: from a <strong>HuggingFace safetensors walkthrough  to the best practices to secure your LLM against prompt injection and an additional follow-up on ML serialization attacks and tools</strong>.</p></div><div class="pullquote"><p><code>&#128293; Passionate about AI security? Don't miss out our next articles and become a subscriber!</code></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://themlsecopshacker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://themlsecopshacker.com/subscribe?"><span>Subscribe now</span></a></p><p>&#128293; Looking for the the most comprehensive resource aggregator to explore the MLSecOps ecosystem?</p><p>&#128073;  Check out the awesome-MLSecOps repository  - the leading repository on AI Security featuring lists of AI security tools, academic papers and attack vectors, MLSecOps learning roadmaps and a rich bibliography of other industry-leading resources. </p><p>&#128064; Found the <a href="https://github.com/RiccardoBiosas/awesome-MLSecOps">Awesome MLSecOps</a> content helpful?  Share some love by starring the repository on GitHub!</p><p>&#128293; Looking for an introduction to MLSecOps? Check out our previous article <strong><a href="https://themlsecopshacker.com/p/what-is-mlsecops">What is MLSecOps</a></strong>?</p><p>&#128293; Any Feedback?</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://themlsecopshacker.com/p/ai-security-model-serialization-attacks/comments&quot;,&quot;text&quot;:&quot;Leave a comment&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://themlsecopshacker.com/p/ai-security-model-serialization-attacks/comments"><span>Leave a comment</span></a></p><p>&#128073; Connect with us on <a href="https://x.com/MLSecOpsHacker">X (Twitter)</a> for daily AI Security updates</p><p>&#128073; Join the conversation on <a href="https://www.linkedin.com/company/the-mlsecops-hacker/">Linkedin</a></p></div>]]></content:encoded></item><item><title><![CDATA[What is MLSecOps?]]></title><description><![CDATA[The machines are coming, but who watches the watchers?]]></description><link>https://themlsecopshacker.com/p/what-is-mlsecops</link><guid isPermaLink="false">https://themlsecopshacker.com/p/what-is-mlsecops</guid><dc:creator><![CDATA[Riccardo Biosas]]></dc:creator><pubDate>Tue, 08 Oct 2024 12:14:00 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Sbps!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>MLSecOps is to MLOps what DevSecOps is to DevOps - </strong>perhaps<strong> the most</strong> <strong>intuitive analogy</strong> for any software and cloud practitioner. </p><p>However, the scope of <strong>MLSecOps - </strong>short for<strong> </strong>Machine Learning Security Operations<strong>- is far more cross-disciplinary </strong>than DevSecOps and, more importantly, <strong>its implications and risks are profoundly more consequential</strong>: in this article I will explain why I am convinced that&#8217;s the case and why you should pay close attention to the burgeoning field of <strong><a href="https://cset.georgetown.edu/publication/key-concepts-in-ai-safety-an-overview/">AI Safety</a></strong>.</p><p>But first, let&#8217;s get it over with the definitions: <strong><a href="https://aws.amazon.com/what-is/mlops/">MLOps</a> </strong>(Machine Learning Operations) <strong>is the engineering discipline that manages the end-to-end lifecycle of a machine learning model</strong> - while <strong>MLSecOps is</strong> <strong>the field that attempts to secure each stage of the ML lifecycle</strong>.</p><h3>The final cybersecurity frontier</h3><blockquote><p>There's considerable buzz about AI as a transformative tool enhancing every segment of the security tooling ecosystem - and, occasionally, inching closer to end-to-end automation. However, there is not quite as much focus on <strong>AI itself as a critical attack surface</strong>.<br></p></blockquote><p>The above statement is a <a href="https://www.linkedin.com/posts/riccardo-dal-pio-luogo-5a7b18192_github-riccardobiosasawesome-mlsecops-activity-7199027352293494786-Lvjt?utm_source=share&amp;utm_medium=member_desktop">post</a> I shared not too long ago on a LinkedIn. </p><p>In hindsight, I realize my claim was rather conservative: AI is <strong>not</strong> just a critical attack surface, but it&#8217;s <strong>THE</strong> <strong>attack surface</strong> <strong>of the coming decades</strong> in the tech industry.</p><p>Lately, the AI security landscape evolved at breakneck speed. New threats targeting Artificial Intelligence systems appear daily, and as a result the <a href="https://github.com/RiccardoBiosas/awesome-MLSecOps?tab=readme-ov-file#open-source-security-tools">MLSecOps security tooling ecosystem</a> has grown accordingly. These tools are designed to protect against the widening attack surface outlined, for instance, in the <strong><a href="https://owasp.org/www-project-machine-learning-security-top-10/">OWASP Top 10 ML attack vectors</a></strong> and <strong><a href="https://genai.owasp.org/">OWASP Top 10 LLM security risks</a></strong>. </p><p>At present, not only do ML security threats outpace the available tools to mitigate them, but <strong>there's also a stark imbalance between the rapid, widespread adoption of AI technologies across industries and the limited engineering resources allocated to ensure their proper security posture</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Sbps!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Sbps!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 424w, https://substackcdn.com/image/fetch/$s_!Sbps!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 848w, https://substackcdn.com/image/fetch/$s_!Sbps!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 1272w, https://substackcdn.com/image/fetch/$s_!Sbps!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Sbps!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png" width="728" height="676.8057210965435" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:780,&quot;width&quot;:839,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:1472625,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Sbps!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 424w, https://substackcdn.com/image/fetch/$s_!Sbps!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 848w, https://substackcdn.com/image/fetch/$s_!Sbps!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 1272w, https://substackcdn.com/image/fetch/$s_!Sbps!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdca719bf-d0ab-477e-9eea-560ea343e08f_839x780.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><h5>Vitruvian Man meets AI agent: Leonardo Da Vinci according to <a href="https://openai.com/index/dall-e-3/">DALL-E 3</a> - OpenAI <a href="https://huggingface.co/tasks/text-to-image">text-to-image model</a>.</h5></blockquote><p>This brought us back to our initial claim: AI as the defining attack surface in our digital era - driven by a mixture of <strong>temporary weaknesses</strong> and <strong>fundamental technical reasons</strong>.</p><h3><strong>Temporary Security Weaknesses in the AI Industry</strong></h3><p>The current state of Artificial Intelligence security is impacted by a <strong>lack of ML security culture, standardized best practices and talent shortages</strong>. </p><p>The current <strong>shortage of security professionals</strong> <strong>with machine learning skills</strong> <strong>is a challenge</strong> that is likely to persist for the foreseeable future.  Bridging the gap between InfoSec and the Machine Learning fields will require a long upskilling cycle, as these two industries have historically diverged until recently.</p><p><strong>The safety shortcomings in this section are socio-economic</strong> rather than technical - as such, their impact will diminish over time as the AI industry adapts itself to the challenges that come with technological mass adoption.</p><p>While it&#8217;s true that the <strong>machine learning industry is lagging behind</strong> the rest of the software and cloud industry in terms of security, we are witnessing a more decisive shift towards the development of <strong>robust enterprise-grade AI safety frameworks</strong>. </p><p>Some notable private-sector examples are <strong><a href="https://cloud.google.com/blog/topics/threat-intelligence/securing-ai-pipeline/">Google&#8217;s Secure AI Framework (SAIF)</a> </strong>and <strong><a href="https://www.ibm.com/blog/announcement/ibm-framework-for-securing-generative-ai/">IBM&#8217;s own</a></strong><a href="https://www.ibm.com/blog/announcement/ibm-framework-for-securing-generative-ai/"> </a><strong><a href="https://www.ibm.com/blog/announcement/ibm-framework-for-securing-generative-ai/"> internal AI security framework</a></strong>. </p><p>On the governmental and institutional front, the <strong><a href="https://www.nist.gov/">National Institute of Standards and Technology (NIST)</a></strong> <strong>has introduced the <a href="https://airc.nist.gov/AI_RMF_Knowledge_Base/AI_RMF">AI Risk Management Framework (AI RMF)</a> and the <a href="https://airc.nist.gov/AI_RMF_Knowledge_Base/Playbook">AI RMF Playbook</a></strong> - a series of documents that<strong> map the organizational risks of AI adoption and the corresponding enterprise processes to reduce their threat profiles</strong>. </p><p>Although we are still far from achieving well-adopted industry standards, <strong>these initiatives effectively set the first successful quantitative and qualitative benchmarks</strong> to measure a company&#8217;s AI security posture.</p><p>Analogously,<strong> the</strong> <strong>industry has yet to develop a more mature security tooling ecosystem</strong> and a consensus on the best mitigation strategies to the the most exotic adversarial risks, but it is beginning to converge towards some general solutions against the most common attack vectors. </p><p>Some of these emergent best practices focus on <strong>restricting AI agents&#8217; access to internal APIs only to what is strictly necessary via <a href="https://blog.google/technology/ai/our-responsible-approach-to-building-guardrails-for-generative-ai/">guardrails</a>, enforcing sensible access-control policies and <a href="https://mlflow.org/docs/latest/model-registry.html">tracking the provenance of ML models</a></strong>.</p><h3><strong>Fundamental Technical Challenges</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0m-c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0m-c!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!0m-c!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!0m-c!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!0m-c!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0m-c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1888764,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0m-c!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!0m-c!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!0m-c!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!0m-c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a87ed16-a5c8-4497-b446-0b0f61a16be0_1024x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><blockquote><h5>A Schrodinger&#8217;s cat black-box - courtesy of <a href="https://openai.com/index/dall-e-3/">DALL-E 3</a></h5></blockquote><h4><strong>Complexity</strong></h4><p>AI systems are the most complex software components ever designed. <strong>The complexity of their architectures lies as much in the mathematical design of their models as it does in their infrastructure</strong> <strong>challenges.</strong> </p><h4><strong>Explainability - Or Lack Thereof</strong></h4><p>This inherent complexity is further amplified by <strong><a href="https://docs.aws.amazon.com/whitepapers/latest/model-explainability-aws-ai-ml/interpretability-versus-explainability.html">the lack of explainability</a> </strong>of Artificial Intelligence systems.</p><p><strong>Explainability</strong> <strong>is the</strong> <strong>ability to model an AI agent's decision-making process by establishing causal or logical relationships between its inputs and outputs</strong>. While we can explain - <strong>debug</strong> - traditional software, <a href="https://www.algolia.com/blog/ai/what-is-explainable-ai-and-why-is-transparency-so-important-for-machine-learning-solutions/">AI systems largely operate as black boxes</a>.<strong> </strong></p><p>The opaque nature of AI has been a key focus of academic and industry research aimed at making their inner workings more human-digestible. Today, the field of <strong><a href="https://insights.sei.cmu.edu/blog/what-is-explainable-ai/">Explainable AI (XAI)</a></strong> offers a range of increasingly sophisticated strategies to enhance the <strong>interpretability</strong> of AI outputs. </p><p>However, ML models are still far from being fully explainable and there&#8217;s a<strong> trade-off between a model&#8217;s performance and its interpretability</strong>.</p><p><strong>This partial lack of transparency raises</strong> <strong>trust concerns</strong> <strong><a href="https://www.mckinsey.com/capabilities/quantumblack/our-insights/why-businesses-need-explainable-ai-and-how-to-deliver-it">for businesses</a></strong> <strong>and complicates the task of ensuring the security and <a href="https://hbr.org/2021/09/ai-regulation-is-coming">regulatory compliance</a></strong> of ML models.</p><h4><strong>High-Value Targets</strong></h4><p>Machine Learning models are increasingly often the <strong>most valuable component</strong> of a software stack. </p><p>The main reasons are:</p><ul><li><p>The <strong>high capital requirements</strong> necessary to cover the costs of the engineering talent and the infrastructure where the ML models are trained and run.</p></li><li><p>The <strong>intellectual property value</strong> of the datasets used to train the ML models - which often are highly confidential data such as financial or healthcare information.</p></li><li><p>The increasingly <strong>critical function that AI components play in the application architecture and its business logic</strong>.</p></li></ul><p>These properties make ML models compelling targets to attackers.</p><p>Imagine a scenario where a large tech company deployed a gargantuan R&amp;D budget for the development of a new machine learning model. Then, once in production,<strong> an attacker is able to reverse-engineer an approximate replica of the company&#8217;s ML model. </strong></p><p><a href="https://owasp.org/www-project-machine-learning-security-top-10/docs/ML05_2023-Model_Theft.html">This attack vector is called </a><strong><a href="https://owasp.org/www-project-machine-learning-security-top-10/docs/ML05_2023-Model_Theft.html">model theft.</a> </strong> It is performed<strong> against Machine Learning models that expose an unprotected public-facing API</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hTyp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hTyp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 424w, https://substackcdn.com/image/fetch/$s_!hTyp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 848w, https://substackcdn.com/image/fetch/$s_!hTyp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 1272w, https://substackcdn.com/image/fetch/$s_!hTyp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hTyp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png" width="541" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:720,&quot;width&quot;:541,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:70684,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hTyp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 424w, https://substackcdn.com/image/fetch/$s_!hTyp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 848w, https://substackcdn.com/image/fetch/$s_!hTyp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 1272w, https://substackcdn.com/image/fetch/$s_!hTyp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa36f9ed-ee38-4e0b-8e5e-243af4404a59_541x720.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h5></h5><blockquote><h5><strong>High-level walk-through of a <a href="https://www.schneier.com/blog/archives/2021/01/extracting-personal-information-from-large-language-models-like-gpt-2.html">model theft</a> exploit against a public-facing ML Model API</strong></h5></blockquote><h4><em><strong>Attacker Scenario</strong></em></h4><p>Let's say there are two leading skincare apps in the digital cosmetic dermatology industry. </p><p>Company A recently released the latest version of its <strong>ML-powered skincare recommendation system</strong>, providing users with highly personalized skincare routines and product suggestions. This new feature has significantly boosted Company A's user growth and retention, far surpassing its competitor Company B. To further consolidate its new market lead, <strong>Company A opens up its ML model via a public API</strong>, allowing other skincare e-commerce shops to integrate the recommendation engine into their applications.</p><p>Its competitor Company B is nowhere near developing a similarly sophisticated machine learning model, so it decides to reverse-engineer Company A&#8217;s valuable AI intellectual property.</p><p>Essentially, the model theft exploit simplified in the above diagram boils down to the three main phases:</p><p>- After obtaining access to the A's skincare recommendation API, Company B designs several user persona templates which it uses for <strong>the automated generation of API queries with a wide range of user profiles</strong> such as different dermatological concerns (i.e.: aging, eczema, acne etc.), lifestyle factors and skin types. <strong>This systematic API probing is designed to model the recommendation system's ranking function</strong>.</p><p>- <strong>Company B iteratively starts pairing the prompt inputs and ML model's outputs &amp; optimizing its reconnaissance queries</strong>. The API inputs selection strategy is designed to progressively refine the attacker&#8217;s payloads for the purpose of maximizing the knowledge gained on the underlying target model&#8217;s behavior.</p><p>- Eventually, Company B collects enough input-output pairs to <strong>approximate the output distribution of Company A&#8217;s skincare recommendation engine</strong>. It then uses this dataset to train or fine-tune its own <strong>replica model</strong>. As a result, Company B&#8217;s recommendation system is able to mimic quite closely the decision-making capabilities of Company A&#8217;s proprietary ML model - although never with absolute fidelity.</p><p>What&#8217;s the outcome? The digital skincare <strong>Company A partially lost its competitive advantage </strong>- the proprietary nature of its recommendation engine's ML model - into which it had invested substantial engineering and infrastructure resources. For Company B, on the other hand, the attack was relatively <strong>inexpensive</strong>.</p><p>What makes model theft even more concerning is, in fact, that it&#8217;s a relatively <strong>cost-effective attack</strong> compared to the financial damage that it can inflict on its targets.</p><p>Luckily, <strong>this AI attack is still mostly theoretical</strong> as its real-world exploit implementation are rare and usually not as effective. Nevertheless, in the near future we can expect more exploit attempts bridging <strong><a href="https://arxiv.org/abs/2206.08451">the gap between academic theory and real-world model stealing attacks</a></strong>: we will go through their main mitigation strategies in a future article. </p><p>Model stealing is just a relatively uncommon example within the <strong>growing taxonomy of AI security threats</strong>: <strong><a href="https://github.com/RiccardoBiosas/awesome-MLSecOps?tab=readme-ov-file#attack-vectors">there are many other AI attack vectors that are far more production-ready</a></strong> and pose a similarly devastating <strong>intellectual property loss and reputational damage</strong> to their targets.</p><p></p><h2><strong>Verdict</strong></h2><p>In conclusion, <strong>ML models are often the most capital intensive, the most valuable and the most obscure component in modern software architectures</strong>. At the same time, they are also one of the areas that is <strong>the most neglected from a cybersecurity perspective</strong>.</p><p><strong>Securing them is, therefore, the most daunting challenge in the cybersecurity industry - as well as the most impactful</strong>.</p><p></p><div class="pullquote"><p>Would you like us to cover a specific AI Security topic?  Let us know in the comments, on <a href="https://x.com/MLSecOpsHacker">Twitter</a> or <a href="https://www.linkedin.com/in/riccardo-dal-pio-luogo-5a7b18192/">Linkedin</a> .</p><p>If you are interested in knowing more about AI security tools and resources, check out the <a href="https://github.com/RiccardoBiosas/awesome-MLSecOps">awesome-MLSecOps repository</a> - contributions are welcome!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://themlsecopshacker.com/p/what-is-mlsecops?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://themlsecopshacker.com/p/what-is-mlsecops?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p><p>Passionate about AI Security? Show us some love:<strong> share the article</strong> and <strong>subscribe to not miss the next MLSecOps deep-dive!</strong></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://themlsecopshacker.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption"></p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>Help us build the AI Security culture of the future.</p></div><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p>]]></content:encoded></item></channel></rss>