joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

10/13/2006

This sucks…

by @ 9:58 pm. Filed under tech

Microsoft Corp. did an about-face yesterday, agreeing to make it easier for customers of its forthcoming Vista operating system to use outside security vendors, such as those who make popular antivirus and anti-spyware programs.

[snip]

The company said that blocking the core of area of the operating system was also meant to enhance the performance of the entire computer, noting that unsupported access by outside software programs could affect the overall stability of the machine.

http://www.washingtonpost.com/wp-dyn/content/article/2006/10/13/AR2006101301280.html

I would hope there will be an option to turn on that level of security for people who don’t want other programs mucking around that level…

  joe

Rating 3.00 out of 5

Happy Friday the 13th….

by @ 12:18 am. Filed under general

Rating 3.00 out of 5

10/12/2006

Brutal article – well for Carly it is.

by @ 11:04 pm. Filed under general

I was a bit surprised at how strongly this news column was worded being that it was from a mainstream network (ABC). I wasn’t all that surprised to see that the columnist was a former HP employee though surprised he left well before Carly was anywhere near HP.

The Former CEO Has Taken Questions About Her Firing Public, but Is She Telling the Whole Story?

Oct. 10, 2006 —  For someone who is running around the country these days portraying herself as a victim, Carly Fiorina is actually one very lucky lady.

http://abcnews.go.com/Business/IndustryInfo/story?id=2546914&page=1

Rating 3.00 out of 5

10/6/2006

LDAP Client API Memory Leak

by @ 10:07 pm. Filed under tech

A user in one of the newsgroups I frequent ran into an issue with some LDAPS code that was leaking memory on him. You can view the entire thread by clicking here.

The summary is that the user was writing some LDAP API code and submitting one of the LDAP Options, specifically LDAP_OPT_CLIENT_CERTIFICATE session option which allows you to specify a callback for the LDAP Client code to invoke your own code for selecting a client cert to use.

Well the user actually didn’t want anything returned to the server so was setting the callback and the function he registered simply returned FALSE. Here is the minimal code snippet to cause the leak.

#include <windows.h>
#include <ntldap.h>
#include <winldap.h>
#include <schnlsp.h>
#include <stdio.h>

BOOLEAN _cdecl GetClientCertRoutine(void *Connection,
                                    void *trusted_CAs,
                                    void *ppCertificate)
 {
  return (FALSE);
 }

int main(int argc, char* argv[])
 {
  LDAP* ld = NULL;
  INT iRtn = 0;
  INT connectSuccess = 0;
  PCHAR pHost = NULL;
  ULONG version = LDAP_VERSION3;
  SecPkgContext_ConnectionInfo sslInfo;
  LONG lv = 0;

  SecPkgContext_ConnectionInfo *psslInfo;

  pHost = “hostname.domain.com”;

  while (1)
   {
    ld = ldap_sslinit(pHost,LDAP_SSL_PORT,1);
    if (ld == NULL)
     {
      printf( “ldap_sslinit failed with 0x%x.\n”,GetLastError());
      return -1;
     }

    iRtn = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,(void*)&version);
    if (iRtn != LDAP_SUCCESS)
      goto FatalExit;

    // setting function to avoid client authetication
    iRtn = ldap_set_option(ld, LDAP_OPT_CLIENT_CERTIFICATE, &GetClientCertRoutine);
    if (iRtn != LDAP_SUCCESS)
      goto FatalExit;

    iRtn = ldap_get_option(ld,LDAP_OPT_SSL,(void*)&lv);
    if (iRtn != LDAP_SUCCESS)
      goto FatalExit;
    if ((void*)lv == LDAP_OPT_ON)
      printf(“SSL is enabled\n”);
    else
     {
      iRtn = ldap_set_option(ld,LDAP_OPT_SSL,LDAP_OPT_ON);
      if (iRtn != LDAP_SUCCESS)
        goto FatalExit;
     }

    connectSuccess = ldap_connect(ld, NULL);
    if (connectSuccess == LDAP_SUCCESS)
      printf(“ldap_connect succeeded \n”);
    else
     {
      printf(“ldap_connect failed with 0x%x.\n”,connectSuccess);
      goto FatalExit;
     }

    printf(“Binding …\n”);
    iRtn = ldap_bind_s(ld,NULL,NULL,LDAP_AUTH_NEGOTIATE);
    if (iRtn != LDAP_SUCCESS)
      goto FatalExit;

    goto NormalExit;

    NormalExit:
      if (ld != NULL)
       {
        ldap_unbind_s(ld);
        continue;
       }

    // Cleanup after an error.
    FatalExit:
      if ( ld != NULL )
        ldap_unbind_s(ld);
      printf( “\n\nERROR: 0x%x\n”, iRtn);
      break;
   }
 }

