SlideShare a Scribd company logo
WCF security: patterns & practices

         ante.gulam[at]ri-ing.net
Overview
•   Intro [Service-Oriented Architecture, MS WCF]
•   Defining Web Service Threats
•   Overview of WCF Security Basics
•   Configuration - Starting Point and Ending Point
•   Bindings In Depth
•   Securing Transport Channel - Integrity and Auth.
•   Messages - What I Send is What You Get?
•   Few Code-Based WCF Security Best Practices
•   Outro [conclusion]
Intro
• SOA in general (discovery, description, messaging)
   –   UDDI  XML Hierarchy
   –   UDDI Discovery (automated scanning tools)
   –   WSDL and XSD Descriptions
   –   SOAP vs. REST XML Protocols
• SOA Security Issues (ASMX, WCF, Java ...)
• WCF (Indigo/2006)- .NET Web Service Technology
• Endpoints (Transport & Bindings)
   – ABC (Address/Binding/Contract)
   – HTTP, TCP, named pipes, MSMQ ...
   – MEX – Metadata Exchange
Defining Web Service Threats
• Attractive target
        • Open to the World (rare filtering access scheme)
        • Direct connection to core application
        • Direct connection to core data
• Discovering and Attacking Web Services
        • WS-discovery (service behaviorConfiguration="serviceDiscoverable”) probe:
          3702
    – WSScanner
        • Footprinting, Discovery, Enumeration, Scanning and Fuzzing tool
• WCF Test Harness – flexible tool for quick service tests
• Common WApp vulns: SQL injection, session theft, XML DoS ...
• XML/SOAP Manipulation (abusing the protocol)
    – Eavesdropping Message Exchange
    – Message Protection Methods
• Configuration Data Injection (tampering .conf)
• Local/UDDI XML Processing attack
Overview of WCF Security Basics
• Logging and Auditing
      • Debbuging and Attack Detection
• Authentication
      • Identify Clients
               » Users, Services, Processes, Machines ...
               » MiTM Attack Mitigation
      • Transport Security Mode (cert, NTLM, basic ...)
      • Message Security Mode (cert, token, username ...)
• Authorization
      • Role-based
      • Identity-based
      • Resource-based
• Confidentiality
      • Encryption of Traffic client  WCF service
• Integrity
Configuration - Starting Point and
               Ending Point
• Web.config start-up
        • Web-config encryption
        • section.SectionInformation.ProtectSection
• <system.ServiceModel>
        • Services
                » Defining Service Endpoints
        • Bindings
                » Basic, WS, WSDual, NetTcp ... ...
        • Behaviors
                » <throttling> and other custom behaviors
• <Credentials /> Stored in Config
      <credentials passwordFormat="Clear">
        <user name="user1" password="pass1"/>
      </credentials>
• Max Message Size ???? (avoid 2147483647)
• Encrypting configuration files (CL tools, code-based...)
Bindings in Depth
• System.ServiceModel.Channels.Binding class
• Binding types and Security Modes
  – WSHttpBinding b = new WSHttpBinding();
    b.Security.Mode = SecurityMode.?????:
     • Transport Security
     • Mixed-Mode Security
     • Message Security
• Considering Scenarios for the right Bindings
     •   Clients accessing through the Internet (wshttp)
     •   Legacy clients (http)
     •   Intranet (netTCP)
     •   Local Machine Clients (netNamedPipeBinding)
     •   Disconnected queued calls support (netMsmqBinding)
     •   bidirectional communication support (wsDualHttp)
• System-Provided bindings

   – BasicHttpBinding: An HTTP protocol binding suitable for
     connecting to Web services that conforms to the WS-I
     Basic Profile specification (for example, ASP.NET Web
     services-based services)
   – WSHttpBinding: An interoperable binding suitable for
     connecting to endpoints that conform to the WS-*
     protocols.
   – NetNamedPipeBinding: Uses the .NET Framework to
     connect to other WCF endpoints on the same machine.
   – NetMsmqBinding: Uses the .NET Framework to create
     queued message connections with other WCF endpoints.

• Custom Bindings
   – Meet Requirements of Your Service
Securing Transport Channel
• SSL tunneling on WS transport channel
• Choosing secure binding or SSL transport??
  – More and more on security (end-to-end, part encrypt)
  – Performances on Message/Transport level
  – Combining Message and Transport security
• Custom Binding and Custom Validator
     • public override void Validate(string uname, string pass)
     • <bindingname="CustomBinding“>
       <securityauthenticationMode="UserNameOverTransport“>
       </security>
Messages - What I Send is What You Get?

• Message integrity check
      • Ability to detect and manage invalid data
      • Imposition of complete transactions
      • Rollbacks
• [Service Behavior] attrib: Transaction Isolation -
  Serializable transaction
   – protection for consistent data
• Hash calculation on message: xml/json messages
  (HMAC, SHA1..)
• ETag (base64 encoding of the md5sum)
• Distributed Transaction Controller
   – Single Transaction building
      • ‘Global’ Rollback (whole call chain rollback)
          – transactionFlow="true"
Few Code-Based WCF Security Best Practices

• using() and try/finally keywords in WCF ?
• Why to Avoid Them???
  – IL almost identical
  – So, where is the problem!?!?
• During Disposal the Channel is NEVER closed!
• Control the catch of Exceptions
• Use a global exception handler to catch
  unhandled exceptions
• FaultContract
     • FaultContract(typeof(CustomException))]
        – throw new FaultException<MathFault>(mf);
