Verifying a controlling process

Has anyone implemented a way to verify that the process controlling
the driver is supposed to control it?
We can have hardcoded hashes of the allowed executables that can
control the driver. What I am worried is how easy would it be for
applications to emulate as if the other application is making the call?
(we are not worried about a driver helping applications, at that point
we cannot do much other than slow it down, we are only interested in
preventing unauthorized applications control the driver)


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

There has already been a discussion in this list about this topic. The bottom line is the following: you can be patched and still IOCTLed.

What can be patched? Do you know the title of the thread, I have no idea what to search for on this topic.

xxxxx@shcherbyna.com wrote:

There has already been a discussion in this list about this topic. The bottom line is the following: you can be patched and still IOCTLed.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

http://www.osronline.com/showThread.cfm?link=200605

I don’t see anything related to special casing the system process there.

In general, special casing the system process is often not the right answer except in extenuating circumstances.

  • S (Msft)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@shcherbyna.com
Sent: Friday, May 06, 2011 8:51 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Verifying a controlling process

http://www.osronline.com/showThread.cfm?link=200605


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Well, this URL is to answer OP question about the IP in drivers.

“Skywing” wrote in message news:xxxxx@ntdev…

I don’t see anything related to special casing the system process there.

In general, special casing the system process is often not the right answer
except in extenuating circumstances.

  • S (Msft)

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@shcherbyna.com
Sent: Friday, May 06, 2011 8:51 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Verifying a controlling process

http://www.osronline.com/showThread.cfm?link=200605


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Starting in Vista services can be assigned unique SIDs which can then be
used to ACL your device object. Not sure how appropriate this would be based
on your requirements, but worth mentioning. I think this feature fell under
what they called, “service hardening” in Vista, so Google should be able to
provide more details.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dejan Maksimovic” wrote in message news:xxxxx@ntdev…

Has anyone implemented a way to verify that the process controlling
the driver is supposed to control it?
We can have hardcoded hashes of the allowed executables that can
control the driver. What I am worried is how easy would it be for
applications to emulate as if the other application is making the call?
(we are not worried about a driver helping applications, at that point
we cannot do much other than slow it down, we are only interested in
preventing unauthorized applications control the driver)


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Quite unrelated. The idea is not to protect us but rather the controlling application and file data integrity.
Once a controlling applications sets certain parameters, we want to let only that application change the parameters.

xxxxx@shcherbyna.com wrote:

http://www.osronline.com/showThread.cfm?link=200605


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Applications won’t be services. And we won’t have any control over them.

Scott Noone wrote:

Starting in Vista services can be assigned unique SIDs which can then be
used to ACL your device object. Not sure how appropriate this would be based
on your requirements, but worth mentioning. I think this feature fell under
what they called, “service hardening” in Vista, so Google should be able to
provide more details.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dejan Maksimovic” wrote in message news:xxxxx@ntdev…

Has anyone implemented a way to verify that the process controlling
the driver is supposed to control it?
We can have hardcoded hashes of the allowed executables that can
control the driver. What I am worried is how easy would it be for
applications to emulate as if the other application is making the call?
(we are not worried about a driver helping applications, at that point
we cannot do much other than slow it down, we are only interested in
preventing unauthorized applications control the driver)


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Bummer. Then I’m not sure what you do aside from whitelisting.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dejan Maksimovic” wrote in message news:xxxxx@ntdev…

Applications won’t be services. And we won’t have any control over them.

Scott Noone wrote:

Starting in Vista services can be assigned unique SIDs which can then be
used to ACL your device object. Not sure how appropriate this would be
based
on your requirements, but worth mentioning. I think this feature fell
under
what they called, “service hardening” in Vista, so Google should be able
to
provide more details.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Dejan Maksimovic” wrote in message news:xxxxx@ntdev…

Has anyone implemented a way to verify that the process controlling
the driver is supposed to control it?
We can have hardcoded hashes of the allowed executables that can
control the driver. What I am worried is how easy would it be for
applications to emulate as if the other application is making the call?
(we are not worried about a driver helping applications, at that point
we cannot do much other than slow it down, we are only interested in
preventing unauthorized applications control the driver)


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Let me run this by you (all) then.

