FGF TV just released this video that covers some highlights of the TMG presentation that I delivered in Brazil last month:
Why is it a bad request? If you haven’t seen this before, I see quiet often in some scenarios involving ISA Server and guess what: if I remove ISA Server from the picture it works just fine. Well, we all know that when you are wide open to Internet there is nobody inspecting your traffic anyway so you shall pass. Is the same thing as trying to get into your house without the key for the door, you can’t get in, but guess what, if you remove the door you can get in. Oh..so it got be the door the root cause of the problem, right? Better remove the door or look for your key?
In some scenarios when you receive the “400 Bad Request” is because is ISA Server is acting according to RFC 2616 and then sending the HTTP response to the client like this:
- Http: Response, HTTP/1.1, Status Code = 400,
ProtocolVersion: HTTP/1.1
StatusCode: 400, Bad request
Reason: Bad Request ( The data is invalid. )
Connection: Keep-Alive
Pragma: no-cache
Cache-Control: no-cache
- ContentType: text/html
MediaType: text/html
ContentLength: 1852
HeaderEnd: CRLF
- payload: HttpContentType = text/html
Here it is a piece of the HTTP header with a type of request that can be interpreted by ISA Server as invalid:
HTTP HTTP:Request
...
Content-type: multipart/mixed
If the content type is multipart the HEX value might look like this:
49 53 41 2A 30 30 2A 20 20 20 20 20 20 20 20 20 20 2A 30 30 2A 20 20 20 20 20 20 20 20 20 20 2A 31 32 2A 36 31 34 32 37 38 36 35 35 31 20 20 20 20 20 2A 30 38 2A 36 31 31 31 33 35 35 30 30 31 20 20 20 20 20 2A 30 36 30 31 30 35 2A 30 39 35 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
The value 20 in HEX means space (see http://en.wikipedia.org/wiki/ASCII for more info), which makes perfect sense in this case since the next HTTP packet just continued with a bunch of more spaces at the end, which supposedly will extend to a third packet if ISA haven’t drop that:
20 20 20 20 20 20 20 20 20 20 20 20 30 32 31 30 30 30 31 7E 47 45 2A 31 2A 31 37 32 31 7E 49 45 41 2A 31 2A 30 30 30 30 30 31 37 32 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7E 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Going back to the RFC 2616 (section 4.2) you will see that this is not a good practice and ISA Server does what is supposed to be done, drop the packet. The best way to fix that is to contact the web site administrator (or application developer) and ask him to fix that. However since in almost of all outbound access you don’t have control of the site that your internal client is trying to access, ISA Server has a workaround to accept that. To workaround on this problem (since is not an ISA issue) you need should install ISA Server 2006 SP1 and after that make the registry changes suggested in the article below:
941293 Error message when you access a Web site through ISA Server 2006 or Microsoft Forefront Threat Management Gateway, Medium Business Edition: "HTTP 400 - Bad Request"
http://support.microsoft.com/default.aspx?scid=kb;EN-US;941293
1. Introduction
Error 64 can happen due many situations and I documented one of those situations last year and as you could see sometimes it is not easy to find out why this error happens. The issue that I’m about to describe here was identified while I was troubleshooting a third party application that uses TCP Port 80 to transmit files, but not using HTTP. What?? Yeah, I know. Although IANA has established port 80 for HTTP, anyone can create an application that uses port 80 to send whatever they want. This is fine, as long as you don’t try to use this application behind a Firewall that does application layer inspection and look to that traffic and say: what is that? This is not HTTP Protocol and it is using TCP Port 80…I shall block this traffic!
The firewall administrator was smart to understand that and what he did was, he created a custom protocol using port 80 and didn’t bind Web Proxy filtering to it. Fair enough, but doesn’t fully resolved this issue.
2. The Error
When the client (which had the 3rd party application installed on his computer) started to transmit the file to the destination it received an error and didn’t proceed. Using Logging feature the Firewall Administrator saw the error below:
Figure 1 – Error 64
On the netmon trace we could see that the TCP Handshake was established fine, but after the first HTTP Payload has being sent ISA Server 2006 didn’t like what he saw and the connection was reset.
Figure 2 – Connection reset right after first attempt to use TCP Port 80 (with a non compliance HTTP Protocol).
3. Resolution
To resolve this problem what you need to do is not only create a custom protocol and an access rule to use this protocol, but also a deny rule right after this access rule to block the regular HTTP Protocol that has the Web Proxy Filter bind to it. The access rules will look like this:
Figure 3 – Access rule with a Deny to HTTP (with filter) Protocol.
Why do I have to do this? Read this post here and you will know the reason:
Why do I need a deny rule to make an allow rule for a custom protocol work correctly?
http://blogs.technet.com/isablog/archive/2006/09/25/why-do-i-need-a-deny-rule-to-make-an-allow-rule-for-a-custom-protocol-work-correctly.aspx
FGF University released a short version of the debate that we had on the University Live TV Program that was recorded last month when I was in Brazil. In this program we discussed many IT areas and the security concerns around those areas. The program (full version) will be live tomorrow (07/19) on Channel 14 (NET Brazil) and also Assembleia TV Channel (Brazil).
The problem that this post is going to discuss was related to a random issue where certain times of the day the ISA Server was stopping answering requests and when the firewall administrator tried to restart the firewall service the service didn’t start. The only event that we have prior to the issue happens was the one below:
Event Type: Error
Event Source: Microsoft ISA Server Web Proxy
Event Category: None
Event ID: 14172
Date: 13/3/2009
Time: 18:37:43
User: N/A
Computer: ISASRV
Description:
The cache was not properly initialized. caching will be disabled (internal code 503.287.4.0.2167.887). Identify the specific reason for the failure from previous relevant event logs. Fix the problem, and then restart the Firewall service to enable caching.
Doing a quick assessment I could see that the Antivirus was scanning all folders, including ISA Folders (not good at all). As a troubleshooting step I disabled the AV but the issue persisted. Using ProcMon I could see that when ISA Storage process (ISAStg.exe) was trying to read a value in register the AV filter drive was still present in kernel mode and intercepting the request. Here it is the sequence:
ISASTG process:
34408 2:23:05.8643957 PM isastg.exe 3904 RegEnumValue HKLM\SOFTWARE\Microsoft\Fpc\Storage\Array-Root\Arrays\{0A8D8F99-6862-47B9-9388-12890728AF1A}\Servers\{B622A644-418A-40E1-988F-C1182B246652}\Proxy-Cache-Directories\Proxy-Cache-Directory1 SUCCESS Index: 3, Name: msFPCDirectoryName, Type: REG_SZ, Length: 34, Data: D:\urlcache\Dir1
The stack for this process shows the AV filter drive (klif.sys):
0 ntoskrnl.exe ntoskrnl.exe + 0x17859f 0x8097859f C:\WINDOWS\system32\ntoskrnl.exe
1 ntoskrnl.exe ntoskrnl.exe + 0x146c3c 0x80946c3c C:\WINDOWS\system32\ntoskrnl.exe
2 klif.sys klif.sys + 0xfa1c 0xf685fa1c C:\WINDOWS\system32\drivers\klif.sys
3 ADVAPI32.dll ADVAPI32.dll + 0x12530 0x77f62530 C:\WINDOWS\system32\ADVAPI32.dll
4 isastg.exe isastg.exe + 0x8352 0x408352 D:\Program Files\Microsoft ISA Server\isastg.exe
5 isastg.exe isastg.exe + 0x9054 0x409054 D:\Program Files\Microsoft ISA Server\isastg.exe
6 RPCRT4.dll RPCRT4.dll + 0x30193 0x77c80193 C:\WINDOWS\system32\RPCRT4.dll
7 RPCRT4.dll RPCRT4.dll + 0x933e1 0x77ce33e1 C:\WINDOWS\system32\RPCRT4.dll
8 RPCRT4.dll RPCRT4.dll + 0x935c4 0x77ce35c4 C:\WINDOWS\system32\RPCRT4.dll
9 RPCRT4.dll RPCRT4.dll + 0x2ff7a 0x77c7ff7a C:\WINDOWS\system32\RPCRT4.dll
10 RPCRT4.dll RPCRT4.dll + 0x3042d 0x77c8042d C:\WINDOWS\system32\RPCRT4.dll
11 RPCRT4.dll RPCRT4.dll + 0x30353 0x77c80353 C:\WINDOWS\system32\RPCRT4.dll
12 RPCRT4.dll RPCRT4.dll + 0x311dc 0x77c811dc C:\WINDOWS\system32\RPCRT4.dll
13 RPCRT4.dll RPCRT4.dll + 0x312f0 0x77c812f0 C:\WINDOWS\system32\RPCRT4.dll
14 RPCRT4.dll RPCRT4.dll + 0x38678 0x77c88678 C:\WINDOWS\system32\RPCRT4.dll
15 RPCRT4.dll RPCRT4.dll + 0x38792 0x77c88792 C:\WINDOWS\system32\RPCRT4.dll
16 RPCRT4.dll RPCRT4.dll + 0x3872d 0x77c8872d C:\WINDOWS\system32\RPCRT4.dll
17 RPCRT4.dll RPCRT4.dll + 0x2b110 0x77c7b110 C:\WINDOWS\system32\RPCRT4.dll
18 kernel32.dll kernel32.dll + 0x24829 0x77e64829 C:\WINDOWS\system32\kernel32.dll
Later on we fail to create the file:
34838 2:23:05.9429702 PM mspadmin.exe 612 CreateFile D:\urlcache SUCCESS Desired Access: Read Attributes, Read Control, Write DAC, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, Impersonating: S-1-5-21-2611182321-852623426-2620623114-500, OpenResult: Opened
34839 2:23:05.9430612 PM mspadmin.exe 612 QueryBasicInformationFile D:\urlcache SUCCESS CreationTime: 2/13/2009 1:51:15 PM, LastAccessTime: 2/13/2009 2:23:04 PM, LastWriteTime: 2/13/2009 1:51:15 PM, ChangeTime: 2/13/2009 1:51:15 PM, FileAttributes: D
34840 2:23:05.9431081 PM mspadmin.exe 612 QuerySecurityFile D:\urlcache BUFFER OVERFLOW Information: Owner, Group, DACL, 0x80000000
We uninstalled the AV and the issue didn’t happen anymore. Since his environment had a requirement to have AV installed on ever single Windows machine we implemented the correct folder exclusion following the article “Considerations when using antivirus software on ISA Server” and the environment got stabilized.
Interesting side of this story is that this article was published exactly one year ago, one year later we still have firewall administrators not following such recommendation and therefore having unexpected downtimes.
FGF TV Channel just released the online version of the interview (in Portuguese) that I recorded last week about information security and also about TMG Book.
Couple of days ago I was assisting a friend to troubleshoot the infamous 5783 that was causing the authentication prompt issue that we all know about. In this case the problem was happening throughout the night, which was even odder because during the day when the traffic was really high the issue wasn’t happen. The employees on the third shift (which was no more than 20) were receiving authentication prompts randomly.
The question was: how to get data on this type of case? We don’t know what time it occurs and we don’t have IT people on that time to collect data. We installed a tool called Port Reporter tool that runs as a service and collects pretty much all the information about process and which port is using during that time. Read http://support.microsoft.com/kb/837243 for more information on how to use this amazing tool.
It boils down that the issue was a piece of malware on those workstations that were sending tons of request to an external URL and drastically affecting ISA Server’s performance.
How many times were you wondering if the Microsoft application that you were running is supported in a virtual environment? That’s a very common question and up to now the answer for this question was not much clear in some cases. The virtualization support team published this month the Virtualization Support Wizard which it was in development and test for months internally. There you will be able to easily identify if the Microsoft product (including ISA Server) that you are looking for is supportable in a virtual environment. Check it out at http://www.windowsservercatalog.com/svvp.aspx?svvppage=svvpwizard.htm