• using()                            • try/finally block
• IL_0000: newobj instance void      •     IL_0012: ldnull
  [System.Windows.Forms]System.             IL_0013: stloc.1
  Windows.Forms.Form::.ctor()               .try
     IL_0005: stloc.0                       {
     .try                                      IL_0014: newobj instance
     {                                   void
        IL_0006: leave.s IL_0012         [System.Windows.Forms]System.Win
     } // end .try                       dows.Forms.Form::.ctor()
     finally                                   IL_0019: stloc.1
     {                                         IL_001a: leave.s IL_0026
        IL_0008: ldloc.0                    } // end .try
        IL_0009: brfalse.s IL_0011          finally
        IL_000b: ldloc.0                    {
        IL_000c: callvirt instance             IL_001c: ldloc.1
  void                                         IL_001d: brfalse.s IL_0025
  [mscorlib]System.IDisposable::Di             IL_001f: ldloc.1
  spose()                                      IL_0020: callvirt instance void
        IL_0011: endfinally              [System]System.ComponentModel.C
     } // end handler                    omponent::Dispose()
                                               IL_0025: endfinally
                                            } // end handler
• CAS in WCF services
  – [assembly: AllowPartiallyTrustedCallers]
  – [PermissionSet(SecurityAction.Assert,Name =
    "FullTrust")]
  – Calling out from the Restricted client Environment
     • Security breach – bypass direct connection
  – PartialTrustClientBase<T> ??
  – GAC on the client side?
     • Proxy Assembly Installation
  – Raw WCF Demands
• ChannelFactory class
  – Used in advanced scenarios
  – Creation of Multiple Channels for Communication
     • ChannelFactory<xx> myChannelFactory = new
       ChannelFactory<xx>(myBinding, myEndpoint);
       xx wcfClient1 = myChannelFactory.CreateChannel();
  – channelFactory.Credentials (username/password)
  – Avoid Creation of ChannelFactory on each page
    call (overhead)
• Make a port scanner out of WCF
  – WSDualHttpBinding
  – “CreateSequence” SOAP request
  – “ReplyTo” address




• https://github.com/GDSSecurity/WCF-WSDualHttpBinding-Port-Scanner
Outro [conclusion]
• What have we remembered to make our WS more secure?
   – Best practice – combine technologies and techniques to get
     security on higher level!!!
       • Combine Smart Coding with Good Configuration
• Test your WCF’s on various attack techniques
• ServiceThrottlingBehavior class
   – MaxConcurrentCalls (default = 16) [Per-message]
   – MaxConcurrentInstances (default = Int32.Max)
       • InstanceContextMode  ServiceBehaviorAttribute  PerCalls /
         Sessions
   – MaxConcurrentSessions (default = 10) [Per-channel]
• Stay in touch with Recent Security Discoveries Related to
  Technologies you are using!
       • Platforms, OS services, dev technologies, transport/protocol
         technologies, encryption algorithms etc.
thank you for your attention
    questions and comments

More Related Content

