windows communication foundation - owasp communication foundation manu cohen-yashar cto applisec...

39
Windows Communication Windows Communication Foundation Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Upload: vokhanh

Post on 10-Apr-2018

230 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Windows Communication Windows Communication FoundationFoundation

Manu Cohen-YasharCTO ApplisecSela Group

Page 2: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

MOBILE EMPLOYEESMOBILE EMPLOYEES CUSTOMERSCUSTOMERS MOBILE EMPLOYEESMOBILE EMPLOYEESCUSTOMERSCUSTOMERS

Page 3: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

It is not only a client server It is not only a client server issueissue

Page 4: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Distributed Systems ChallengesDistributed Systems ChallengesDistributed TransactionsDistributed TransactionsSecuritySecurity

B2BB2BEnterpriseEnterpriseWeb Web ……

Versioning Versioning –– The possibility to change !The possibility to change !InteroperabilityInteroperabilityPerformancePerformanceSeparation between logic and distribution Separation between logic and distribution technology.technology.ExtensibilityExtensibility

Page 5: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group
Page 6: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

InteropInteropwith otherwith otherplatformsplatforms

ASMX

AttributeAttribute--BasedBased

ProgrammingProgramming

Enterprise Services

WSWS--**ProtocolProtocolSupportSupport

WSE

MessageMessage--OrientedOriented

ProgrammingProgramming

System.Messaging

ExtensibilityExtensibilityLocation Location

transparencytransparency

.NET Remoting

Page 7: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group
Page 8: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Services and ClientsServices and Clients

ClientClient ServiceService

MessageMessage

MessageMessage

Page 9: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

EndpointsEndpoints

ClientClient ServiceService

MessageMessageEndpointEndpoint EndpointEndpoint

EndpointEndpoint

Page 10: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Address, Binding, ContractAddress, Binding, Contract

ClientClient ServiceService

MessageMessageAABBCC AA BB CC

AA BB CC

AddressAddress BindingBinding ContractContract

(Where)(Where) (How)(How) (What)(What)

Page 11: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Bindings & Binding ElementsBindings & Binding Elements

TransportTransport

IPCIPCMSMQMSMQ

CustomCustom

TCPTCP HTTPHTTP

ProtocolProtocolEncodersEncoders

.NET.NETTXTX

CustomCustom

SecuritySecurity ReliabilityReliability

BindingBindingHTTPHTTP TXTXSecuritySecurity ReliabilityReliabilityTextText

TextText

BinaryBinary

CustomCustom

Page 12: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Elements of BindingElements of BindingTransportTransport EncoderEncoder SecuritySecurity ReliabilityReliability ProtocolProtocol

PipesPipes

MSMQMSMQ

CustomCustom

HTTPHTTP TextText

TCPTCP BinaryBinary

MTOMMTOM

CustomCustom

CustomCustom CustomCustom

WSWS--** WSWS--** WSWS--**

CustomCustom

WSWS--** WSWS--** WSWS--**HTTPHTTP TextTextTCPTCP BinaryBinary

Page 13: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

The bigger pictureThe bigger picture

CallerCaller ServiceService

MessageMessageAABBCC AA BB CC

AA BB CC

MetadataMetadata

BvBv BvBv

BvBv BvBv

ProxyProxy ServiceHost<T>()ServiceHost<T>()

Page 14: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group
Page 15: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Messaging Security Messaging Security RequirementsRequirements

ConfidentialityConfidentiality

IntegrityIntegrity

AuthenticationAuthentication

AuthorizationAuthorization

Auditing Auditing

Page 16: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

WCF Security ModelWCF Security Model

Based on credentials and claimsBased on credentials and claims

Can satisfy security requirementsCan satisfy security requirements

Secure by defaultSecure by default

Consistent across bindingsConsistent across bindings

Consistent across credentialsConsistent across credentials

Page 17: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

AuthorizationAuthorization

Normal .Net Authorization using existing Normal .Net Authorization using existing CLR constructsCLR constructs

ClaimsClaims--based model known as based model known as Identity Identity ModelModel..

Page 18: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

The Identity modelThe Identity model

ClaimsClaims--based systembased system

Claims describe the capabilities associated Claims describe the capabilities associated with some entity in the system.with some entity in the system.

Claims are used to gain access to Claims are used to gain access to resources. (Like a key)resources. (Like a key)

WCF Create claims from incoming WCF Create claims from incoming messages.messages.

Example: a claim of Example: a claim of typetype "File", with "File", with rightright"Read" over the "Read" over the valuevalue "Biography.doc""Biography.doc"

