Title: Web Services Security
1Web Services Security
- XML Encryption, XML Signature and
- WS-Security
2Why WS-Security?
- Standard signature and encryption techniques can
be used to sign and encrypt an XML document. - But these techniques are generally tied to
transmission (e.g., SSL) and dont protect the
document once it arrives. - But document needs to be sent as a whole, and
different parts might have different security
requirements. - Transmission system cant be expected to respect
these differences - Merchant needs to know customers name and
address, but not credit card number.
3Complexity of the Problem
- An XML document might contain data describing an
entire interaction however each portion should
only be viewed by a particular audience - Personal details of a medical record should not
be available to a researcher, doctor should be
able to see medical details but not credit card
data, some medical details should not be
available to administrator. - Different parts of document might have to be
signed by different participants - The subsets might intersect, so multiple
encryption might be required for certain portions - Should tags be encrypted?
- If yes, searching with XPath might be inhibited
and security might be compromised (since the
plaintext associated with encrypted data can be
guessed)
4WS-Security
- A standard set of SOAP extensions that can be
used to implement a variety of security models
and encryption techniques. - Not itself a protocol
- Supports
- Security token (passwords, keys, certificates)
transmission - Message integrity
- Message encryption
- Makes use of other standards XML Signature, XML
Encryption
5XML Encryption
ltpayment xmlnsgt ltnamegt John Doe lt/namegt
ltcreditCard typevisa limit5000 \gt
ltnumbergt 1234 5678 9012 3456 lt/numbergt
ltissuergt Bank of XY lt/issuergt
ltexpirationgt 04/09 lt/expi55rationgt
lt/creditCardgt lt/paymentgt
6XML Encryption
- Example encrypt the credit card element
(including tags) - Encrypted element replaces element
encrypting an element
ltpayment xmlnsgt ltnamegt John Doe lt/namegt
ltEncryptedData Typehttp//www.w3.org/2001/04/x
mlencElement
xmlnsXML encryption namespacegt
ltEncryptionMethod Algorithm /gt
ltKeyInfo xmlnsgt ltKeyNamegt keyABC
lt/KeyNamegt lt/KeyInfogt
ltCipherDatagt ltCipherValuegt
AB12VY54321X .. lt/CipherValuegt
lt/CipherDatagt lt/EncryptedDatagt lt/paymentgt
encryption algorithm
identify key to receiver
encrypted data
7XML Encryption
- Type granularity of encryption
- An entire document, or an element (with or
without tags) can be encrypted. - Different parts can be encrypted with different
keys - Algorithm algorithm used to encrypt data
- Example DES, RSA
- KeyName key is known to receiver just identify
it - CipherData octet stream
- The standard provides a number of options that
can be used to accommodate a variety of needs
8XML Encryption Some Alternatives
- Symmetrically encrypt data, assume the receiver
knows the key and include key name (previous
example) - Symmetrically encrypt data, include encrypted key
in message (encrypted with public key of
receiver) (next example)
9XML Encryption and SOAP
- Store encryption key in header, encrypted data is
body, an element w/i body, or an attachment - The result of the encryption must be a valid SOAP
envelope - Cant encrypt ltsEnvelopegt, ltsHeadergt or
ltsBodygt elements only their descendants
10XML Encryption (2)
WS-Security used to attach XML Encryption
Encrypted key is stored in header
wsse prefix for WS-Security xenc prefix for
XML Encryption ds prefix for KeyInfo element
ltsHeadergt ltwsseSecuritygt
ltxencEncryptedKey gt
ltxencEncryptionMethod
Algorithmpub. key algo. to encrypt symmetric
key/gt ltdsKeyInfogt ltdsKeyNamegt
Bill lt/dsKeyNamegt lt/dsKeyInfogt
ltxencCipherDatagt
ltxencCipherValuegtabcd456lt/xencCipherValuegt
lt/xencCipherDatagt
ltxencReferenceListgt
ltxencDataReference URIEncrData /gt
lt/xencReferenceListgt lt/xencEncryptedKey
gt lt/wsseSecuritygt lt/sHeadergt
Bills publ. key encrypts sym. key
optional, receiver may know it
encrypted symmetric key
list of data items encrypted with symmetric key
11XML Encryption (2)
Encrypted data is stored in body
identifies data
ltsBodygt ltxencEncryptedData IdEncrData
Typehttp//www.w3.org/2001/04
/xmlencElement /gt ltxencEncryptionMethod
Algorithmsymmetric algo. to
encrypt data /gt ltxencCipherDatagt
ltxencCipherValuegtA341BBlt/xencCipherValue
gt lt/xencCipherDatagt
lt/xencEncryptedDatagt lt/sBodygt
data encrypted with symmetric key
12XML Signature
- An entire document or individual elements can be
signed. Allows for the fact that - Different individuals might be responsible for
different parts of the message - Some parts of the message should not be changed,
others are changeable - The signature is computed in two stages
- A digest, using dig_fn1 , is computed of the data
and encapsulated in a ltSignedInfogt element - A digest, using dig_fn2 , is computed of the
ltSignedInfogt element and signed using the private
key of the sender
13XML Signature
ltSignature xmlns XML Signature namespacegt
ltSignedInfogt ltCanonicalizationMethod
Algorithm /gt ltSignatureMethod
Algorithmhash/public key encryption /gt
ltReference URIlocate item to be signed
/gt ltDigestMethod Algorithm hash
algorithm for item/gt
ltDigestValuegtxyT14Rstlt/DigestValuegt
lt/Referencegt lt/SignedInfogt
ltSignatureValuegtxYzu2fR.lt/SignatureValuegt lt/Signa
turegt
digest of data
signature of entire ltSignedInfogt element
14Canonicalization Method
- Problem blank spaces, tabs, line delimiters etc.
do not affect the semantics of an XML element,
but two different semantically identical elements
will have different digests and hence different
signatures - Solution put element into a canonical form
before digesting it
15Transforms
16Two-Stage Signature Computation
- Signature is over ltSignedInfogt element (not over
the data directly) - Change to data produces change to its
ltDigestValuegt which produces change to signature
of ltSignedInfogt - Double digesting does not effect integrity of
signature - Technique used to do the signing (but not the
signature itself) is signed. - Defends against an attack in which intruder
attempts to substitute weaker signature algorithm
17KeyInfo Element
- Problem Suppose the public key corresponding to
the private key used to sign ltSignedInfogt is not
known to the receiver.
ltSignedInfogt ltCanonicalizationMethod
Algorithm /gt ltSignatureMethod
Algorithmhash/public key encryption /gt
.. other children lt/SignedInfogt ltSignatureV
aluegt . lt/SignatureValuegt ltKeyInfogt .
lt/KeyInfogt
produced by algorithm using a private key
identifies the private key - a name
- a certificate - a corresponding public key
18KeyInfo Element
- Problem Since ltKeyInfogt is not contained in
ltSignedInfogt it is not bound by signature to
ltSignedInfogt - Intruder might substitute a different ltKeyInfogt
element - Solution use multiple ltReferencegt elements
19Multiple Reference Elements
ltsEnvelopegt ltsHeadergt
ltwsseSecuritygt ltdsSignaturegt
ltdsSignedInfogt .
ltdsReference URImessgt
lt/dsReferencegt ltdsReference
URIKgt lt/dsReferencegt
lt/dsSignedInfogt
ltdsSignatureValuegt lt/dsSignatureValuegt
ltdsKeyInfo IdKgt lt/dsKeyInfogt
lt/dsSignaturegt lt/wsseSecuritygt
lt/sHeadergt ltsBody Idmessgt
. lt/sBodygt lt/sEnvelopegt
part of WS-Security
both Body and KeyInfo are signed
each Reference element contains digest of item
referred to
20WS-Security
- Defines Security header block as a mechanism for
attaching security-related information to a SOAP
message and organizing it in a standard way. - Uses the concept of a security token
- Asserts a claim by the sender of security-related
information - username, PW, Kerberos ticket, key
- Provides a mechanism for referring to security
related information that is not in message - Tokens are children of Security header block
- Leverages XML Encryption and XML Signature
21Security Tokens
- Username token element
- Binary security token an element that carries
binary security information
ltUsernameToken Idgt ltUsernamegt .
lt/Usernamegt ltPasswordgt . lt/Passwordgt lt/Userna
meTokengt
ltBinarySecurityToken ValueType.
-- type of token (e.g., certificate, ticket)
EncodingType. gt -- encoding format
NmgT446C7. -- token lt/BinarySecurutyToke
ngt
22Security Tokens
- Security token reference a mechanism for
referencing tokens not contained in the message - ltKeyInfogt (part of XML Signature) provides an
alternate (more general) mechanism for
transmitting information of this type. It can be
inserted as a child of Security header block
ltSecurityTokenReference Id gt ltReference
URI /gt lt/SecurityTokenReferencegt
23Example
WS-Security
ltsHeadergt ltwsseSecuritygt
ltwsseBinarySecurityToken
ValueTypecertificate IdX509Tokengt
xDee45TsYU. lt/wsseBinarySecurityTokengt
ltdsSignaturegt
ltdsSignedInfogt
ltdsCanonicalizationMethod /gt
ltdsSignatureMethod ../gt
ltdsReference URIBgt
-- body is signed
ltdsDigestMethod ./gt ltdsDigestValue
./gt lt/dsReferencegt
lt/dsSignedInfogt ltdsSignatureValuegt
afdSkK lt/dsSignatureValuegt --
signature ltdsKeyInfogt
ltwsseSecurityTokenReferencegt ltwsseReference
URIX509Token/gt
lt/wsseSecurityTokenReferencegt
lt/dsKeyInfogt
lt/dsSignaturegt lt/wsseSecuritygt lt/sHeadergt lt
sBody IdBgt .body. lt/sBodygt
XML Signature
token
information about key used in the signature is
found here
24Security Token
- Signature An XML Signature element can be a
child of a Security header block - There can be multiple signatures referencing
different (perhaps overlapping) components of the
message - Example
- Client signs orderId header block and body of
message and sends to order processing dept - Order processing dept adds a shippingId header
block and signs it and the orderId header block
and sends to billing
25Encryption in WS-Security
- WS-Security uses XML Encryption in a standard way
to encrypt portions of a message
ReferenceList used as a stand-alone header block
lists encrypted items
ltsHeadergt ltwsseSecuritygt
ltxencReferenceListgt
ltxencDataReference URIbodyId /gt
lt/xencReferenceListgt ltwsseSecuritygt lt/sHead
ergt ltsBodygt ltxencEncryptedData IdbodyId
gt ltdsKeyInfogt ltdsKeyNamegt
xyz lt/dsKeyNamegt lt/dsKeyInfogt
ltxencCipherDatagt ltxencCipherValuegt
lt/xencCipherValuegt lt/xencCipherDatagt
lt/xencEncryptedDatagt lt/sBodygt
each EncryptedData element in ReferenceList provid
es its own key info
xyz is the name associated with the symmetric key
used to encrypt data