PDF
DEF CON 27 - ALVARO MUNOZ / OLEKSANDR MIROSH - sso wars the token menace
PDF
Talk about html5 security
PDF
Атаки на платформу Java Card с использованием вредоносных апплетов
PDF
Hernan Ochoa - WCE Internals [RootedCON 2011]
PPTX
Cryptography In Silverlight
PPTX
#3 (Multi Threads With TCP)
PDF
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
PPTX
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...
DEF CON 27 - ALVARO MUNOZ / OLEKSANDR MIROSH - sso wars the token menace
Talk about html5 security
Атаки на платформу Java Card с использованием вредоносных апплетов
Hernan Ochoa - WCE Internals [RootedCON 2011]
Cryptography In Silverlight
#3 (Multi Threads With TCP)
AllTheTalks.Online 2020: "Basics of OAuth 2.0 and OpenID Connect"
Современные технологии и инструменты анализа вредоносного ПО_PHDays_2017_Pisk...

What's hot (13)

PDF
Breaking .net through serialization
PDF
Security in Node.JS and Express:
PPTX
Architecting Secure and Compliant Applications with MongoDB
PPTX
XML Security
PPTX
OAuth 2.0 at the Globiots
PPTX
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
PPTX
Webinar: Securing your data - Mitigating the risks with MongoDB
PDF
Building Client-Side Attacks with HTML5 Features
TXT
Birhanu distributive assignment
PDF
ChromeからMacBookのTouchIDでWebAuthenticationする ~Idance vol1~
 
PDF
Docker and Fargate
PDF
Web前端性能优化 2014
PDF
Webinar slides: How to Secure MongoDB with ClusterControl
Breaking .net through serialization
Security in Node.JS and Express:
Architecting Secure and Compliant Applications with MongoDB
XML Security
OAuth 2.0 at the Globiots
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
Webinar: Securing your data - Mitigating the risks with MongoDB
Building Client-Side Attacks with HTML5 Features
Birhanu distributive assignment
ChromeからMacBookのTouchIDでWebAuthenticationする ~Idance vol1~
 
Docker and Fargate
Web前端性能优化 2014
Webinar slides: How to Secure MongoDB with ClusterControl
Ad

Viewers also liked (20)

PDF
Windows Communication Foundation (WCF)
PPTX
Windows Communication Foundation (WCF)
PPTX
WCF security
PDF
ITCamp 2012 - Mihai Nadas - Tackling the single sign-on challenge
PPT
Paypal-IPN
PPTX
How to Launch a Web Security Service in an Hour
PDF
Pyscho-Strategies for Social Engineering
PPTX
Cusomizing Burp Suite - Getting the Most out of Burp Extensions
PDF
Burp suite
PPTX
Advanced WCF
PPS
Wcf Transaction Handling
PPTX
Windows Azure Versioning Strategies
PPTX
Wcf for the web developer
PPTX
Wcf security session 1
PPT
Web Service Security
PPTX
Burp plugin development for java n00bs (44 con)
PPT
Basics of WCF and its Security
PPTX
Pentesting With Web Services in 2012
PPTX
Burpsuite yara
PDF
Pentesting RESTful webservices
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
WCF security
ITCamp 2012 - Mihai Nadas - Tackling the single sign-on challenge
Paypal-IPN
How to Launch a Web Security Service in an Hour
Pyscho-Strategies for Social Engineering
Cusomizing Burp Suite - Getting the Most out of Burp Extensions
Burp suite
Advanced WCF
Wcf Transaction Handling
Windows Azure Versioning Strategies
Wcf for the web developer
Wcf security session 1
Web Service Security
Burp plugin development for java n00bs (44 con)
Basics of WCF and its Security
Pentesting With Web Services in 2012
Burpsuite yara
Pentesting RESTful webservices
Ad

Similar to WCF Security, FSec (20)