This is a little shorter and slightly different than the code that the user posted so it is quicker to read through. I copied the code and slapped it into a new Borland Developer Studio c++ console project, added the wldap32.lib and compiled it. I fired up good old perfmon and then launched the app so I could select counters for that process. The specific counters I wanted were Process\Private Bytes and Process\Working Set. I then watched the counters and sure enough… There appeared to be a leak.

 

Since the application isn’t allocating memory within the loop that it isn’t deallocating, the counters should be a straight and HORIZONTAL line… While that line is relatively straight, horizontal it is not.

So I started commented out almost all of the code and recompiled and got the straight line that I expected. So the next step was to either un-comment parts and recompile and rerun or un-comment everything and then comment certain pieces until you find the source. Doesn’t matter which way you go really, up to you. In the end I found that if I commented out just this section

    // setting function to avoid client authetication
    iRtn = ldap_set_option(ld, LDAP_OPT_CLIENT_CERTIFICATE, &GetClientCertRoutine);
    if (iRtn != LDAP_SUCCESS)
      goto FatalExit;

The leak was gone. Looking at the call back function (described more below) I saw that one of the parameters was a list of trusted CAs and was dynamically allocated… It was likely the leak was in that section of the LDAP Client API code. So I then broke out my super secret MSDN Premium smart card which gives me access to the Windows Operating Source Code….

Having played in the source quite a bit over the last 3 or 4 years it was fairly easy (a minute or two) to find the location where the user specified function was being called. I then saw what I thought to be the problem,  as I figured the list of trusted CAs was allocated and I didn’t immediately see it deallocated. So I chased a little more and still didn’t find a deallocation. That made me feel even more strongly that it was the culprit. I verified by actually changing the callback function so that it deallocated the list… I then recompiled and reran the test only to see….

 

That is the nice flat line I expected in the first place… A little bit of allocation up front and then nice and flat… Definitely stands out as quite different eh?

So I spent a little time and forwarded the newsgroup posting with my observations written up including the lines of code in the LDAP Client API source that I felt were at fault and sent them off to a very helpful MSFT guy. He dug into it and sure enough, the leak was confirmed and a bug opened on for it (note I was told I could say this). This will be corrected in some future version of the LDAP Client API DLLs though if someone needs a QFE for this, they could open up a support ticket with Microsoft and request a QFE and possibly get it (and this…).

Since this is a problem in the actual LDAP Client API it will most likely impact anything utilizing the API, this means ADSI, .NET S.DS, etc. So if you are using the callback function for the LDAP_OPT_CLIENT_CERTIFICATE option then you need to be aware of this. It shouldn’t be a tremendous issue unless you are binding and unbinding over and over again so most apps shouldn’t have to worry about it. However if you are doing something similar to what is above, you may want to be take care.

Oh, what code did I add to remove the leak? I had to add a couple of items. Basically the definition of the callback function is defined here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/queryclientcert.asp. The definition is

BOOLEAN _cdecl QUERYCLIENTCERT(
  PLDAP Connection,
  PSecPkgContext_IssuerListInfoEx trusted_CAs,
  PCCERT_CONTEXT* ppCertificate
);

