Improving Web Services Security: Scenarios and Implementation Guidance for WCF
WCF Security Checklist
.png)
Design Considerations
|
Check
|
Description
|
.gif)
|
Consider exposing different endpoints.
|
.gif)
|
If you need to support ASMX clients, use basicHttpBinding.
|
.gif)
|
If you are migrating from DCOM, use netTcpBinding.
|
.gif)
|
If you need to support legacy WSE clients, use a customBinding in WCF.
|
.gif)
|
If you require interoperability with non-Microsoft clients, use bindings that are targeted for interoperability.
|
.gif)
|
If your non-Microsoft clients understand the WS* stack, use ws2007HttpBinding or wsHttpBinding.
|
.gif)
|
Consider transport security as your preferred security mode.
|
.gif)
|
Know your authentication options.
|
.gif)
|
Know your authorization options.
|
.gif)
|
Know your binding options.
|
.gif)
|
Choose the right binding for your scenario.
|
Auditing and Logging
|
Check
|
Description
|
.gif)
|
Use WCF auditing to audit your service.
|
.gif)
|
If non-repudiation is important, consider setting the SuppressAuditFailure property to false.
|
.gif)
|
Use message logging for debugging purposes.
|
.gif)
|
Instrument for user management events.
|
.gif)
|
Instrument for significant business operations.
|
.gif)
|
Protect log files from unauthorized access.
|
.gif)
|
Do not log sensitive information.
|
.gif)
|
Protect information in log files.
|
.gif)
|
Use a custom trace listener only when message filtering is needed.
|
Authentication
|
Check
|
Description
|
.gif)
|
Know your authentication options.
|
.gif)
|
Use Windows authentication when you can.
|
.gif)
|
If your users are in Active Directory but you can’t use Windows authentication, consider using Username authentication.
|
.gif)
|
If you are using Username authentication, use a membership provider instead of custom authentication.
|
.gif)
|
If your users are in a SQL membership store, use the SQL Server membership provider.
|
.gif)
|
If your users are in a custom store, consider using Username authentication with a custom validator.
|
.gif)
|
If your clients have certificates, consider using client certificate authentication.
|
.gif)
|
If your partner applications need to be authenticated when calling WCF services, use client certificate authentication.
|
.gif)
|
If you are using Username authentication, validate user login information.
|
.gif)
|
Do not store passwords directly in the user store.
|
.gif)
|
Enforce strong passwords.
|
.gif)
|
Protect access to your credential store.
|
.gif)
|
If you are using client certificate authentication, limit the certificates in the certificate store.
|
Authorization
|
Check
|
Description
|
.gif)
|
If you store role information in Windows groups, consider using the WCF PrincipalPermissionAttribute class for role authorization.
|
.gif)
|
If you use ASP.NET roles, use the ASP.NET Role Manager for role authorization.
|
.gif)
|
If you use Windows groups for authorization, use the ASP.NET role provider with AspNetWindowsTokenRoleProvider.
|
.gif)
|
If you store role information in SQL Server, consider using the SQL Server role provider for role authorization.
|
.gif)
|
If you store role information in ADAM, use the Authorization Manager role provider.
|
.gif)
|
If you store role information in a custom store, create a custom authorization policy.
|
.gif)
|
If you need to authorize access to WCF operations, use declarative authorization.
|
.gif)
|
If you need to perform fine-grained authorization based on business logic, use imperative authorization.
|
Bindings
|
Check
|
Description
|
.gif)
|
If you need to support clients over the Internet, consider using wsHttpBinding.
|
.gif)
|
If you need to expose your WCF service to legacy clients as an ASMX Web service, use basicHttpBinding.
|
.gif)
|
If you need to support WCF clients within an intranet, consider using netTcpBinding.
|
.gif)
|
If you need to support WCF Clients on the same machine, consider using netNamedPipeBinding.
|
.gif)
|
If you need to support disconnected queued calls, use netMsmqBinding.
|
.gif)
|
If you need to support bidirectional communication between a WCF client and WCF service, use wsDualHttpBinding or netTcpBinding.
|
Configuration Management
|
Check
|
Description
|
.gif)
|
Use replay detection to protect against message replay attacks.
|
.gif)
|
If you host your service in a Windows service, expose a metadata exchange (mex) binding.
|
.gif)
|
If you don’t want to expose your WSDL, turn off HttpGetEnabled and metadata exchange (mex).
|
.gif)
|
Encrypt configuration sections that contain sensitive data.
|
Exception Management
|
Check
|
Description
|
.gif)
|
Use structured exception handling.
|
.gif)
|
Do not divulge exception details to clients in production.
|
.gif)
|
Use a fault contract to return error information to clients.
|
.gif)
|
Use a global exception handler to catch unhandled exceptions.
|
Hosting
|
Check
|
Description
|
.gif)
|
Run your service in a least-privileged account.
|
.gif)
|
Use IIS to host your service, unless you need to use a transport that IIS does not support.
|
Impersonation/Delegation
|
Check
|
Description
|
.gif)
|
Know the tradeoffs involved in impersonation.
|
.gif)
|
Know your impersonation options.
|
.gif)
|
Know your impersonation methods.
|
.gif)
|
Consider using programmatic instead of declarative impersonation.
|
.gif)
|
When impersonating programmatically, be sure to revert to the original context.
|
.gif)
|
When impersonating declaratively, only impersonate on the operations that require it.
|
.gif)
|
When you cannot do a Windows mapping, consider using the S4U feature for impersonation and delegation.
|
.gif)
|
If your WCF service cannot be trusted for delegation, consider using the LogonUser API.
|
.gif)
|
If you have to flow the original caller to the back-end services, use constrained delegation.
|
Message Validation
|
Check
|
Description
|
.gif)
|
If you need to validate parameters, use parameter inspectors.
|
.gif)
|
Use schemas with message inspectors to validate messages.
|
.gif)
|
Use regular expressions in schemas to validate format, range, or length.
|
.gif)
|
Implement the AfterReceiveRequest method to validate inbound messages on the service.
|
.gif)
|
Implement the BeforeSendReply method to validate outbound messages on the service.
|
.gif)
|
Implement the AfterReceiveReply method to validate inbound messages on the client.
|
.gif)
|
Implement the BeforeSendRequest method to validate outbound messages on the client.
|
.gif)
|
Validate operation parameters for length, range, format, and type.
|
.gif)
|
Do not rely on client-side validation.
|
.gif)
|
Avoid user-supplied file name and path input.
|
.gif)
|
Do not echo untrusted input.
|
Message Security
|
Check
|
Description
|
.gif)
|
If you need to support clients over the Internet, consider using message security.
|
.gif)
|
If there are intermediaries between the client and service, consider using message security.
|
.gif)
|
If you need to support selective message protection, use message security.
|
.gif)
|
If you need to support multiple transactions per session using secure conversation, use message security.
|
.gif)
|
Do not pass sensitive information in SOAP headers when using HTTP transport and message security.
|
.gif)
|
If you need to support interoperability, consider setting negotiateServiceCredentials to false.
|
.gif)
|
If you need to streamline certificate distribution to your clients, consider negotiating the service credentials.
|
.gif)
|
If you need to limit the clients that will consume your service, consider setting negotiateServiceCredentials to false.
|
Transport Security
|
Check
|
Description
|
.gif)
|
Use transport security when possible.
|
.gif)
|
If you need to support clients in an intranet, use transport security.
|
.gif)
|
If you need to support interoperability with non-WCF clients, use transport security.
|
.gif)
|
Use a hardware accelerator when using transport security.
|
Proxy Considerations
|
Check
|
Description
|
.gif)
|
Publish your WCF service metadata only when required.
|
.gif)
|
If you need to publish your WCF service metadata, publish it over the HTTPS protocol.
|
.gif)
|
If you need to publish your WCF service metadata, publish it using secure binding.
|
.gif)
|
If you turn off mutual authentication, be aware of service spoofing.
|
Sensitive Data
|
Check
|
Description
|
.gif)
|
Avoid plain-text passwords or other sensitive data in configuration files.
|
.gif)
|
Use platform features to manage keys where possible.
|
.gif)
|
Protect sensitive data over the network.
|
.gif)
|
Do not cache sensitive data.
|
.gif)
|
Minimize exposure of secrets in memory.
|
.gif)
|
Be aware that basicHttpBinding will not protect sensitive data by default.
|
.gif)
|
Use appropriately sized keys.
|
Deployment Considerations
|
Check
|
Description
|
.gif)
|
Do not use temporary certificates in production.
|
.gif)
|
If you are using Kerberos authentication or delegation, create an SPN.
|
.gif)
|
Use IIS to host your WCF service wherever possible.
|
.gif)
|
Use a least-privileged account to run your WCF service.
|
.gif)
|
Protect sensitive data in your configuration files.
|