PPTX
PDF
Wcf Overview
PPTX
Lunch Learn - WCF Security
PPT
PPT
Windows Communication Foundation
DOC
WCF tutorial
PPT
PPT
Dot Net Training Wcf Dot Net35
PPTX
Net framework key components - By Senthil Chinnakonda
PPTX
10 Tricks and Tips for WCF
PDF
Wcf difference faqs-1
PDF
Wcf development
PPT
DotNet_WindowsCommunicationFoundation.ppt
PDF
WCF Interview Questions By Scholarhat PDF
PPTX
Windows communication foundation ii
PPT
Session 1 Shanon Richards-Exposing Data Using WCF
PPTX
1. WCF Services - Exam 70-487
PDF
Secure .NET programming
PPTX
WCF Fundamentals
Wcf Overview
Lunch Learn - WCF Security
Windows Communication Foundation
WCF tutorial
Dot Net Training Wcf Dot Net35
Net framework key components - By Senthil Chinnakonda
10 Tricks and Tips for WCF
Wcf difference faqs-1
Wcf development
DotNet_WindowsCommunicationFoundation.ppt
WCF Interview Questions By Scholarhat PDF
Windows communication foundation ii
Session 1 Shanon Richards-Exposing Data Using WCF
1. WCF Services - Exam 70-487
Secure .NET programming
WCF Fundamentals

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation theory and applications.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KodekX | Application Modernization Development
NewMind AI Monthly Chronicles - July 2025
Encapsulation theory and applications.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Digital-Transformation-Roadmap-for-Companies.pptx