SecPkgContext_IssuerListInfoEx is a structure and the dynamically allocated CA blobs are in the aIssuers property.

This memory is freed with FreeContextBuffer which requires you to include security.h.

 

So at the top of the program, add in

#define SECURITY_WIN32 1    // Required for security.h

and then include security.h where the other includes are

#include <security.h>      // Required for FreeContextBuffer()

and then change the callback function, this could be done in a couple of ways:

BOOLEAN _cdecl GetClientCertRoutine(void *Connection,
                                    void *trusted_CAs,
                                    void *ppCertificate)
 {
  SecPkgContext_IssuerListInfoEx *p = (SecPkgContext_IssuerListInfoEx *)trusted_CAs;
  FreeContextBuffer((void*)p->aIssuers);
  return (FALSE);
 }

or

BOOLEAN _cdecl GetClientCertRoutine(void *Connection,
                                    SecPkgContext_IssuerListInfoEx *trusted_CAs,
                                    void *ppCertificate)
 {
  FreeContextBuffer((void*)trusted_CAs->aIssuers);
  return (FALSE);
 }

Whichever floats your boat… I am sure one looks or feels more elegant to you than the other, chose the one you like, just make sure you deallocate the memory.  🙂

 

Certainly I could have figured this out without the OS source code access; for this particular problem the information needed was available in MSDN if you took the leap of faith that the CA list was where the leak was. Quiet honestly, after seeing that the callback function caused the leak and looking at the MSDN info on the callback function parameters I was pretty sure that was, in fact, it. Having source access though certainly helped me move along a little more confidently and definitely helped me to describe exactly where in the LDAP Client API code the issue was for Microsoft. I don’t know how much if any time that could have saved for them but I am sure the developers were happy for direct pointers, I know I would be. I think this is one of those cases where having the ability to see the source (though not recompile it) is quite handy. It is why if MSFT ever opened their source in any large scale, I think doing so in such a fashion that you can look but not modify would be fine. However, I admit that is tough to enforce and quite honestly, I don’t care if every OSS person in the world has a heartattack over MSFT NOT opening their source, MSFT needs to feel comfortable in releasing anything to the open source world and if they don’t, I fully agree with their right not to do so. Though I admit it is useful to have the access – but I feel I earned the access rights I have and continue to try and earn the right. 😉

   joe

Rating 3.00 out of 5

10/3/2006

whenChanged and modifyTimeStamp

by @ 11:43 pm. Filed under tech

There was a posting in the public newsgroups the other day concerning using whenChanged and/or modifyTimeStamp for tracking changes for an object so I thought I would say a few words about it…

Before I say anything though, lets look at the schema definitions:

 

F:\>adfind -sc s:whenchanged

AdFind V01.32.00cpp Joe Richards (joe@joeware.net) October 2006

Using server: 2k3dc02.joe.com:389
Directory: Windows Server 2003
Base DN: CN=Schema,CN=Configuration,DC=joe,DC=com

dn:CN=When-Changed,CN=Schema,CN=Configuration,DC=joe,DC=com
>objectClass: top
>objectClass: attributeSchema
>cn: When-Changed
>distinguishedName: CN=When-Changed,CN=Schema,CN=Configuration,DC=joe,DC=com
>instanceType: 4 [WRITABLE(4)]
>whenCreated: 20021023015022.0Z
>whenChanged: 20050514161047.0Z
>uSNCreated: 5126
>attributeID: 1.2.840.113556.1.2.3
>attributeSyntax: 2.5.5.11 [STRING (UTC/GENERALIZED TIME)]
>isSingleValued: TRUE
>mAPIID: 12296
>uSNChanged: 5126
>showInAdvancedViewOnly: TRUE
>adminDisplayName: When-Changed
>adminDescription: When-Changed
>oMSyntax: 24
>searchFlags: 0 []
>lDAPDisplayName: whenChanged
>name: When-Changed
>objectGUID: {DDB22CED-BB5E-470F-A21C-0DA0853FF397}
>schemaIDGUID: {BF967A77-0DE6-11D0-A285-00AA003049E2}
>systemOnly: TRUE
>systemFlags: 19 [NOT REPLICATED(1);PAS-ATTR(2);CAT-1(16)]
>isMemberOfPartialAttributeSet: TRUE
>objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=joe,DC=com
>dSCorePropagationData: 20050909162804.0Z
>dSCorePropagationData: 20050909162631.0Z
>dSCorePropagationData: 16010101000417.0Z

