290 likes | 304 Views
INFOSYS 290, Section 3 Web Services: Concepts, Design and Implementation. Web Services Security. Adam Blum ablum@good.com. Agenda. Security Issues with Web Services WS-Security XML Signature XML Encryption Tool Support. Security Issues Addressed by WS-Security. Identity Authentication
E N D
INFOSYS 290, Section 3Web Services: Concepts, Design and Implementation Web Services Security Adam Blum ablum@good.com
Agenda • Security Issues with Web Services • WS-Security • XML Signature • XML Encryption • Tool Support
Security Issues Addressed by WS-Security • Identity • Authentication • Authorization • Integrity • Confidentiality
Terms • Proof-of-possession – data to demonstrate knowledge by sender that should only be known by claimed sender • Integrity – process to guarantee no modification in transit • Confidentiality - process by which data is protected such that only authorized actors can view data • Digest - cryptographic checksum of content • Signature - binding of proof of possession and digest
Message with Token <?xml version="1.0" encoding="utf-8"?> <S:Envelope xmlns:S="http://www.w3.org/2001/12/soap-envelope" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <S:Header> <wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ ws/2002/04/secext"> <wsse:UsernameToken Id="MyID"> <wsse:Username>Zoe</wsse:Username> </wsse:UsernameToken>
…a Digital Signature <ds:Signature> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm= "http://www.w3.org/2001/10/xml-exc-c14n#"/> <ds:SignatureMethod Algorithm= "http://www.w3.org/2000/09/xmldsig#hmac-sha1"/> <ds:Reference URI="#MsgBody"> <ds:DigestMethod Algorithm= "http://www.w3.org/2000/09/xmldsig#sha1"/> <ds:DigestValue>LyLsF0Pi4wPU...</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue>DJbchm5gK...</ds:SignatureValue> <ds:KeyInfo> <wsse:SecurityTokenReference> <wsse:Reference URI="#MyID"/> </wsse:SecurityTokenReference> </ds:KeyInfo> </ds:Signature> </wsse:Security> </S:Header>
…and a Body • <S:Body Id="MsgBody"> • <tru:StockSymbol xmlns:tru="http://fabrikam123.com/payloads"> QQQ • </tru:StockSymbol> • </S:Body> </S:Envelope>
Message Security Model • Security tokens - assert claims • Signatures • Provide mechanism for proving sender’s knowledge of key • Associate signature with claims in the security token • Endorsed Claims • Represented as security tokens signed by a trusted authority • X.509 certificate claims a binding between one’s identity and a public key • Unendorsed claims • Can be trusted if there is trust relationship between sender and receiver • Proof of possession claim – e.g. username/password
Username Token Example <S:Envelope xmlns:S="http://www.w3.org/2001/12/soap-envelope" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext"> <S:Header> ... <wsse:Security> <wsse:UsernameToken> <wsse:Username>ablum</wsse:Username> <wsse:Password>lauren</wsse:Password> </wsse:UsernameToken> </wsse:Security> ... </S:Header> ... </S:Envelope>
Security Tokens • Binary Security Tokens <wsse:BinarySecurityToken xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext" Id="myToken" ValueType="wsse:Kerberosv5ST" EncodingType="wsse:Base64Binary"> MIIEZzCCA9CgAwIBAgIQEmtJZc0... </wsse:BinarySecurityToken> - or X509 (note that there is thus no guarantee of interoperability) • Security Token References <SecurityTokenReference Id="..."> <Reference URI="..."/> </SecurityTokenReference>
Signatures • determine whether a message was altered in transit • Verify that message was sent by possessor of particular security token
XML Signature <Signature ID?> <SignedInfo> <CanonicalizationMethod/> <SignatureMethod/> (<Reference URI? > (<Transforms>)? <DigestMethod> <DigestValue> </Reference>)+ </SignedInfo> <SignatureValue> (<KeyInfo>)? (<Object ID?>)* </Signature>
CanonicalizationMethod A way to guarantee that two equivalent bits of XML are represented the same so that they can be signed Algorithms used for this • Identifier for REQUIRED Canonical XML (omits comments): • http://www.w3.org/TR/2001/REC-xml-c14n-20010315 • Identifier for Canonical XML with Comments: • http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments An example of an XML canonicalization element is: • <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
SignatureMethod • Algorithm used to create digital signature • Required • Secure Hash Algorithm-1 with Digital Signature Algorithm
Reference Element • Digest algorithm • Digest value • Optional identifier of object being signed • Optional transforms applied prior to digesting • With SOAP • Signed parts of SOAP message • Base64-encoded • SHA1 algorithm
Elements Outside SignedInfo • SignatureValue • Base64 encoded bytes making up digital signature • KeyInfo • Indicates what key should be used to validate signature • Can be embedded, referenced or left out entirely
Signature Example <Signature Id="MyFirstSignature" xmlns="http://www.w3.org/2000/09/xmldsig#"> [s02] <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/> <Reference URI="http://www.w3.org/TR/2000/REC-xhtml1-20000126/"> <Transforms> <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> [s10] <DigestValue>j6lwx3rvEPO0vKtMup4NbeVu8nk=</DigestValue> </Reference> </SignedInfo> <SignatureValue>MC0CFFrVLtRlk=...</SignatureValue> <KeyInfo> <KeyValue> <DSAKeyValue> [s15c] <P>...</P><Q>...</Q><G>...</G><Y>...</Y> </DSAKeyValue> </KeyValue> </KeyInfo> </Signature>
Encryption Components • xenc:ReferenceList • Manifest of encrypted elements in message • xenc:EncryptedData • Contains encrypted elements
Encryption Example (Shared Secret) <S:Envelope xmlns:S="http://www.w3.org/2001/12/soap-envelope" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> <S:Header> <wsse:Security> <xenc:ReferenceList> <xenc:DataReference URI="#bodyID"/> </xenc:ReferenceList> </wsse:Security> </S:Header> <S:Body> <xenc:EncryptedData Id="bodyID"> <ds:KeyInfo> <ds:KeyName>CN=Hiroshi Maruyama, C=JP</ds:KeyName> </ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue>...</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </S:Body> </S:Envelope>
Encrypting Keys • Encrypt elements with key • Encrypt key with recipient’s key • Embed in header • E.g. encrypting with randomly generated symmetric key that is encrypted with recipients public key
Encrypting with Encrypted Key <S:Header> <wsse:Security> <xenc:EncryptedKey> <xenc:EncryptionMethod Algorithm="..."/> <ds:KeyInfo> <ds:KeyName>CN=Hiroshi Maruyama, C=JP</ds:KeyName></ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue>...</xenc:CipherValue> </xenc:CipherData> <xenc:ReferenceList> <xenc:DataReference URI="#bodyID"/> </xenc:ReferenceList> </xenc:EncryptedKey> /wsse:Security> </S:Header> <S:Body> <xenc:EncryptedData Id="bodyID"> <ds:KeyInfo> <ds:KeyName>CN=Hiroshi Maruyama, C=JP</ds:KeyName> </ds:KeyInfo> <xenc:CipherData> <xenc:CipherValue>...</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </S:Body> </S:Envelope>
WS-Security Specs • WS-Security • http://www-128.ibm.com/developerworks/webservices/library/ws-secure/ • XML Signature • http://www.w3.org/TR/xmldsig-core/
Microsoft WSE 3.0 • Turnkey Security Scenarios • Username over Transport • Username over Certificate • Anonymous over Certificate • Mutual Certificate • Kerberos (Windows)
WSE 3.0 Named Policies • [WebService(Namespace = "http://stockservice.contoso.com/wse/samples/2005/10")] [Policy("ServerPolicy")] • public class WSSecurityUsernameService : System.Web.Services.WebService { • public WSSecurityUsernameService() { } • [WebMethod] public List<StockQuote> StockQuoteRequest([XmlArray(), XmlArrayItem("Symbol"] string[] symbols) { • // Business logic here • } }