<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MQX Software SolutionsのトピックRe: Potential Bug in httpsrv_readreq() in RTCS for MQX for KSDK 1.1</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454466#M15280</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This has nothing to do with how an HTTP header ends.&amp;nbsp; This has to do with potentially reading past the end of the buffer in the case of a really long line in a header (probably in the case of an intentional attack).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Bowe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jul 2015 23:31:22 GMT</pubDate>
    <dc:creator>bowe</dc:creator>
    <dc:date>2015-07-07T23:31:22Z</dc:date>
    <item>
      <title>Potential Bug in httpsrv_readreq() in RTCS for MQX for KSDK 1.1</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454464#M15278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are using MQX for KDSK 1.1.&amp;nbsp; In looking at httpsrv_readreq() in httpsrv_task.c, it seems that there is a potential bug that might occur if the the buffer is completely filled at line 577 because line 602 might not find a '\n' in the buffer and continue reading past it.&amp;nbsp; This bug would be exploited in the case that an HTTP request header has a line that is larger than the buffer, which will probably never happen unless intentionally exploited.&amp;nbsp; I have not experimentally proven this bug, so maybe there is some way I am not seeing that prevents it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is line 577:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14322486031674932" data-renderedposition="113_8_1232_16" jivemacro_uid="_14322486031674932"&gt;&lt;P&gt;read = httpsrv_recv(session, session-&amp;gt;buffer.data+session-&amp;gt;buffer.offset, HTTPSRV_SES_BUF_SIZE_PRV-session-&amp;gt;buffer.offset, 0);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is line 602:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14322486217184727 jive_text_macro" data-renderedposition="171_8_1232_16" jivemacro_uid="_14322486217184727"&gt;&lt;P&gt;while (session-&amp;gt;request.process_header &amp;amp;&amp;amp; ((line_end = strchr(line_start, '\n')) != NULL))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fix we implemented until we move to MQX for KSDK 1.2 is to ensure the buffer is never completely filled (and then null-terminating).&amp;nbsp; This is done by changing line 577, as shown below, and leaving line 602 alone.&amp;nbsp; The second line in this fix is probably not necessary since the free buffer space is zero-ed in line 653.&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14322486952827286 jive_text_macro" data-renderedposition="250_8_1232_32" jivemacro_uid="_14322486952827286" modifiedtitle="true"&gt;&lt;P&gt;read = httpsrv_recv(session, session-&amp;gt;buffer.data+session-&amp;gt;buffer.offset, HTTPSRV_SES_BUF_SIZE_PRV-session-&amp;gt;buffer.offset-1, 0);&lt;/P&gt;&lt;P&gt;if(read &amp;gt; 0) session-&amp;gt;buffer.data[session-&amp;gt;buffer.offset+read] = '\0';&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, recommendations/comments are welcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Bowe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE:&amp;nbsp; In MQX for KSDK 1.2, it looks like this function has been renamed to httpsrv_req_read(), and the potential bug is fixed by using memchr(), which takes a length.&amp;nbsp; So this potential problem is probably already known.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 23:00:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454464#M15278</guid>
      <dc:creator>bowe</dc:creator>
      <dc:date>2015-05-21T23:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Potential Bug in httpsrv_readreq() in RTCS for MQX for KSDK 1.1</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454465#M15279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bowe:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Every http header should be ended with "\r\n", please check the httpsrv_sendhdr function in httpsrv_supp.c&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;/* End of header */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;httpsrv_print(session, "\r\n");&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;....., &lt;/P&gt;&lt;P&gt;otherwise, the receive socket maybe blocked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 09:12:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454465#M15279</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2015-06-02T09:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Potential Bug in httpsrv_readreq() in RTCS for MQX for KSDK 1.1</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454466#M15280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This has nothing to do with how an HTTP header ends.&amp;nbsp; This has to do with potentially reading past the end of the buffer in the case of a really long line in a header (probably in the case of an intentional attack).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Bowe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2015 23:31:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Potential-Bug-in-httpsrv-readreq-in-RTCS-for-MQX-for-KSDK-1-1/m-p/454466#M15280</guid>
      <dc:creator>bowe</dc:creator>
      <dc:date>2015-07-07T23:31:22Z</dc:date>
    </item>
  </channel>
</rss>