1 Objects returned

 

F:\>adfind -sc s:modifyTimeStamp

AdFind V01.32.00cpp Joe Richards (joe@joeware.net) October 2006

Using server: 2k3dc02.joe.com:389
Directory: Windows Server 2003
Base DN: CN=Schema,CN=Configuration,DC=joe,DC=com

dn:CN=Modify-Time-Stamp,CN=Schema,CN=Configuration,DC=joe,DC=com
>objectClass: top
>objectClass: attributeSchema
>cn: Modify-Time-Stamp
>distinguishedName: CN=Modify-Time-Stamp,CN=Schema,CN=Configuration,DC=joe,DC=com
>instanceType: 4 [WRITABLE(4)]
>whenCreated: 20021023015016.0Z
>whenChanged: 20050514161045.0Z
>uSNCreated: 4498
>attributeID: 2.5.18.2
>attributeSyntax: 2.5.5.11 [STRING (UTC/GENERALIZED TIME)]
>isSingleValued: TRUE
>uSNChanged: 4498
>showInAdvancedViewOnly: TRUE
>adminDisplayName: Modify-Time-Stamp
>adminDescription: Modify-Time-Stamp
>oMSyntax: 24
>searchFlags: 0 []
>lDAPDisplayName: modifyTimeStamp
>name: Modify-Time-Stamp
>objectGUID: {5BC24C7E-958E-429C-AC3F-41EEEFE39B76}
>schemaIDGUID: {9A7AD94A-CA53-11D1-BBD0-0080C76670C0}
>systemOnly: TRUE
>systemFlags: 134217748 [CONSTRUCTED(4);CAT-1(16);NO-RENAME(134217728)]
>objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=joe,DC=com
>dSCorePropagationData: 20050909162804.0Z
>dSCorePropagationData: 20050909162630.0Z
>dSCorePropagationData: 16010101000417.0Z

1 Objects returned

The things to notice about the schema definitions:

  • whenChanged is marked as not-replicated
  • modifyTimeStamp is marked as constructed (effectively an alias for whenChanged)

This means neither attribute is replicated. This is a critical thing to keep in mind if you are tracking changes with this attribute, it means that you can only track changes for objects in this manner against the SAME DC. Objects on different DCs can and usually will (if in different sites) have very different values for these attributes even if only one change has been made on the object recently.

 

Something that REALLY seems to surprise people is that even promoting a new DC will result in this value being different on a DC. As an example, check out the wide range of values for the whenChanged attribute for the actual whenChanged schema definition, this is entirely due to different DCPromo times of the DCs:

F:\>adfind -sc s:whenchanged whenChanged -h 2k3dc02 -tdcgt

AdFind V01.32.00cpp Joe Richards (joe@joeware.net) October 2006

Using server: 2k3dc02.joe.com:389
Directory: Windows Server 2003
Base DN: CN=Schema,CN=Configuration,DC=joe,DC=com

dn:CN=When-Changed,CN=Schema,CN=Configuration,DC=joe,DC=com
>whenChanged: 05/14/2005-12:10:47 Eastern Daylight Time

1 Objects returned

F:\>adfind -sc s:whenchanged whenChanged -h 2k3dc10 -tdcgt

AdFind V01.32.00cpp Joe Richards (joe@joeware.net) October 2006

