Security
  Home arrow Security arrow Page 20 - Safeguarding the Identity and Integrit...
FaxWave - Free Trial.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
SECURITY

Safeguarding the Identity and Integrity of XML Messages
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2004-09-09

    Table of Contents:
  • Safeguarding the Identity and Integrity of XML Messages
  • XML Signature Fundamentals
  • XML Signature Structure
  • Types of XML Signatures
  • The Signature Element Schema
  • XML Signature Processing
  • XML Signature Validation
  • The XML Signature Elements
  • Canonicalization Actions from Canonical XML Version 1.0
  • The SignatureMethod Element
  • The Reference Element
  • The Transform Element
  • XPath Filtering Transform
  • Enveloped Signature Transform
  • XPath Filter 2.0 Transform
  • The DigestMethod Element
  • The Object Element
  • The Manifest Element
  • The KeyInfo Element
  • Security Strategies for XML Signature
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Safeguarding the Identity and Integrity of XML Messages - Security Strategies for XML Signature
    (Page 20 of 21 )

    XML Signature, just like any security strategy, is effective only if it is used correctly within the context and constraints of the situation. It is effective in certain areas but can be inappropriate in others. The following sections describe some security considerations when you are using XML Signatures.

    Using Transforms

    Perhaps the scariest aspect of XML Signatures, at least when you come from a traditional digital signature perspective, is the concept that you can change (transform) the information being signed in a hidden way (by an algorithmic process) before it is digitally signed. This capability seems to go against the assumptions about fundamental integrity on which digital signatures are based. However, as we discussed earlier when talking about Transforms, there are completely legitimate reasons for using a Transform algorithm, such as when you need to Base-64 encode a binary object or remove a signature when creating/validating an Enveloped Signature. The XML Signature working group was concerned enough about the security issues around Transforms to call out three specific principles to consider when using Transforms in XML Signatures.

    Only What Is Signed Is Secure

    The principle "only what is signed is secure" seems obvious, but the point is that when a Transform is involved, you must be extra diligent to understand what the Transform does and to understand that the discarded information is not digitally signed. For example, in a Web services scenario, if an XML Signature has signed the XML payload, only the XML payload is secured, not the SOAP envelope information.

    Only What Is Seen Should Be Signed

    If a user's judgment or consent is being conveyed by the signature, every practical effort should be made to sign what a user has seen. For example, if a contract being signed (showing intent) has been rendered to the signer as XML with an XSL stylesheet, both the XML and the XSL stylesheet should be signed. In general, implementers should adhere to the principle of What You See Is What You Sign (WYSIWYS).

    "See" What Is Signed

    The idea behind the principle "see what is signed" is that you should make sure you are working with (seeing) what was actually signed. Making presumptions about the signature is risky. You should run the actual Reference URI and Transforms and work with the output to be sure. For example, you may know that a signature is supposed to contain a certain field, such as an amount. If Transforms are involved (and they always are when you consider canonicalization of the SignedInfo element), you cannot be positive that that field's integrity has been validated unless you run the Reference URI/Transform algorithms and then access the field's contents from the result.

    Knowing the Security Model

    In the context of our discussion, the term security model means the set of assumptions and constraints associated with a particular security or cryptographic strategy. For example, XML Signature supports both public key signatures and keyed hashed authentication codes (such as HMAC).

    We discussed the security model around public key signatures in Chapter 3. The main point here to remember is that public key signatures are associated with identity and integrity.

    Keyed hashed authentication codes, such as HMAC, are shared key based. They tend to run much faster than public key signatures, but they are primarily associated with integrity, not identity.

    XML Signatures can and will be extended over time to include other types of algorithms and techniques. If you choose one of these approaches, it is critical that you understand the underlying security model well.

    Knowing Your Keys

    Key management is a fundamental issue of cryptography whether it is public key or shared key oriented. It is critical (and challenging) that you protect the private keys that are used for signing and confirm that the keys you are using for validation are valid, not revoked, and represent the identity that you expect them to represent.

    Signing Object Elements

    XML Signature processing does not automatically sign Object elements within a Signature element. If you want an element signed, you must create a Reference and point specifically to the Object element. This point is obvious when you are creating an Enveloping Signature, but it may seem less obvious when you are adding a SignatureProperties or Manifest element. Most of the time, you will want these elements signed. For example, if you add a "Time of Signature" property to a SignedProperties element, you usually want to add a Reference to it; otherwise, why would you provide this information to the verifier and potentially have it tampered with?

    Signing DTDs with Entity References

    One of the key capabilities of DTDs is keeping entity references that are resolved for you at XML parse time. For example, say you have a DTD that contains the following entity references:

    <!ENTITY companyname "CompanyA">
    <!ENTITY companylocation "Chicago, IL">

    Then you receive a signed XML document representing an order commitment for $1,000,000 that was signed by Company A like Listing 4.29.

    Listing 4.29 An <OrderCommittment> Document Signed by Company A

    <?xml version="1.0"?>
    <!DOCTYPE ordercommittment SYSTEM "ordercommittment.dtd">
    <OrderCommittment>
      <CompanyName>&companyname;</CompanyName>
      <CompanyLocation>&companylocation;</CompanyLocation>
      <CommittedItem type="cash" denom="USD">$1,000,000</CommittedItem>
      <CommittedDate>ASAP</CommittedDate>
      <Signature>
        <SignedInfo>
          <CanonicalizationMethod ... />
          <SignatureMethod ... />
          <Reference URI="">
            <Transforms>
             <Transform
              Algorithm="http://www.w3.org/2000/09/
              xmldsig#enveloped-signature"/>
            </Transforms>
          <DigestMethod ... />
          <DigestValue>...</DigestValue>
         </Reference>
      </SignedInfo>
        <SignatureValue>...</SignatureValue>
      </Signature>
    </OrderCommittment>

    Notice that the signature is an Enveloped Signature that signs everything under the OrderCommittment element. Because the Reference URI is "", the entire document includes the <?xml and <!DOCTYPE lines; however, the DTD itself has not been signed. Notice that the DTD has a relative address. So, imagine that an attacker—say, from Company B—substituted a different DTD file into the same directory as the XML containing the following entity references:

    <!ENTITY companyname "CompanyB">
    <!ENTITY companylocation "Pendleton, NJ">

    In this case, the signature is validated even though different values appear in the CompanyName and CompanyLocation elements of the XML document! And Company B will receive the $1,000,000 because of it. The point is: Signing DTDs is very important when entity references are being used.

    Entity references are not a problem with XML Schemas because schemas do not have the same entity reference capability; however, a similar problem can occur with default values. It is a good idea to include a Reference to the XML Schema for the same reasons you would sign DTDs.


    SOAP Security Extensions: An Initial Stab at Web Services Security - In February 2001, Microsoft and IBM submitted a W3C Note regarding the use digital signatures in SOAP messages (see http://www.w3.org/TR/SOAP-dsig/). This precursor to WS-Security defines a standard way to put an XML Signature into the header of a SOAP message. For example, a signed SOAP message would look like Listing 4.30 using this method.

    Listing 4.30 Early Use of Digital Signatures in SOAP

    <SOAP-ENV:Envelope
     xmlns:SOAP-ENV="...">
     <SOAP-ENV:Header>
      <SOAP-SEC:Signature xmlns:SOAP-SEC="..."
       SOAP-ENV:actor="some-URI"
       SOAP-ENV:mustUnderstand="1">
       <ds:Signature xmlns:ds="...">
        <ds:SignedInfo>
         <ds:CanonicalizationMethod
          Algorithm="...">
         </ds:CanonicalizationMethod>
         <ds:SignatureMethod Algorithm="..."/>
         <ds:Reference URI="#Body">
          <ds:Transforms>
           <ds:Transform Algorithm="..."/>
          </ds:Transforms>
          <ds:DigestMethod Algorithm="..."/>
            <ds:DigestValue>...=</ds:DigestValue>
         </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>...</ds:SignatureValue>
       </ds:Signature>
      </SOAP-SEC:Signature>
     </SOAP-ENV:Header>
     <SOAP-ENV:Body
      xmlns:SOAP-SEC="..." SOAP-SEC:id="Body">
      <m:GetLastTradePrice xmlns:m="some-URI">
       <m:symbol>IBM</m:symbol>
      </m:GetLastTradePrice>
     </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    You will not see this standard in much use today; it never went past the W3C Note stage. However, it is used in some situations, and it had a significant influence on the later WS-Security standard.


    SamsThis chapter is from Securing Web Services Security with WS-Security, by Jothy Rosenberg and David Remy (Sams, 2004, ISBN: 0672326515). Check it out at your favorite bookstore today.

    Buy this book now.

    More Security Articles
    More By Sams Publishing


     

       

    SECURITY ARTICLES

    - An Epilogue to Cryptography
    - A Sequel to Cryptography
    - An Introduction to Cryptography
    - Security Overview
    - Network Security Assessment
    - Firewalls
    - What’s behind the curtain? Part II
    - What’s behind the curtain? Part I
    - Vectors
    - PKI: Looking at the Risks
    - A Quick Look at Cross Site Scripting
    - PKI Architectures: How to Choose One
    - Trust, Access Control, and Rights for Web Se...
    - Basic Concepts of Web Services Security
    - Safeguarding the Identity and Integrity of X...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway