Home All Groups Group Topic Archive Search About

encrypting app.config with RSA

Author
19 Jan 2006 9:06 PM
Eric
I'd like my application to encrypt certian secitons of the config file. I'd
like to use the System.Configuration.SectionInformation.ProtectSection API.
However, I'd like the application to be able to decrypt the file no matter
what user is using it or what machine they are running on. So I can't use the
DPAPI provider.

That means I have to use the RSA provider, but by default, it still uses the
user keys or the machine keys. Is there a way to get the provider to only use
keys that my app specifies? I know that the RSA class has an AddKey method,
but I can't find a way to get that to work with the ProtectSection method.

Author
19 Jan 2006 9:29 PM
Dominick Baier [DevelopMentor]
Hi,

user/machine only specifies which store to use - you further can specify
the key container name.

You have to create a rsa key and import it on every single machine. You also
have to set ACLs on the key container.

To avoid having to change machine.config on every machine you could overwrite
the default key container called "NetFrameworkConfigurationKey"

the security you gain from this is questionable - if every user on every
machine has access to the private key - this is not much better than clear
text :)

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

Show quoteHide quote
> I'd like my application to encrypt certian secitons of the config
> file. I'd like to use the
> System.Configuration.SectionInformation.ProtectSection API. However,
> I'd like the application to be able to decrypt the file no matter what
> user is using it or what machine they are running on. So I can't use
> the DPAPI provider.
>
> That means I have to use the RSA provider, but by default, it still
> uses the user keys or the machine keys. Is there a way to get the
> provider to only use keys that my app specifies? I know that the RSA
> class has an AddKey method, but I can't find a way to get that to work
> with the ProtectSection method.
>
Author
19 Jan 2006 9:47 PM
Eric
I don't want the users to be able to read it, I want my app to be able to
read it with out the user being able to read it.

Show quoteHide quote
"Dominick Baier [DevelopMentor]" wrote:

> Hi,
>
> user/machine only specifies which store to use - you further can specify
> the key container name.
>
> You have to create a rsa key and import it on every single machine. You also
> have to set ACLs on the key container.
>
> To avoid having to change machine.config on every machine you could overwrite
> the default key container called "NetFrameworkConfigurationKey"
>
> the security you gain from this is questionable - if every user on every
> machine has access to the private key - this is not much better than clear
> text :)
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
> > I'd like my application to encrypt certian secitons of the config
> > file. I'd like to use the
> > System.Configuration.SectionInformation.ProtectSection API. However,
> > I'd like the application to be able to decrypt the file no matter what
> > user is using it or what machine they are running on. So I can't use
> > the DPAPI provider.
> >
> > That means I have to use the RSA provider, but by default, it still
> > uses the user keys or the machine keys. Is there a way to get the
> > provider to only use keys that my app specifies? I know that the RSA
> > class has an AddKey method, but I can't find a way to get that to work
> > with the ProtectSection method.
> >
>
>
>
Author
19 Jan 2006 11:11 PM
Dominick Baier [DevelopMentor]
Hi,

OK - but the app is running in the security context of the user - so everyting
the app can do - can be also done by the user.

A user could write a c# app to decrypt the section. would be no problem.

But still this is better than having clear text configs.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

Show quoteHide quote
> I don't want the users to be able to read it, I want my app to be able
> to read it with out the user being able to read it.
>
> "Dominick Baier [DevelopMentor]" wrote:
>
>> Hi,
>>
>> user/machine only specifies which store to use - you further can
>> specify the key container name.
>>
>> You have to create a rsa key and import it on every single machine.
>> You also have to set ACLs on the key container.
>>
>> To avoid having to change machine.config on every machine you could
>> overwrite the default key container called
>> "NetFrameworkConfigurationKey"
>>
>> the security you gain from this is questionable - if every user on
>> every machine has access to the private key - this is not much better
>> than clear text :)
>>
>> ---------------------------------------
>> Dominick Baier - DevelopMentor
>> http://www.leastprivilege.com
>>> I'd like my application to encrypt certian secitons of the config
>>> file. I'd like to use the
>>> System.Configuration.SectionInformation.ProtectSection API. However,
>>> I'd like the application to be able to decrypt the file no matter
>>> what user is using it or what machine they are running on. So I
>>> can't use the DPAPI provider.
>>>
>>> That means I have to use the RSA provider, but by default, it still
>>> uses the user keys or the machine keys. Is there a way to get the
>>> provider to only use keys that my app specifies? I know that the RSA
>>> class has an AddKey method, but I can't find a way to get that to
>>> work with the ProtectSection method.
>>>
Author
15 Mar 2006 11:25 AM
Leo Leys
Is there a secure way to encrypt sensible information in a .net application
so that nobody but the application (and the developer of course)  can reveal
that sensitive information (a password for instance as part of a
connectionstring connecting to a sql server 2000 database). The context I
have in mind is a windows application installed on user's machines.