Using server: 2k3dc10.child1.joe.com:389
Directory: Windows Server 2003
Base DN: CN=Schema,CN=Configuration,DC=joe,DC=com

dn:CN=When-Changed,CN=Schema,CN=Configuration,DC=joe,DC=com
>whenChanged: 07/04/2004-18:26:19 Eastern Daylight Time

1 Objects returned

F:\>adfind -sc s:whenchanged whenChanged -h 2k3dc11 -tdcgt

AdFind V01.32.00cpp Joe Richards (joe@joeware.net) October 2006

Using server: 2k3dc11.joe.com:389
Directory: Windows Server 2003
Base DN: CN=Schema,CN=Configuration,DC=joe,DC=com

dn:CN=When-Changed,CN=Schema,CN=Configuration,DC=joe,DC=com
>whenChanged: 05/26/2006-19:05:48 Eastern Daylight Time

1 Objects returned

I have used that understanding of this attribute in the past to “magically” tell companies when all of their DCs were promoted when they weren’t really sure themselves or help discover replication latency issues when none allegedly existed. It is especially useful when you walk into a shop (or more likely a shop that has a “loud” admin or two) that thinks and guarantees you that it isn’t possible to get any “real” info about Domain Controllers without being a Domain Admin and this (and much more) is easily available as any normal user.  Shhh, don’t tell anyone….

  joe

Rating 4.00 out of 5

More on the ridiculous claims of the "security" companies.

by @ 10:28 pm. Filed under tech

http://www.rockyh.net/Posts/Post.aspx?postId=6d119600-53a9-4bf4-b491-2b04127f4022

Rating 3.00 out of 5

McAfee and Symantec don’t want you safe, they want your money…

by @ 10:27 pm. Filed under tech

I saw this article today

http://www.businessweek.com/technology/content/oct2006/tc20061003_871186.htm?chan=top+news_top+news+index_businessweek+exclusives

which is about how McAfee and Symantec are pissed that Microsoft is locking down the OS from people hacking it.

Me personally, I don’t mind of they go out of business, I don’t use either of their products; neither one has done anything I would even start to consider amazing in a long long time. I have no trust in either company or their products. My overall experiences with McAfee products are less than stellar, I have been in jobs where I saw a McAfee AV package update blow out a large portion of the Windows servers in a Data Center. I think both companies actually encourage unsafe practices by putting their freebie versions of tools on new PCs and expecting people to subscribe to their services. Don’t believe me, go door to door and ask folks if they have an large manufacturer PC and if they do, if they have ever subscribed to the update services… Very few folks I talk to do. Instead they feel they must still be safe in some way. The first thing I do with my or anyone’s PCs that came from a vendor in my personal life is that I wipe the OS that came from the factory and reinstall Windows from the ground up. Almost immediately the machine is much faster. I enable the firewall and if I am concerned about viruses with the person I install AVG. I feel the machine is safer with AVG than it is with McAfee and Symantec AND the machine is more performant overall.

 

Basically I think these companies have been making their dollars the last few years protecting uninformed people from themselves and they are not happy that Microsoft is trying to make the OS safer so that this extra protection may not be as required as it was in the past. Also, all of the hack ways they had of trying to offer this protection are becoming worthless because Microsoft is blocking that type of access… Specifically that is the kernel access…

The whining about the kernel access “issue” is the one that really makes me dislike McAfee and Symantec and make me want to scream from the rooftops that the products aren’t worth the box they come in. I don’t care what their argument is, they shouldn’t have access to the kernel. NO ONE should have that access except the OS itself. Period. They shouldn’t have had access before, they shouldn’t have that access now, they certainly shouldn’t have that access in the future. Interestingly, at least to me, they are pissed that they don’t have access and can’t do what they want to do but at the same time they are arguing that they know Microsoft can’t protect it properly and that hackers are going to get into it and since they (the “security” companies) won’t have their software there first, the customers will be at risk… Come again? The security companies can’t get into the kernel but the bad guys can? Are the security companies actually admitting that with their millions or maybe billions of dollars pumping into their company and funding their R&D and programming they aren’t as good as or better than the kid hackers sitting in their basements with no funding? Why would I want these companies protecting my system anyway? Doesn’t make sense if they have admitted the hackers can do something they can’t. I would rather pay the hackers.