Page 19: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Claims issuerClaims issuerClaims are always issued by some entity in Claims are always issued by some entity in the system.the system.

Claims are grouped together as a set and Claims are grouped together as a set and each set has an issuer.each set has an issuer.

An issuer is just a set An issuer is just a set of claims.of claims.

Page 20: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Authorization PoliciesAuthorization PoliciesClaims are generated as part of the Claims are generated as part of the process of evaluating the authorization process of evaluating the authorization policy.policy.

Choose to add additional claims based on Choose to add additional claims based on the claims already present.the claims already present.

For example: If you have a claim identifying For example: If you have a claim identifying you as a student, the policy will give you the you as a student, the policy will give you the claim permitting you to use the library.claim permitting you to use the library.

A given authorization policyA given authorization policymay need to be evaluatedmay need to be evaluatedmultiple times.multiple times.

Page 21: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Authorization ContextAuthorization Context

An authorization manager evaluates the An authorization manager evaluates the various authorization policiesvarious authorization policies

The result is an authorization contextThe result is an authorization context

The authorization context can be examined The authorization context can be examined to determine what claims are present in to determine what claims are present in that context.that context.

Page 22: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group
Page 23: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

WCF Security out of the boxWCF Security out of the box

Page 24: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Transport Security

Security requirements satisfied atSecurity requirements satisfied attransport layertransport layer

AdvantagesAdvantagesPerformance benefitsPerformance benefits

Common implementationCommon implementation

DisadvantagesDisadvantagesRestricted claim typesRestricted claim types

No security off the wireNo security off the wire

Page 25: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Transport SecurityTransport Security<endpoint address=<endpoint address=““httpshttps://localhost/c://localhost/calculator"alculator"

binding=binding=““basicHttpbasicHttpBindingBinding““

bindingConfiguration=bindingConfiguration=““Binding1Binding1””

contract="ICalculator" />contract="ICalculator" />

<<basicHttpbasicHttpBinding>Binding>

<binding Name="Binding1"><binding Name="Binding1">

<security mode="Transport"><security mode="Transport">

<transport clientCredentialType="None"/><transport clientCredentialType="None"/>

</security></security>

</binding></binding>

</</basicbasicProfileBinding>ProfileBinding>

Only the server certificate will be used (server Only the server certificate will be used (server authentication)authentication)

Page 26: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Transport Security technologyTransport Security technologyDepend on the binding and transport Depend on the binding and transport being usedbeing used

WsHttpBinding WsHttpBinding –– Https (Default)Https (Default)

NetTcpBinding NetTcpBinding –– TLS (Default)TLS (Default)

BasicHttpBinding BasicHttpBinding –– None (Default)None (Default)Can be configured to:Can be configured to:

BasicBasic

CertificateCertificate

DigestDigest

NTLMNTLM

WindowsWindows

Page 27: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Message SecuritySecurity requirements satisfied atSecurity requirements satisfied atmessage layermessage layer

AdvantagesAdvantagesMore credential typesMore credential types

ExtensibleExtensible

EndEnd--toto--end securityend security

DisadvantagesDisadvantagesStandards and usage still solidifying Standards and usage still solidifying

Performance impactPerformance impact

Page 28: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Depend on bindingDepend on bindingwsHttpbinding for example is using Windows wsHttpbinding for example is using Windows Kerberos token as a default token.Kerberos token as a default token.

You can set the token type (next slides)You can set the token type (next slides)

You can set encryption and digital signatures You can set encryption and digital signatures orderorder

Message Security technologyMessage Security technology

Page 29: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Message SecurityMessage Security<endpoint address=<endpoint address=““http://localhost/chttp://localhost/calculator"alculator"

binding=binding=““wsHttpwsHttpBindingBinding““

bindingConfiguration=bindingConfiguration=““Binding1Binding1””

contract="ICalculator" />contract="ICalculator" />

<<wsHttpwsHttpBinding>Binding>

<binding Name="Binding1"><binding Name="Binding1">

<security mode="Message"><security mode="Message">

<message clientCredentialType=<message clientCredentialType=““Windows"/>Windows"/>

</security></security>

</binding></binding>

</</wsHttpwsHttpBinding>Binding>

Page 30: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Mixed Mode

Compromise between Transport and Compromise between Transport and Message SecurityMessage Security

Transport layer satisfies integrity and Transport layer satisfies integrity and confidentiality requirements confidentiality requirements

Performance benefitsPerformance benefits

Message layer carries claimsMessage layer carries claimsRich credentials, extensibilityRich credentials, extensibility

