<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>blog</title>
    <subtitle>notes, posts, and files</subtitle>
    <link rel="self" type="application/atom+xml" href="https://zll.la/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://zll.la"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-12-03T00:00:00+00:00</updated>
    <id>https://zll.la/atom.xml</id>
    <entry xml:lang="en">
        <title>fl studio rce</title>
        <published>2026-12-03T00:00:00+00:00</published>
        <updated>2026-12-03T00:00:00+00:00</updated>
        
        <author>
          <name>zilla</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://zll.la/posts/fl-rce/"/>
        <id>https://zll.la/posts/fl-rce/</id>
        
        <content type="html" xml:base="https://zll.la/posts/fl-rce/">&lt;h2 id=&quot;intro&quot;&gt;intro&lt;/h2&gt;
&lt;p&gt;i first got inspiration to try and find an fl rce when i started working on a mod loader for fl. sounded fun and i knew there was a lot of attack surface (flp parser, audio codec parsers, zip parser, stock plugins, etc). i didn&#39;t have any success on my first attempts, i initially looked at any stock plugin i could think of that would load user input (i assumed the likeliest places i would find success would be formula controller, patcher, or convolver on loading IR responses) and turned up empty. i also couldn&#39;t get anything going w/ flp / zip parser logic.&lt;/p&gt;
&lt;p&gt;after having no luck with poking obvious areas, i ran a scanner to parse the plugin state of the first plugin in every flp in FL&#39;s built in &quot;Render tests&quot; directory, which conveniently contains an flp for every stock plugin containing just that plugin loaded. this led me to BeepMap, which stores a bmp file in its plugin state.&lt;/p&gt;
&lt;h2 id=&quot;the-bug&quot;&gt;the bug&lt;/h2&gt;
&lt;p&gt;FL contains a vulnerable shared .bmp parser added in Fruity Loops 2.7.0. the parser was accessible from .flp parameters in Fruity Loops 3, via the addition of the BeepMap stock plugin. below is pseudocode representing the parser function:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: light-dark(#282835, #D2D2E6); background-color: light-dark(#D8D8E4, #3E3E52);&quot; &gt;&lt;code data-lang=&quot;c&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt; DIBParser&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;DIBSharedImage &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;*&lt;/span&gt;&lt;span&gt;surface&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; TMemoryStream &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;*&lt;/span&gt;&lt;span&gt;stream&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; uint32_t&lt;/span&gt;&lt;span&gt; flags&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    DIBSharedImage &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;*&lt;/span&gt;&lt;span&gt;savedSurface &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span&gt; surface&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    uint32_t&lt;/span&gt;&lt;span&gt; biSize &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt; read_u32&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;stream&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    uint32_t&lt;/span&gt;&lt;span&gt; biClrUsed&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;biSize &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;==&lt;/span&gt;&lt;span&gt; BITMAPCOREHEADER_SIZE&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        [&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; read dimensions and bit depth&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        biClrUsed &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;biSize &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;==&lt;/span&gt;&lt;span&gt; BITMAPINFOHEADER_SIZE&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        [&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; read biWidth, biHeight, biBitCount, biCompression, etc&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        biClrUsed &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt; read_u32&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;stream&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        [&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; read biClrImportant and any color masks&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt;        error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#28553D, #BDE7C8);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#28553D, #BDE7C8);&quot;&gt;DIB is invalid&lt;/span&gt;&lt;span style=&quot;color: light-dark(#28553D, #BDE7C8);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;        return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    uint32_t&lt;/span&gt;&lt;span&gt; colors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span&gt; biClrUsed&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; palette entry count&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;colors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; biBitCount &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 8&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        colors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; &amp;lt;&amp;lt;&lt;/span&gt;&lt;span&gt; biBitCount&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;int32_t&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;colors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 256&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; note int32_t - signed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        colors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 256&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; cap amount of colors to 256 to fit in 1024 byte buffer (4 bytes per color)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    uint8_t&lt;/span&gt;&lt;span&gt; palette4&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;0x&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;400&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;biSize &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;==&lt;/span&gt;&lt;span&gt; BITMAPCOREHEADER_SIZE&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        [&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; read and convert three-byte palette entries&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;        uint32_t&lt;/span&gt;&lt;span&gt; paletteBytes &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;=&lt;/span&gt;&lt;span&gt; colors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;u&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt;        read&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;stream&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; palette4&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt; sign_extend_32_to_64&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;paletteBytes&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#234F79, #B9D5F5);&quot;&gt;    build_surface&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;savedSurface&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; palette4&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; biWidth&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; biHeight&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                  biBitCount&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; biCompression&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; biSizeImage&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    [&lt;/span&gt;&lt;span&gt;...&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt; decode pixels according to biCompression &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;biClrUsed is an unsigned 32-bit integer that declares how many colors are in the loaded bitmap&#39;s palette. When biClrUsed = 0 for an image using 8 bits or less, the parser uses 256 entries at 8 bits per pixel. Above 8 bits per pixel, 0 usually means there is no color table and each pixel defines its own color.&lt;/p&gt;
&lt;p&gt;The parser is intended to cap colors at 256 and fit in a 1024 byte buffer. However, since jle uses a signed comparison, palette counts with bit 31 set bypass the cap. The later multiplication by 4 bytes per entry can wrap to a read length larger than palette4, as shown later with 0x800001DE.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: light-dark(#282835, #D2D2E6); background-color: light-dark(#D8D8E4, #3E3E52);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F800  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;cmp&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;    esi&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x100&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;   ; esi compares # of colors in palette with 256&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F806  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;jle&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;    0x20F80D&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;     ; jle checks if less than or equal using a signed comparison, skip cap if colors is less than or = 256&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F808  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;    esi&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x100&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;   ; otherwise if greater, set colors to 256&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          [...]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F8AF  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;    r8d&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;esi&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;     ; copy colors&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F8B2  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;shl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;    r8d&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;       ; multiply by 4 bytes/entry&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F8B6  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;movsxd&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; r8&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;r8d&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;      ; sign extend result to 64 bits for r8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F8B9  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;call&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;   0xF1010&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;      ; read r8 bytes into palette4 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;turning-a-bitmap-into-rce&quot;&gt;turning a bitmap into rce&lt;/h2&gt;
&lt;p&gt;for the poc, i use a bmp with biClrUsed = 0x800001DE (2147484126) as bit 31 is set which makes jle interpret it as a negative number and it causes a 0x778 (1912) byte read, overrunning palette4 by 888 bytes. this reaches the saved rbp, return address, and surface pointer, and stops before the saved stream pointer. the pointer value 0x18008F100 comes from other bytes written in the bmp stream located at offsets 0x770 - 0x777 from the start of the palette read.&lt;/p&gt;
&lt;p&gt;the parser uses our overwritten pointer and passes it, along with the palette buffer, to the surface builder:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: light-dark(#282835, #D2D2E6); background-color: light-dark(#D8D8E4, #3E3E52);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F631  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rbp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x7F0&lt;/span&gt;&lt;span&gt;], &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rcx&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;   ; save rcx (which holds image surface pointer) on stack&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          [...]                              &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; After palette read&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F8F3  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; r8&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rbp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x7F0&lt;/span&gt;&lt;span&gt;]    &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; reload saved pointer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F914  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;lea&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rdx&lt;/span&gt;&lt;span&gt;, [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rbp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x80&lt;/span&gt;&lt;span&gt;]              &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; palette4&amp;#39;s address&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F91B  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rsp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x28&lt;/span&gt;&lt;span&gt;], &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rdx&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;    ; pass palette4 address to helper&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;          ; ... set up other arguments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F928  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rcx&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;r8&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                        ; pass surface pointer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;          ; ... set up other arguments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F934  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;call&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; 0x20ECD0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                      ; build surface and copy palette&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;inside 0x20ECD0, the surface builder saves the pointer passed in rcx &amp;amp; uses it as the destination for the palette copy:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: light-dark(#282835, #D2D2E6); background-color: light-dark(#D8D8E4, #3E3E52);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020ECDB  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rsp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x28&lt;/span&gt;&lt;span&gt;], &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rcx&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;              ; save surface pointer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          [...]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020EE61  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rsi&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rsp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x88&lt;/span&gt;&lt;span&gt;]              &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; load the palette4 pointer into rsi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020EE69  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rax&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rsp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x28&lt;/span&gt;&lt;span&gt;]              &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; reload surface pointer&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020EE6E  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;lea&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rdi&lt;/span&gt;&lt;span&gt;, [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rax&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x20&lt;/span&gt;&lt;span&gt;]                        &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; destination: surface pointer (0x18008F100) + 0x20&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020EE72  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;mov&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; ecx&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x80&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                                ; repeat copy in next instruction 128x&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020EE77  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;rep&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; movsq&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt; qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rdi&lt;/span&gt;&lt;span&gt;], &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;qword&lt;/span&gt;&lt;span&gt; ptr [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rsi&lt;/span&gt;&lt;span&gt;]   &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; copy 1024 bytes from palette4 (rsi) to surface+0x20 (rdi)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The surface pointer (0x18008F100) is loaded into rax, then lea adds 0x20, setting rdi to 0x18008F120 in freetype_x64.dll&#39;s writable .data section. freetype is used because it has DYNAMICBASE disabled (preventing ASLR troubles) and loads at its preferred base. rep movsq then copies the palette there, placing the ROP chain, and the earlier overflow set saved rbp to 0x18008F100 &amp;amp; return address to the pivot gadget at 0x180062E5E.&lt;/p&gt;
&lt;p&gt;After surface construction &amp;amp; pixel decoding, DIBParser restores registers and returns:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: light-dark(#282835, #D2D2E6); background-color: light-dark(#D8D8E4, #3E3E52);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F9A0  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;lea&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rsp&lt;/span&gt;&lt;span&gt;, [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rbp&lt;/span&gt;&lt;span&gt; + &lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x7C8&lt;/span&gt;&lt;span&gt;]   &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; point rsp at the saved registers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F9A7  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rbx&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                  ; restore rbx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F9A8  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rsi&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                  ; restore rsi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F9A9  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rdi&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                  ; restore rdi&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F9AA  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rbp&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                  ; load overwritten value 0x18008F100&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0020F9AB  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                      ; use overwritten return address&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ret enters the freetype gadget with rbp set as 0x18008F100:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: light-dark(#282835, #D2D2E6); background-color: light-dark(#D8D8E4, #3E3E52);&quot; &gt;&lt;code data-lang=&quot;asm&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;180062E5E  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;lea&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rsp&lt;/span&gt;&lt;span&gt;, [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;rbp&lt;/span&gt;&lt;span&gt;+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;0x20&lt;/span&gt;&lt;span&gt;]   &lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;; rsp = 0x18008F120&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;180062E62&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;  pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; r15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;               ; load first 8 bytes of copied palette&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;180062E64&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;  pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; r14&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;180062E66&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;  pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; r13&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt;180062E68&lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;  pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; r12&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;180062E6A  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;pop&lt;/span&gt;&lt;span style=&quot;color: light-dark(#793C2D, #F3C1A7);&quot;&gt; rbp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;180062E6B  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#603579, #DCC2F4);&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;color: light-dark(#4A5265, #ACADC5);font-style: italic;&quot;&gt;                   ; take next address from 0x18008F148&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the final ret takes its next address from the bmp palette bytes that were copied into freetype&#39;s .data. this allows executing code and calling functions in the process, including  calling WinExec to run arbitrary windows commands.&lt;/p&gt;
&lt;p&gt;Below are demos of the exploit in action popping calc &amp;amp; opening my twitter on FL 26, 24, and, for fun, Fruity Loops 3 :p
The vulnerable parser is also found in other places than beepmap, most notably Harmor, where the same bug is exploitable due to harmor having a similar image-to-sound feature. simply removing beepmap isn&#39;t sufficient protection.&lt;/p&gt;
&lt;div class=&quot;demo-gifs&quot;&gt;
  &lt;a class=&quot;demo-gif&quot; href=&quot;/gallery/#img-poc1.gif&quot;&gt;&lt;img src=&quot;/gallery/poc1.gif&quot; width=&quot;960&quot; height=&quot;600&quot; alt=&quot;PoC demo with a Discord attachment and FL Studio&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/a&gt;
  &lt;a class=&quot;demo-gif&quot; href=&quot;/gallery/#img-poc2.gif&quot;&gt;&lt;img src=&quot;/gallery/poc2.gif&quot; width=&quot;960&quot; height=&quot;540&quot; alt=&quot;PoC demo in modern FL Studio&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/a&gt;
  &lt;a class=&quot;demo-gif&quot; href=&quot;/gallery/#img-poc3.gif&quot;&gt;&lt;img src=&quot;/gallery/poc3.gif&quot; width=&quot;960&quot; height=&quot;540&quot; alt=&quot;PoC demo in Fruity Loops 3&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;h2 id=&quot;credits&quot;&gt;credits&lt;/h2&gt;
&lt;p&gt;&lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://x.com/9098&quot;&gt;ty&lt;/a&gt; - additional testing
&lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://x.com/mjkzys&quot;&gt;mjkzys&lt;/a&gt; - previous published &lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/mjkzy/easyflp&quot;&gt;flp research&lt;/a&gt; that was a useful resource&lt;/p&gt;
&lt;h2 id=&quot;fix&quot;&gt;fix&lt;/h2&gt;
&lt;p&gt;Use jbe instead of jle (the equivalent unsigned instruction) when checking if the palette has more than 256 colors. this fix was made on FL 26.2 (released yesterday), along with zero-extending the byte length. Go update&lt;/p&gt;
&lt;p&gt;For those for whatever reason unable to update, linked is a &lt;a rel=&quot;noopener noreferrer external&quot; target=&quot;_blank&quot; href=&quot;https://ziiias.github.io/bitmapoverflowscanner/&quot;&gt;quick scanner&lt;/a&gt; I wrote to detect malicious flps/fsts/etc abusing this bug. everything is processed locally, none of your flps or any info is sent and you can run the html file on your own pc.&lt;/p&gt;
&lt;p&gt;I hope u enjoyed reading . . i hope to write more in the future ^_^! attached below are the two pocs that work on all versions between 12.5.0.59 - 26.1.7.5654.  Happy birthday to me and cya 🎈&lt;/p&gt;
&lt;div class=&quot;attachments&quot; aria-label=&quot;PoC downloads&quot;&gt;
  &lt;a class=&quot;attachment&quot; href=&quot;/files/calc.flp&quot; download=&quot;calc.flp&quot;&gt;
    &lt;svg class=&quot;attachment-icon&quot; viewBox=&quot;0 0 24 24&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;M5 2.5h9l5 5v14H5zM14 2.5v5h5M8 12h8M8 15.5h8&quot;/&gt;&lt;/svg&gt;
    &lt;span class=&quot;attachment-name&quot;&gt;calc.flp&lt;/span&gt;
  &lt;/a&gt;
  &lt;a class=&quot;attachment&quot; href=&quot;/files/twitter.flp&quot; download=&quot;twitter.flp&quot;&gt;
    &lt;svg class=&quot;attachment-icon&quot; viewBox=&quot;0 0 24 24&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;M5 2.5h9l5 5v14H5zM14 2.5v5h5M8 12h8M8 15.5h8&quot;/&gt;&lt;/svg&gt;
    &lt;span class=&quot;attachment-name&quot;&gt;twitter.flp&lt;/span&gt;
  &lt;/a&gt;
&lt;/div&gt;
</content>
        
    </entry>
</feed>