I understand that the "protectsection" approach actually is not secure at
all, is it?

Thanks

Leo Leys


Show quoteHide quote
"Dominick Baier [DevelopMentor]" wrote:

> Hi,
>
> OK - but the app is running in the security context of the user - so everyting
> the app can do - can be also done by the user.
>
> A user could write a c# app to decrypt the section. would be no problem.
>
> But still this is better than having clear text configs.
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
> > I don't want the users to be able to read it, I want my app to be able
> > to read it with out the user being able to read it.
> >
> > "Dominick Baier [DevelopMentor]" wrote:
> >
> >> Hi,
> >>
> >> user/machine only specifies which store to use - you further can
> >> specify the key container name.
> >>
> >> You have to create a rsa key and import it on every single machine.
> >> You also have to set ACLs on the key container.
> >>
> >> To avoid having to change machine.config on every machine you could
> >> overwrite the default key container called
> >> "NetFrameworkConfigurationKey"
> >>
> >> the security you gain from this is questionable - if every user on
> >> every machine has access to the private key - this is not much better
> >> than clear text :)
> >>
> >> ---------------------------------------
> >> Dominick Baier - DevelopMentor
> >> http://www.leastprivilege.com
> >>> I'd like my application to encrypt certian secitons of the config
> >>> file. I'd like to use the
> >>> System.Configuration.SectionInformation.ProtectSection API. However,
> >>> I'd like the application to be able to decrypt the file no matter
> >>> what user is using it or what machine they are running on. So I
> >>> can't use the DPAPI provider.
> >>>
> >>> That means I have to use the RSA provider, but by default, it still
> >>> uses the user keys or the machine keys. Is there a way to get the
> >>> provider to only use keys that my app specifies? I know that the RSA
> >>> class has an AddKey method, but I can't find a way to get that to
> >>> work with the ProtectSection method.
> >>>
>
>
>
Author
15 Mar 2006 11:46 AM
Dominick Baier [DevelopMentor]
Hi,

no there is no such way - and don't try something hacky like embedding a
hardcoced key in source code (which isn't secure at all either)

If the application (running in the security context of the user) is able
to read that secret - the user is too.

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

Show quoteHide quote
> Is there a secure way to encrypt sensible information in a .net
> application so that nobody but the application (and the developer of
> course)  can reveal that sensitive information (a password for
> instance as part of a connectionstring connecting to a sql server 2000
> database). The context I have in mind is a windows application
> installed on user's machines.
>
> I understand that the "protectsection" approach actually is not secure
> at all, is it?
>
> Thanks
>
> Leo Leys
>
> "Dominick Baier [DevelopMentor]" wrote:
>
>> Hi,
>>
>> OK - but the app is running in the security context of the user - so
>> everyting the app can do - can be also done by the user.
>>
>> A user could write a c# app to decrypt the section. would be no
>> problem.
>>
>> But still this is better than having clear text configs.
>>
>> ---------------------------------------
>> Dominick Baier - DevelopMentor
>> http://www.leastprivilege.com
>>> I don't want the users to be able to read it, I want my app to be
>>> able to read it with out the user being able to read it.
>>>
>>> "Dominick Baier [DevelopMentor]" wrote:
>>>
>>>> Hi,
>>>>
>>>> user/machine only specifies which store to use - you further can
>>>> specify the key container name.
>>>>
>>>> You have to create a rsa key and import it on every single machine.
>>>> You also have to set ACLs on the key container.
>>>>
>>>> To avoid having to change machine.config on every machine you could
>>>> overwrite the default key container called
>>>> "NetFrameworkConfigurationKey"
>>>>
>>>> the security you gain from this is questionable - if every user on
>>>> every machine has access to the private key - this is not much
>>>> better than clear text :)
>>>>
>>>> ---------------------------------------
>>>> Dominick Baier - DevelopMentor
>>>> http://www.leastprivilege.com
>>>>> I'd like my application to encrypt certian secitons of the config
>>>>> file. I'd like to use the
>>>>> System.Configuration.SectionInformation.ProtectSection API.
>>>>> However, I'd like the application to be able to decrypt the file
>>>>> no matter what user is using it or what machine they are running
>>>>> on. So I can't use the DPAPI provider.
>>>>>
>>>>> That means I have to use the RSA provider, but by default, it
>>>>> still uses the user keys or the machine keys. Is there a way to
>>>>> get the provider to only use keys that my app specifies? I know
>>>>> that the RSA class has an AddKey method, but I can't find a way to
>>>>> get that to work with the ProtectSection method.
>>>>>
Author
15 Mar 2006 1:11 PM
Mitch Gallant
Also, read "Protecting Secret Data" Ch. 9 in:
"Writing Secure Code", Howard and LeBlanc,  2nd Edn. 2003, Microsoft Press.