There are two types of control codes for our driver - Send Entry and Delete/change Entry. Any application should
be able to Send new entries, but only that application should be able to change/delete that specific entry.
If I get the process image file name during Send Entry call, compute the hash, save it and compare it against
the process image’s hash during Change/Delete, what can a user mode application do to subvert that? Provided that
the application cannot load any new drivers, in which case all bets are off obviously.

Scott Noone wrote:

Bummer. Then I’m not sure what you do aside from whitelisting.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

An application could inject a thread into your application.

Bill Wandel

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dejan Maksimovic
Sent: Wednesday, May 11, 2011 10:11 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Verifying a controlling process

Let me run this by you (all) then.

There are two types of control codes for our driver - Send Entry and
Delete/change Entry. Any application should
be able to Send new entries, but only that application should be able to
change/delete that specific entry.
If I get the process image file name during Send Entry call, compute the
hash, save it and compare it against
the process image’s hash during Change/Delete, what can a user mode
application do to subvert that? Provided that
the application cannot load any new drivers, in which case all bets are off
obviously.

Scott Noone wrote:

Bummer. Then I’m not sure what you do aside from whitelisting.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Yeah, I would inject a dll into your application and would hook your DeviceIoControl function.

Dejan Maksimovic wrote:

Let me run this by you (all) then.

There are two types of control codes for our driver - Send Entry and Delete/change Entry. Any application should be able to Send new entries, but only that application should be able to change/delete that specific entry.
If I get the process image file name during Send Entry call, compute the hash, save it and compare it against the process image’s hash during Change/Delete, what can a user mode application do to subvert that? Provided that the application cannot load any new drivers, in which case all bets are off obviously.

Wouldn’t it be just as good – and much easier – for you to return a
random key when you create the entry, then require that key to be
specified when you do the Change/Delete?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Dejan,

First things first, Hope you know that is is a losing battle and all you can
achieve is to delay/stall the attacker…

Having said this, what you are trying to achieve is ‘caller validation’, if
it is not, then I mis-interpret the thread, and you need not read any
further.

There are a few things you can try (and non of these would help if the
attacker has admin rights)

  1. Validate the hash of the function calling into your driver (HMAC) (make
    sure there are no relocatable codes in the segment) - Works if there are no
    other functions in between, since there are several layers of software
    between your app and your driver, then finding the caller’s IP and return
    address would only lead you to some kernel component. There are a few work
    arounds:

1.a Walk the stack back: Difficult without symbols, and FPO might be a
problem too, but still a doable thing. The tough thing is to know, how far
back the stack you gotta walk, before you jay walk :slight_smile:
1.b Generate an interrupt and jump straight from ring 3 to 0. The interrupt
handler in the driver will get immediate control and the EIP will point to
the original caller. Ofcourse, the usual targets are the debug interrupts
The problem here is vista and above kind of dislikes this approach. But
again doable.

  1. To prevent debuggers from attaching to your process: There are several
    known ways to detect debuggers, some of them are specific to certain
    debuggers, and all of them have known work arounds by hackers.
  2. Move your protection code outside the purview of the OS: Like in a
    headless hyper visor, to disarm debugger based attacks.
  3. Split up the data from the command. The IOCTL goes in with junk data, and
    the actual command/data goes in through a different route, like 1.b
  4. Encrpytion: ARmadillo or similar techniques to protct the process in
    memory.
  5. Instead of trusting a process, spawn the process from the Driver. The
    process binary (or a stub) can be inside the driver as a resource, not an
    easy thing to achieve.
  6. Use a trusted third party to validate the process, like a webserver with
    a key generated and with a short-finite key validity life.
  7. The list goes on…

We did all of this, and were wondering where we draw the line, after all
many of these things are in antivirus domain, we were just a security
product. And after doing al of this, when we wanted the code pen-tested, t
took the hacker (one of the best in profession) all but 3 days to make the
code dance to his/her tunes.

Your best bet is 3 or 7…

Thanks

amit

On Thu, May 12, 2011 at 9:28 PM, Tim Roberts wrote:

> Dejan Maksimovic wrote:
> > Let me run this by you (all) then.
> >
> > There are two types of control codes for our driver - Send Entry and
> Delete/change Entry. Any application should be able to Send new entries, but
> only that application should be able to change/delete that specific entry.
> > If I get the process image file name during Send Entry call, compute
> the hash, save it and compare it against the process image’s hash during
> Change/Delete, what can a user mode application do to subvert that? Provided
> that the application cannot load any new drivers, in which case all bets are
> off obviously.
>
> Wouldn’t it be just as good – and much easier – for you to return a
> random key when you create the entry, then require that key to be
> specified when you do the Change/Delete?
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>