Overall the only thing I can think of that these companies truly add value for is to use up CPU cycles on machines that are otherwise almost idle and adds enough slowness to the machines that people feel they should kick out more money in a year or three to buy another machine thereby keeping consumers buying more and faster computers.

I say go Microsoft, continue making the OS as safe as you can – THAT IS YOUR JOB. I hope it becomes so safe that there is nothing a third party could offer in the way of security protection. I know that will never occur because many people are uninformed and the OS can never get away with completely stopping uninformed people from doing uninformed things. That is why those people can buy the third party tools. They can pay to be stopped and know that they specifically paid for that feature.

Do I think that Vista and Longhorn will be perfectly secure? Not at all, but I think they will be more secure than they will be if Symantec and McAfee get anywhere in trying to block MSFT from locking things down properly. If you use products from these companies, contact their support and tell them to shut up and let MSFT secure the product the best they can, then come through and write products that further protect the user or make things easier.

 

  joe

Rating 3.00 out of 5

10/2/2006

Ethereal -> WireShark

by @ 11:44 pm. Filed under tech

I talk about Ethereal a lot because I believe it is an extremely useful tool. If you don’t know, it is a network “sniffer” utility. I.E. It captures network packets for display or analysis. I love the tool, I used to use Microsoft’s NetMon but several years ago found Ethereal and slowly stopped using NetMon.

Well anyway, this last summer when I was really busy and not looking, Ethereal’s “founder” moved companies and had to leave the Ethereal name behind so he fired up a new project. It is sort of like a fork but isn’t as all of the main Ethereal developers joined him over on WireShark.

You can get WireShark here —> http://www.wireshark.org/

In all previous blog entries, anywhere you see the word Ethereal in reference to a network tool, replace it with WireShark. If I mention Ethereal in reference to a network took in future posts, don’t worry, that is my memory loss kicking in again, just replace that with WireShark as well.

    joe

Rating 3.00 out of 5

Darren is off to the races…

by @ 10:25 pm. Filed under tech

Well DesktopStandard has been acquired by Microsoft which means Darren Mar-Elia is off and running with his own startup full time now.

http://blogs.dirteam.com/blogs/gpoguy/archive/2006/10/02/DesktopStandard-acquired-by-Microsoft.aspx

I have known Darren quite a while now. I first met him in an official meeting where he, in his capacity as the CTO of Quest, was trying to sell a customer (who I happened to work for) some Quest products. That didn’t go particularly well for Quest but it was only because of Quest’s licensing terms and lack of an Enterprise License option and the customer’s lack of excitement for any product that charges a per user or per object charge.

While we didn’t buy anything, it still was a good meeting because Darren impressed me with his technical responses and etched his name in my mind. Since then, Darren became an MVP which gave us the opportunity to spend a considerable amount of time talking in various settings, both formal and informal and discussed briefly earlier this year what he was thinking about doing so I think I have a good understanding of how Darren looks at the world. 

From that understanding and my experiences with Darren I can absolutely back anything he says he is going to do because I know he has the intelligence and wherewithal to do it. He has both the business knowledge and the technical knowledge. To put it simply… I know Darren can produce because he already has; he is a known quantity, that is proof enough for me.

I don’t hope Darren will succeed, I expect it. Along those lines, anything he needs from me, he knows I will assist with.  🙂

  joe

Rating 3.00 out of 5

Long Stick…

by @ 9:01 pm. Filed under quotes

In waking a tiger, use a long stick.

 – Mao Tse-Tung

Rating 3.00 out of 5

[joeware – never stop exploring… :) is proudly powered by WordPress.]