- Mitch

Show quoteHide quote
"Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> wrote in message
news:4580be631983848c81645a0a22420@news.microsoft.com...
> Hi,
> no there is no such way - and don't try something hacky like embedding a hardcoced key in source code (which isn't
> secure at all either)
>
> If the application (running in the security context of the user) is able to read that secret - the user is too.
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>> Is there a secure way to encrypt sensible information in a .net
>> application so that nobody but the application (and the developer of
>> course)  can reveal that sensitive information (a password for
>> instance as part of a connectionstring connecting to a sql server 2000
>> database). The context I have in mind is a windows application
>> installed on user's machines.
>>
>> I understand that the "protectsection" approach actually is not secure
>> at all, is it?
>>
>> Thanks
>>
>> Leo Leys
>>
>> "Dominick Baier [DevelopMentor]" wrote:
>>
>>> Hi,
>>>
>>> OK - but the app is running in the security context of the user - so
>>> everyting the app can do - can be also done by the user.
>>>
>>> A user could write a c# app to decrypt the section. would be no
>>> problem.
>>>
>>> But still this is better than having clear text configs.
>>>
>>> ---------------------------------------
>>> Dominick Baier - DevelopMentor
>>> http://www.leastprivilege.com
>>>> I don't want the users to be able to read it, I want my app to be
>>>> able to read it with out the user being able to read it.
>>>>
>>>> "Dominick Baier [DevelopMentor]" wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> user/machine only specifies which store to use - you further can
>>>>> specify the key container name.
>>>>>
>>>>> You have to create a rsa key and import it on every single machine.
>>>>> You also have to set ACLs on the key container.
>>>>>
>>>>> To avoid having to change machine.config on every machine you could
>>>>> overwrite the default key container called
>>>>> "NetFrameworkConfigurationKey"
>>>>>
>>>>> the security you gain from this is questionable - if every user on
>>>>> every machine has access to the private key - this is not much
>>>>> better than clear text :)
>>>>>
>>>>> ---------------------------------------
>>>>> Dominick Baier - DevelopMentor
>>>>> http://www.leastprivilege.com
>>>>>> I'd like my application to encrypt certian secitons of the config
>>>>>> file. I'd like to use the
>>>>>> System.Configuration.SectionInformation.ProtectSection API.
>>>>>> However, I'd like the application to be able to decrypt the file
>>>>>> no matter what user is using it or what machine they are running
>>>>>> on. So I can't use the DPAPI provider.
>>>>>>
>>>>>> That means I have to use the RSA provider, but by default, it
>>>>>> still uses the user keys or the machine keys. Is there a way to
>>>>>> get the provider to only use keys that my app specifies? I know
>>>>>> that the RSA class has an AddKey method, but I can't find a way to
>>>>>> get that to work with the ProtectSection method.
>>>>>>
>
>