Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intercept deserialization errors in WCF

I was recently asked by a security team if it was possible to change the message returned from deserialization issues within a WCF service. The error in question was when they intercepted the message and passed an integer that was outside the bounds of Int32.

The value '2147483649' cannot be parsed as the type 'Int32'.

My answer was that the deserialization process occurs before a single line of my service is executed and that it is not possible. However, is it possible to achieve this goal?

like image 755
Tom Fobear Avatar asked Dec 22 '25 13:12

Tom Fobear


1 Answers

It sounds like you have includeExceptionDetailInFaults="true". True is the default value that should be set to false before you do a production deploy. Once this is false you will get a generic error message. That should be enough to make security happy.

An even better option is to implement an IErrorHandler. That's the extension point that allow you to handle the exception, even though it happens before execution reaches your service code.

like image 99
ErnieL Avatar answered Dec 24 '25 04:12

ErnieL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!