An interesting point, which may be unique to the shared host environment! It
may lead me to favor using entropy as well. This would require more effort,
and skill, to exploit - assuming the entropy value was hidden inside the
code.
Yes, it's true that a change in hardware might disable an application which
was dependent on the machine key! That's why I have written a simple .aspx
page to encrypt/decrypt using this same technique, so an administrator could
update the encrypted string. The hosting service could also, in theory,
commit to maintaining the machine key (just as you need to in a web farm for
the same reason).
As you point out, adding entropy leads to the circular problem of having a
secret left to protect. But it's at least smaller, and perhaps not as easy
to sniff out, and could be obfuscated in the code. Decrypting the string
once into the cache at startup would alleviate the performance issue for
decrypting.
I am curious as to whether the permissions on another application's
web.config file are actually sufficient to allow one to read it. (If I get
curious enough, I have more than one app hosted at my service, and I could
try to get at another app's file).
"Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
news:%23B%239b9eQEHA.2716@tk2msftngp13.phx.gbl...[color=blue]
> Yes, but the READ access to the web.config is quite open (it includes
> Everyone, Guest, etc), so to read a value from it may not be a big problem
> for any "other application" running on the same machine.
>
> "Rick Spiewak" <rickspiewak@mindspring.com> wrote in message
> news:u5r7U3eQEHA.2936@TK2MSFTNGP12.phx.gbl...[color=green]
> > Yes, but the "other application" would need access to your web.config[/color]
> file.[color=green]
> > Remember, that the objective in security can never be "absolute" - it's[/color]
> just[color=green]
> > to make the cost of acquiring information greater than the value. You[/color][/color]
can[color=blue][color=green]
> > never do any better than that. That plus a little diligence to detect
> > misuse of information is all you need.
> >
> > "Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in message
> > news:u809F4HQEHA.3708@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > I don't think that using DPAPI with machine key gives you any[/color][/color][/color]
particular[color=blue][color=green][color=darkred]
> > > advantage. After all any application running on the same server will[/color][/color][/color]
be[color=blue][color=green]
> > able[color=darkred]
> > > to decrypt data encrypted using DPAPI with machine key, so it is not[/color]
> > really[color=darkred]
> > > secure, unless you use secondary entropy, but if you do, it is no[/color][/color][/color]
better[color=blue][color=green][color=darkred]
> > > than hiding encryption key (or pass phrase) in the source code (since[/color][/color]
> you[color=green][color=darkred]
> > > need to store this entropy somewhere).
> > >
> > > The truth is that in a Web hosting environment, all feasible options[/color][/color][/color]
are[color=blue][color=green][color=darkred]
> > > bad, but there is not much you can do about it. From the security
> > > perspective, shared hosting (and I assume that we are not talking[/color][/color][/color]
about[color=blue][color=green][color=darkred]
> > > dedicated hosting) is probably the worst environment you can think of.[/color][/color]
> You[color=green][color=darkred]
> > > share the server with other customers, so in addition to external[/color][/color]
> hackers[color=green][color=darkred]
> > > there is a potential threat coming from your neighbors. And your[/color][/color][/color]
server[color=blue]
> is[color=green][color=darkred]
> > > managed by people you have no control over, so there is no way you can
> > > enforce security procedures and make sure that the system is safe. But[/color]
> > what[color=darkred]
> > > can you do? I assume that there is at least some level of trust[/color][/color][/color]
between[color=blue][color=green]
> > you[color=darkred]
> > > and the hosting company. Suspecting the hosting company to[/color][/color][/color]
intentionally[color=blue][color=green][color=darkred]
> > > hack your application is probably not reasonable (although who[/color][/color][/color]
knows?),[color=blue][color=green]
> > but[color=darkred]
> > > they can make a mistake and unintentionally leave your application
> > > vulnerable.
> > >
> > > As I said, in this scenario a reasonable option would be to hide pass[/color]
> > phrase[color=darkred]
> > > in the source code and obfuscate the assembly. Assuming that the[/color]
> > application[color=darkred]
> > > does not give access to the FBI files or Citibank accounts, it should[/color][/color][/color]
be[color=blue]
> a[color=green][color=darkred]
> > > reasonably sufficient deterrent for most hackers. Using DPAPI with[/color][/color]
> machine[color=green][color=darkred]
> > > store (and secondary entropy + obfuscation) is another alternative,[/color][/color][/color]
but[color=blue]
> it[color=green][color=darkred]
> > > is too much overhead with no additional benefits. And there is a[/color][/color]
> potential[color=green][color=darkred]
> > > to lose data in case the application is moved to a different server,[/color][/color]
> which[color=green][color=darkred]
> > > is not unheard of.
> > >
> > > Alek
> > >
> > > "Rick Spiewak" <rickspiewak@mindspring.com> wrote in message
> > > news:uQS3Yw6PEHA.644@tk2msftngp13.phx.gbl...
> > > > See the following article:
> > > >
> > >[/color]
> >[/color]
>[/color]
http://msdn.microsoft.com/library/de...SecNetHT07.asp.[color=blue][color=green][color=darkred]
> > > > This describes the use of the DPAPI library and the machine key (or[/color][/color]
> user[color=green][color=darkred]
> > > > key, but for your purpose stick to the machine key) to encrypt and[/color]
> > decrypt[color=darkred]
> > > > things like the connection string. Because the key is known by the[/color][/color]
> DPAPI[color=green][color=darkred]
> > > > library, you don't need to provide it (or even know it).
> > > >
> > > > You can pretty easily follow the article, and compile the library.[/color][/color]
> I've[color=green][color=darkred]
> > > also
> > > > written a VB.NET "wrapper" which simplifies the use of this library[/color][/color]
> (but[color=green][color=darkred]
> > > > still requires it) if you're interested. You will then need to use[/color][/color][/color]
an[color=blue][color=green][color=darkred]
> > > > ASP.NET page (I've also written that if you like) which you will
> > > temporarily
> > > > install on your web site - the encryption technique used here relies[/color][/color]
> on[color=green][color=darkred]
> > > the
> > > > machine key for the actual machine on which you are running, so you[/color]
> > can't[color=darkred]
> > > do
> > > > this with a Windows app, although you could also do it with a web[/color]
> > service.[color=darkred]
> > > >
> > > > You can then encrypt the connection string, and put it into the[/color][/color][/color]
config[color=blue][color=green][color=darkred]
> > > file,
> > > > and then decrypt it at runtime. Then, if you're using an ASP.NET[/color][/color][/color]
page[color=blue][color=green][color=darkred]
> > > which
> > > > knows how to encrypt/decrypt using DPAPI, you should remove it from[/color][/color]
> your[color=green][color=darkred]
> > > web
> > > > site since anyone who could find their way to it could use the[/color]
> > decryption[color=darkred]
> > > > facility!!
> > > >
> > > > The only caveat is that if your hosting service replaces the machine
> > > you're
> > > > running on and doesn't maintain the machine key, you'll have to[/color][/color][/color]
re-do[color=blue][color=green]
> > the[color=darkred]
> > > > encryption steps above.
> > > >
> > > > "Alek Davis" <alek_xDOTx_davis_xATx_intel_xDOTx_com> wrote in[/color][/color][/color]
message[color=blue][color=green][color=darkred]
> > > > news:ei79Ws3PEHA.832@TK2MSFTNGP09.phx.gbl...
> > > > > Charlie,
> > > > >
> > > > > If you use passwords for user authentication only, do not use
> > > encryption,
> > > > > use hashing (with salt) instead. If you need to use encryption, in[/color]
> > your[color=darkred]
> > > > > particular scenario (Web hosting environment to which you have[/color][/color]
> limited[color=green][color=darkred]
> > > > > access), the best you can do is use a tool like CipherLite.NET[/color][/color][/color]
(see[color=blue][color=green][color=darkred]
> > > > >
http://www.obviex.com/cipherlite/). You will need to embed the
> > > passphrase
> > > > > (to generate encryption key) in your code, so if a hacker gets[/color][/color][/color]
hold[color=blue]
> of[color=green][color=darkred]
> > > > your
> > > > > assembly, this passphrase can be easily retrieved unless you[/color][/color]
> obfuscate[color=green][color=darkred]
> > > the
> > > > > assembly using a good commercial obfuscator (and even this will[/color][/color][/color]
not[color=blue][color=green][color=darkred]
> > > > > guarantee security). Unfortunately, you don't have many options.[/color][/color][/color]
If[color=blue][color=green]
> > you[color=darkred]
> > > > find
> > > > > a better approach, please post it here; there may be other readers[/color][/color]
> in[color=green][color=darkred]
> > > the
> > > > > same situation.
> > > > >
> > > > > Alek
> > > > >
> > > > > "Charlie@CBFC" <charle1@comcast.net> wrote in message
> > > > > news:O80gzh3PEHA.3232@TK2MSFTNGP11.phx.gbl...
> > > > > > Hi:
> > > > > >
> > > > > > My host will not allow me use a trusted connection or make[/color][/color]
> registry[color=green][color=darkred]
> > > > > setting,
> > > > > > so I'm stuck trying find a way to hide connection string which[/color][/color]
> will[color=green]
> > be[color=darkred]
> > > > > > stored in web.config file. If I encrypt string externally, can[/color][/color][/color]
it[color=blue][color=green]
> > be[color=darkred]
> > > > used
> > > > > > in it's encrypted form to connect to SQL Server? If I decrypt[/color][/color]
> back[color=green]
> > to[color=darkred]
> > > > > > string for use in connection string during runtime, I have to[/color][/color]
> supply[color=green]
> > a[color=darkred]
> > > > > key.
> > > > > > If I do that, hacker could use key to break encryption. How do[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > handle
> > > > > > this? I'll be storing passwords in database and don't want a[/color][/color]
> hacker[color=green][color=darkred]
> > > to
> > > > > get
> > > > > > in.
> > > > > >
> > > > > > Thanks,
> > > > > > Charlie
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]