That diagram is very accurate for XP and previous. The reason it is so complicated is the several levels of abstraction involved.
There are two primary (as in, "most used") ways of logging into Windows - as a standalone workstation user, and as a member of a domain. In both cases, on XP those credentials pass through the LSA client and its server.
At the backend, then, LSA must determine "who to ask" to determine if the credentials are indeed valid. That's where the "negotiate" block comes in - which will do one of two things:
- If the system is configured as a workstation, use the NTLM scheme as configured on the box and talk to the SAM database.
- If the system is configured as part of a domain, talk to the server to see what it supports, and give it what it needs.
In essence, this process isn't all that different from negotiating what sort of hashing to use for say a HTTP authentication method: the server says what it wants (PLAIN, DIGEST, MD5) and I send the password as needed.
There is an allusion to other credential types fitting in here in the form of "msgina.dll". This is the component responsible for talking to the user after Ctrl+Alt+Delete and can be replaced to provide new UI such as fingerprint and smart card logon. In each of these cases, LSA must still talk to the backend database (whereever that is) to get an authentication token of some form.
You can also add extra authentication protocols to LSA via LSA providers. This is the corresponding "talk to the authentication database to determine if this is a valid user" component and you can read about these components here and directions for how to write one here.
Now, once this process is complete, the user is handed an authentication token called an access token. UAC aside, presenting this token is how processes indicate to the system they are already authorised to act on behalf of the user.
This is what is going on and how LSA and the various components fit together.
Now, part two of my answer. Flame targeted LSA for two reasons:
- It is estensible. You can register new authentication protocols, new GINA/Credential Providers (XP/Vista+ respectively).
- It runs on boot of the system, with
NT AUTHORITY\SYSTEM privileges.
This makes it a marvellously good place from which to launch your malware and remain persistent on the system. See this analysis
As you can imagine, there are checks and balances preventing any old program from installing itself there and even being run there, by means of Authenticode. However, Flame used a stolen certificate to bypass this, which is where things got interesting. The information, specifically the Common Name, contained in the authenticode certificate is displayed as part of the authenticode warning dialog. So in this case, the malware would actually appear to be authored by "Microsoft Corporation". Once they click OK and run Flame with elevated privileges, it then has all the access it wants. It can then register itself as an LSA provider and will then be run automatically each time the system starts.