Simmons Consulting, the Website of Toby Simmons

Microsoft MS06-071 (KB927978) breaks stuff

29
Nov

Microsoft Security Bulletin MS06-071 was released November 15 to patch a vulnerability in their XML Core Services 4.0 (and 6.0). Having nearly 50 servers to update, this can be a real headache. Still, we managed to get all of the important servers (especially the web servers) updated with this patch and the others that were released that day. Yay.

Of course, I didn’t realize that after installing all of these patches, some (fortunately non-critical) web code I had written years ago suddenly quit working.

I got around it by editing the way the code works, but it is so frustrating when MS releases patches that break existing code.

The original code loaded the XML from a remote site by creating a DOMDocument object and using the .LoadXML() method to load the XML that was screen-scraped using the following function:

  1. Function HttpScoop( myURL, myUser, myPass )
  2.    On Error Resume Next
  3.    Dim objHttp, lResolve, lConnect, lSend, lReceive
  4.    Set objHttp = CreateObject("MSXML2.ServerXMLHTTP.4.0")
  5.  
  6.    lResolve = 5 * 1000
  7.    lConnect = 5 * 1000
  8.    lSend = 5 * 1000
  9.    lReceive = 15 * 1000
  10.    objHttp.setTimeouts lResolve, lConnect, lSend, lReceive
  11.  
  12.    If Len(myUser) > 0 Then
  13.       objHttp.Open "GET", myURL, false, myUser, myPass
  14.    Else
  15.       objHttp.Open "GET", myURL, false
  16.    End If
  17.    objHttp.Send
  18.  
  19.    If Not Err Then
  20.       If objHttp.getResponseHeader("Content-Type") = "text/xml" Then
  21.          HttpScoop = objHttp.responseXML.xml
  22.       Else
  23.          HttpScoop = objHttp.responseText
  24.       End If
  25.       Set objHttp = Nothing
  26.    Else
  27.       Err.Clear
  28.    End If
  29. End Function

Then, in the main block of code, I would load the XML by passing the function and its parameters to the .LoadXML function, like this:

  1.    Set xmldoc = Server.CreateObject("MSXML2.DOMDocument.4.0")
  2.    xmldoc.LoadXML HttpScoop(xmlURL, "", "")
  3.    If xmldoc.parseerror.errorcode <> 0 Then
  4.       outString = outString + "Error loading XML Document :" & "<br />"
  5.       outString = outString + "----------------------------" & "<br />"
  6.       outString = outString + "Error Code : " & xmldoc.parseerror.errorcode & "<br />"
  7.       outString = outString + "Reason : " & xmldoc.parseerror.reason & "<br />"
  8.       outString = outString + "Line : " & xmldoc.parseerror.Line & "<br />"
  9.       outString = outString + "Position : " & xmldoc.parseerror.linepos & "<br />"
  10.    End If

The the content being loaded from xmlURL was returned using a Content-Type header of “text/html” and the XML declaration used windows-1252 encoding. This was because the XML contained many high-character codes within the XML file (literal characters, not encoded) including smart quotes, em-dashes, and more. For example: “ ” ’ and —. This worked swell up until we installed these updates.

Now, every time it tries to load the xml, the following error is generated:

Error loading XML Document :
----------------------------
Error Code : -1072896760
Reason : An invalid character was found in text content. 
Line : 1
Position : 293 (wherever the first high-character code appears)

I used the .LoadXML() and HttpScoop() function above because in some cases I have to post-process the XML before loading it into the DOM. Now I can’t do that. I changed the code to load the XML directly using the ServerHttpRequest property and the .Load() method instead, like this:

  1.    Set xmldoc = Server.CreateObject("MSXML2.DOMDocument.4.0")
  2.    xmldoc.async = False
  3.    xmldoc.setProperty "ServerHTTPRequest", True
  4.    xmldoc.load xmlURL

At least the code works now, at least in the cases where I don’t need to post process the text before loading it into the DOM object.

Oh well.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>