WCF Security, FSec

  • 1. WCF security: patterns & practices ante.gulam[at]ri-ing.net
  • 2. Overview • Intro [Service-Oriented Architecture, MS WCF] • Defining Web Service Threats • Overview of WCF Security Basics • Configuration - Starting Point and Ending Point • Bindings In Depth • Securing Transport Channel - Integrity and Auth. • Messages - What I Send is What You Get? • Few Code-Based WCF Security Best Practices • Outro [conclusion]
  • 3. Intro • SOA in general (discovery, description, messaging) – UDDI  XML Hierarchy – UDDI Discovery (automated scanning tools) – WSDL and XSD Descriptions – SOAP vs. REST XML Protocols • SOA Security Issues (ASMX, WCF, Java ...) • WCF (Indigo/2006)- .NET Web Service Technology • Endpoints (Transport & Bindings) – ABC (Address/Binding/Contract) – HTTP, TCP, named pipes, MSMQ ... – MEX – Metadata Exchange
  • 4. Defining Web Service Threats • Attractive target • Open to the World (rare filtering access scheme) • Direct connection to core application • Direct connection to core data • Discovering and Attacking Web Services • WS-discovery (service behaviorConfiguration="serviceDiscoverable”) probe: 3702 – WSScanner • Footprinting, Discovery, Enumeration, Scanning and Fuzzing tool • WCF Test Harness – flexible tool for quick service tests • Common WApp vulns: SQL injection, session theft, XML DoS ... • XML/SOAP Manipulation (abusing the protocol) – Eavesdropping Message Exchange – Message Protection Methods • Configuration Data Injection (tampering .conf) • Local/UDDI XML Processing attack
  • 5. Overview of WCF Security Basics • Logging and Auditing • Debbuging and Attack Detection • Authentication • Identify Clients » Users, Services, Processes, Machines ... » MiTM Attack Mitigation • Transport Security Mode (cert, NTLM, basic ...) • Message Security Mode (cert, token, username ...) • Authorization • Role-based • Identity-based • Resource-based • Confidentiality • Encryption of Traffic client  WCF service • Integrity
  • 6. Configuration - Starting Point and Ending Point • Web.config start-up • Web-config encryption • section.SectionInformation.ProtectSection • <system.ServiceModel> • Services » Defining Service Endpoints • Bindings » Basic, WS, WSDual, NetTcp ... ... • Behaviors » <throttling> and other custom behaviors • <Credentials /> Stored in Config <credentials passwordFormat="Clear"> <user name="user1" password="pass1"/> </credentials> • Max Message Size ???? (avoid 2147483647) • Encrypting configuration files (CL tools, code-based...)
  • 7. Bindings in Depth • System.ServiceModel.Channels.Binding class • Binding types and Security Modes – WSHttpBinding b = new WSHttpBinding(); b.Security.Mode = SecurityMode.?????: • Transport Security • Mixed-Mode Security • Message Security • Considering Scenarios for the right Bindings • Clients accessing through the Internet (wshttp) • Legacy clients (http) • Intranet (netTCP) • Local Machine Clients (netNamedPipeBinding) • Disconnected queued calls support (netMsmqBinding) • bidirectional communication support (wsDualHttp)
  • 8. • System-Provided bindings – BasicHttpBinding: An HTTP protocol binding suitable for connecting to Web services that conforms to the WS-I Basic Profile specification (for example, ASP.NET Web services-based services) – WSHttpBinding: An interoperable binding suitable for connecting to endpoints that conform to the WS-* protocols. – NetNamedPipeBinding: Uses the .NET Framework to connect to other WCF endpoints on the same machine. – NetMsmqBinding: Uses the .NET Framework to create queued message connections with other WCF endpoints. • Custom Bindings – Meet Requirements of Your Service
  • 9. Securing Transport Channel • SSL tunneling on WS transport channel • Choosing secure binding or SSL transport?? – More and more on security (end-to-end, part encrypt) – Performances on Message/Transport level – Combining Message and Transport security • Custom Binding and Custom Validator • public override void Validate(string uname, string pass) • <bindingname="CustomBinding“> <securityauthenticationMode="UserNameOverTransport“> </security>
  • 10. Messages - What I Send is What You Get? • Message integrity check • Ability to detect and manage invalid data • Imposition of complete transactions • Rollbacks • [Service Behavior] attrib: Transaction Isolation - Serializable transaction – protection for consistent data • Hash calculation on message: xml/json messages (HMAC, SHA1..) • ETag (base64 encoding of the md5sum) • Distributed Transaction Controller – Single Transaction building • ‘Global’ Rollback (whole call chain rollback) – transactionFlow="true"
  • 11. Few Code-Based WCF Security Best Practices • using() and try/finally keywords in WCF ? • Why to Avoid Them??? – IL almost identical – So, where is the problem!?!? • During Disposal the Channel is NEVER closed! • Control the catch of Exceptions • Use a global exception handler to catch unhandled exceptions • FaultContract • FaultContract(typeof(CustomException))] – throw new FaultException<MathFault>(mf);
  • 12. • using() • try/finally block • IL_0000: newobj instance void • IL_0012: ldnull [System.Windows.Forms]System. IL_0013: stloc.1 Windows.Forms.Form::.ctor() .try IL_0005: stloc.0 { .try IL_0014: newobj instance { void IL_0006: leave.s IL_0012 [System.Windows.Forms]System.Win } // end .try dows.Forms.Form::.ctor() finally IL_0019: stloc.1 { IL_001a: leave.s IL_0026 IL_0008: ldloc.0 } // end .try IL_0009: brfalse.s IL_0011 finally IL_000b: ldloc.0 { IL_000c: callvirt instance IL_001c: ldloc.1 void IL_001d: brfalse.s IL_0025 [mscorlib]System.IDisposable::Di IL_001f: ldloc.1 spose() IL_0020: callvirt instance void IL_0011: endfinally [System]System.ComponentModel.C } // end handler omponent::Dispose() IL_0025: endfinally } // end handler
  • 13. • CAS in WCF services – [assembly: AllowPartiallyTrustedCallers] – [PermissionSet(SecurityAction.Assert,Name = "FullTrust")] – Calling out from the Restricted client Environment • Security breach – bypass direct connection – PartialTrustClientBase<T> ?? – GAC on the client side? • Proxy Assembly Installation – Raw WCF Demands
  • 14. • ChannelFactory class – Used in advanced scenarios – Creation of Multiple Channels for Communication • ChannelFactory<xx> myChannelFactory = new ChannelFactory<xx>(myBinding, myEndpoint); xx wcfClient1 = myChannelFactory.CreateChannel(); – channelFactory.Credentials (username/password) – Avoid Creation of ChannelFactory on each page call (overhead)
  • 15. • Make a port scanner out of WCF – WSDualHttpBinding – “CreateSequence” SOAP request – “ReplyTo” address • https://github.com/GDSSecurity/WCF-WSDualHttpBinding-Port-Scanner
  • 16. Outro [conclusion] • What have we remembered to make our WS more secure? – Best practice – combine technologies and techniques to get security on higher level!!! • Combine Smart Coding with Good Configuration • Test your WCF’s on various attack techniques • ServiceThrottlingBehavior class – MaxConcurrentCalls (default = 16) [Per-message] – MaxConcurrentInstances (default = Int32.Max) • InstanceContextMode  ServiceBehaviorAttribute  PerCalls / Sessions – MaxConcurrentSessions (default = 10) [Per-channel] • Stay in touch with Recent Security Discoveries Related to Technologies you are using! • Platforms, OS services, dev technologies, transport/protocol technologies, encryption algorithms etc.
  • 17. thank you for your attention questions and comments