Digital signature is a cryptographic mechanism that provides three security services; data origin authentication, data integrity and non repudiation . Verification of a digital signature using a public key, gives the verifier proof, that the signature was created by someone in possession of the corresponding private key. Also if a particular user is the only one known to be associated with that private key, then it can be proved that the data has originated from that user and has not changed since.
Digital signatures, on their own, provide no notion of when in the past the message was signed. Continuing with the earlier posts on Vulnerabilities in Web Applications due to improper use of Crypto, let us see what might happen if assumptions are made about what security services digital signatures provide implicitly.
Let us consider the business case of a fictitious organization, say, Contoso. Contoso sells two different categories of products, furniture and soaps. It also has two different web sites to showcase these products (Let us call them product sites). Consumers can visit these product sites, http://www.furniture.contoso.com and http://www.soap.contoso.com, browse the products and view their prices. When they want to purchase any product, they are then redirected to another web site, also hosted by Contoso. This web site, https://www.order.contoso.com is Contoso’s payment and order processing web site (Let us call this payment site). The product identifier and the price, of any products selected by the customer are sent from the product site to the payment site as HTTP POST data during redirection. This means that the customer, using a Web proxy tool like Fiddler , can view and modify this HTTP POST request and thereby modify the price at which that product will be sold to that customer.
To counter this threat, the developers decide to digitally sign the HTTP POST data. When the customer decides to buy a list of products, the product data (product identifier, name and price) is created in XML format and then signed using XML Signature  by the product site. This XML Signature is then verified by the payment site. If a user, during redirection, changes the price of a product using a Web proxy tool, the signature will be invalidated and the request will be rejected by the payment site.
Below is a sample of the product data and its signature sent from Contoso’s product site to Contoso’s payment site when a customer decides to buy that product.
3: <productname>Special Soap</productname>
5: <Signature xmlns=“http://www.w3.org/2000/09/xmldsig#”>
7: <CanonicalizationMethod Algorithm=“http://www.w3.org/TR/2001/REC-xml-c14n-20010315” />
8: <SignatureMethod Algorithm=“http://www.w3.org/2000/09/xmldsig#rsa-sha1” />
9: <Reference URI=“”>
11: <Transform Algorithm=“http://www.w3.org/2000/09/xmldsig#enveloped-signature” />
13: <DigestMethod Algorithm=“http://www.w3.org/2000/09/xmldsig#sha1” />
The developers are content that the use of digital signatures in this case is proper and has helped them in countering this threat.
There is although a scenario where this is not quite true! Consider the case, where the price of a product with identifier, say, 1234-4567-2345-34556 is $49.99 today. The customer selects this product. The product data and its signature are then sent as a HTTP POST to the payment site. The customer, using a Web proxy tool, simply captures and stores this request. Later, say after a month, the price of this same product goes up to $79.99. Now, the customer can, during redirection, using the Web proxy tool, replace the current request with the earlier stored request and thereby purchase the product at an earlier price, which is lower than the current price. The payment site will not know the difference, since the signature is still valid.
This is a classic example of a replay attack and can be prevented by introducing a notion of freshness in the request. For example, in this case, a good mitigation may be for the payment site to include a timestamp in the XML request and ensure that the timestamp is also included while calculating the signature. The payment site, after validating the signature can now also verify that the timestamp is sufficiently recent and if not, reject the request.
 Internet Security Glossary, Version 2
 Introducing Fiddler
 .NET Framework Class Library Signature Class
 Understanding XML Digital Signature
Security Engineer, ACE Team