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.
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:
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
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:
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.
blog comments powered by Disqus