tags:

views:

57

answers:

6

In the project I'm currently working we're using WCF. Company policy forces us to use async calls and the reason should be security. I've asked why this is so much more secure but I don't get clear answers.

Can someone explain why this is so much secure?

+2  A: 

There is no point why an async call will be more secure than a sync call. I think you should talk to the owner of the policy for the same.

Kangkan
+2  A: 

No they are not more or less secure than synchronous calls. The only difference is the client waits for a response on synchronous calls, whereas on async it is notified of a response.

Are they coming from the angle that synchronous calls leave the connection open longer or something?

Adam
Would synchronous calls leave the connection open longer? I can't see that
Rup
No it wouldn't, I was trying to assume they OP's colleagues train of thought.
Adam
+3  A: 

They are not. The same security (authentication, encryption) mechanisms and considerations apply whether a call blocks until it gets a response or it uses a callback.

The only way someone may be confused into thinking that asynch calls are more "safe/secure", is they think that unhandled WCF exceptions will not bring down the main thread if they are asynchronous, as they will be raised inside the callback.

In this case, I would advice extreme caution when approaching the owner of this policy to avoid career-limiting consequences. Some people can get emotionally attached to their policies.

Panagiotis Kanavos
+1 "emotionally attached to their policies"
sarnold
Been there, burned by that, not wish it on anyone :P
Panagiotis Kanavos
To avoid career-limiting consequences, perhaps show the policy maker this page?
Saajid Ismail
'wcf exceptions will not bring down the main thread if they are asynchronous'Quite the reverse. Exceptions thrown on the WCF entry thread will be marshalled and so forth. They may fault the channel, but that's only because you didn't translate them appropriately (ie that's by design). They've not really done any damage.However exceptions thrown on any background threads you spin off are, unless handled, process terminating(!). So from this perspective you are definately safer implementing everything synchronously, where there is effectively a big try{} further up the stack...
piers7
+2  A: 

I agree with the other answers - definitely not more secure.

Fire up Fiddler and watch a synchronous request vs. an asynchronous request. You'll basically see the same type of traffic (although the sync may send and receive more data since it's probably a postback). But you can intercept both of those requests, manipulate them, and resend them and cause havoc on your server.

Fiddler's a great tool, by the way. It's an eye-opener in terms of what kind of data and how much data you're sending to the server.

David Hoerster
+2  A: 

Just exposing a WCF operation using an async signature (BeginBlah/EndBlah) doesn't actually affect the exposed operation at all. When you view the meta data, an operation like

[OperationContract(AsyncPattern=true)]
IAsyncResult BeginSomething(AsyncCallback, object)

void EndSomething(IAsyncResult)

...actually still ends up being represented as an operation called 'Something'. And actually this is one of the nice things about WCF: the client and server can differ in whether they choose to implement/consume an operation syncronously.

So if you are using generating WCF proxies (eg through Add Service Reference) then you will get syncronous versions of each operation whether they are implemented asyncronously or not unless you tick the little checkbox to generate the async overloads. And when you do you then get async versions of operations that might only be declared syncronously on the server.

All WCF is doing is, on both the client and server, giving you a choice about your threading model: do you want WCF to wait for the result, or are you going to signal it that you've finished. How the actual transport connection is managed is - to the best of my knowlege - totally unaffected. eg: For a NetTcpBinding the socket still stays open for the duration of the call, either way.

So, to get to the point, I really struggle to imagine how this could possibly make any difference to the security envelope of a WCF service. If a service is exposed using an async pattern, and is genuinely implemented in an async way (async for outbound IO, or queues work via the thread pool or something) then there's probably an argument that it would be harder to DOS the service (by exhausting the pool of WCF IO threads), but that'd be about it.

See Syncronous and Asyncronous Operations in MSDN

NB: If you are sharing the contract interface between the client and server then obviously the syncronisity of the two ends match (because they are both using the same interface type), but that's just a limitation of using a shared interface. If you made another equivilent interface, differing only by the async pattern, you could still create a ChannelFactory against it just fine.

piers7
A: 

Thanks to everybody for your input!

anagels