Page 31: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Mixed Mode SecurityMixed Mode Security<endpoint address=<endpoint address=““https://localhost/chttps://localhost/calculator"alculator"

binding=binding=““wsHttpwsHttpBindingBinding““

bindingConfiguration=bindingConfiguration=““Binding1Binding1””

contract="ICalculator" />contract="ICalculator" />

<<wsHttpwsHttpBinding>Binding>

<binding Name="Binding1"><binding Name="Binding1">

<security mode="TransportWithMessageCredential"><security mode="TransportWithMessageCredential">

<message clientCredentialType=<message clientCredentialType=““Windows"/>Windows"/>

</security></security>

</binding></binding>

</</wsHttpwsHttpBinding>Binding>

Page 32: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Credential typesCredential types

You can use different credentials types:You can use different credentials types:WindowsWindows

Username PasswordUsername Password

CertificateCertificate

Issued Token (CardSpaceIssued Token (CardSpace……) )

Page 33: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Authentication ModesAuthentication Modes

You can use different authentication You can use different authentication technologies:technologies:

WindowsWindows

Membership provider (ASP.NET)Membership provider (ASP.NET)

Custom Custom

Page 34: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Credentials TypeCredentials Type

<bindings><bindings>

<wsHttpBinding><wsHttpBinding>

<binding name="WSHttpBinding_manuCalc" ><binding name="WSHttpBinding_manuCalc" >

<security mode="Message"><security mode="Message">

<message clientCredentialType="UserName" /><message clientCredentialType="UserName" />

</security></security>

</binding></binding>

</wsHttpBinding></wsHttpBinding>

</bindings></bindings>

Page 35: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Authentication ModeAuthentication Mode<behaviors><behaviors>

<serviceBehaviors><serviceBehaviors><behavior name="MyBehavior"><behavior name="MyBehavior">

<serviceAuthorization<serviceAuthorizationprincipalPermissionMode="UseAspNetRoles"/>principalPermissionMode="UseAspNetRoles"/>

<serviceCredentials><serviceCredentials><userNameAuthentication<userNameAuthentication

userNamePasswordValidationMode="MembershipProvider"userNamePasswordValidationMode="MembershipProvider" />/>

<serviceCertificate storeLocation="LocalMachine"<serviceCertificate storeLocation="LocalMachine"storeName="My"storeName="My"findValue="CN=WSE2QuickStartServer"findValue="CN=WSE2QuickStartServer"

x509FindType="FindBySubjectDistinguishedName" x509FindType="FindBySubjectDistinguishedName" /> /> </serviceCredentials></serviceCredentials>

</behavior></behavior></serviceBehaviors></serviceBehaviors>

</behaviors></behaviors>

Page 36: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Service Certificate

Service Certificate must be set to enable server authentication and the safe transfer of client credentials.The automatic proxy created in the client will include (in the config file) a reference to this certificate so the client will be able to encrypt its credentials using the public key.

Page 37: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

Username/PasswordUsername/PasswordConsole.WriteLine(Console.WriteLine(““Enter username[domainEnter username[domain\\\\user]:");user]:");

string username = Console.ReadLine();string username = Console.ReadLine();

Console.WriteLine(Console.WriteLine(““Enter password:");Enter password:");

string password = Console.ReadLine();string password = Console.ReadLine();

CalculatorProxy proxy = new CalculatorProxyCalculatorProxy proxy = new CalculatorProxy();();

pproxy.roxy.CredentialsCredentials.UserName.UserName.UserName = .UserName = usernameusername;;

pproxy.roxy.CredentialsCredentials.UserName.UserName.Password = .Password = password;password;

//When using channel factory//When using channel factoryChannelFactory<ICalc> chf = new ChannelFactory<ICalc>(binding,ReChannelFactory<ICalc> chf = new ChannelFactory<ICalc>(binding,RemoteAdd);moteAdd);

proxproxyy = chf.CreateChannel();= chf.CreateChannel();

pproxy.ChannelFactory.roxy.ChannelFactory.CredentialsCredentials.UserName.UserName.UserName = .UserName = usernameusername;;

pproxy.ChannelFactory.roxy.ChannelFactory.CredentialsCredentials.UserName.UserName.Password = .Password = password;password;

Page 38: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group

wsHttpBindingwsHttpBinding

1. Windows Authentication1. Windows Authentication

2. Authentication using ASP.NET membership provider2. Authentication using ASP.NET membership provider

3. ClientCredentialType="Certificate"3. ClientCredentialType="Certificate"

Page 39: Windows Communication Foundation - OWASP Communication Foundation Manu Cohen-Yashar CTO Applisec Sela Group