- amitr0

Is that possible without a driver on x64?

Bill Wandel wrote:

An application could inject a thread into your application.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

That is probably the most appealing approach. The application would need to save it if it wants to change the entries, but it would work for those need it.

Tim Roberts wrote:

Wouldn’t it be just as good – and much easier – for you to return a random key when you create the entry, then require that key to be specified when you do the Change/Delete?


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.

Dejan Maksimovic wrote:

Is that possible without a driver on x64?

Sure. That’s how window hooks work.

However, the attacker would have to know exactly what they were looking
for and where to find it. They wouldn’t have access to the symbols in
that process.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Or use CreateRemoteThread to load a dll into your process.

Bill

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Thursday, May 12, 2011 5:02 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Verifying a controlling process

Dejan Maksimovic wrote:

Is that possible without a driver on x64?

Sure. That’s how window hooks work.

However, the attacker would have to know exactly what they were looking
for and where to find it. They wouldn’t have access to the symbols in
that process.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Luckily, I do not need even 1% of that (actually none of that).
I feel this is something where 1% of the all possible work would be
enough to secure 99% of the paths, and the other 1% of them cannot be
secured and we are not even interested in those other 1% (at that point
there are much larger security issues on the system than whether the
caller is the original caller).

And yes I am quite aware that this a losing battle on the security
front. The question is what needs to be secured, i.e. how valuable it is
and how skilled an attacker is. In my case it’s not valuable data in
question and it’s not a skilled hacker at all. But I am more afraid of
Joe Plumbers and Jane Sextetaries (not a typo) because I know how a
hacker thinks and what I can do about it - Joes and Janes gave me more
grief than hackers :wink:

amitr0 wrote:

Dejan,

First things first, Hope you know that is is a losing battle and all
you can
achieve is to delay/stall the attacker…

Having said this, what you are trying to achieve is ‘caller
validation’, if
it is not, then I mis-interpret the thread, and you need not read any
further.

There are a few things you can try (and non of these would help if the

attacker has admin rights)

  1. Validate the hash of the function calling into your driver (HMAC)
    (make
    sure there are no relocatable codes in the segment) - Works if there
    are no
    other functions in between, since there are several layers of software

between your app and your driver, then finding the caller’s IP and
return
address would only lead you to some kernel component. There are a few
work
arounds:

1.a Walk the stack back: Difficult without symbols, and FPO might be a

problem too, but still a doable thing. The tough thing is to know, how
far
back the stack you gotta walk, before you jay walk :slight_smile:
1.b Generate an interrupt and jump straight from ring 3 to 0. The
interrupt
handler in the driver will get immediate control and the EIP will
point to
the original caller. Ofcourse, the usual targets are the debug
interrupts
The problem here is vista and above kind of dislikes this approach.
But
again doable.

  1. To prevent debuggers from attaching to your process: There are
    several
    known ways to detect debuggers, some of them are specific to certain
    debuggers, and all of them have known work arounds by hackers.
  2. Move your protection code outside the purview of the OS: Like in a
    headless hyper visor, to disarm debugger based attacks.
  3. Split up the data from the command. The IOCTL goes in with junk
    data, and
    the actual command/data goes in through a different route, like 1.b
  4. Encrpytion: ARmadillo or similar techniques to protct the process
    in
    memory.
  5. Instead of trusting a process, spawn the process from the Driver.
    The
    process binary (or a stub) can be inside the driver as a resource, not
    an
    easy thing to achieve.
  6. Use a trusted third party to validate the process, like a webserver
    with
    a key generated and with a short-finite key validity life.
  7. The list goes on…

We did all of this, and were wondering where we draw the line, after
all
many of these things are in antivirus domain, we were just a security
product. And after doing al of this, when we wanted the code
pen-tested, t
took the hacker (one of the best in profession) all but 3 days to make
the
code dance to his/her tunes.


Kind regards, Dejan (MSN support: xxxxx@alfasp.com)
http://www.alfasp.com
File system audit, security and encryption kits.