Wiki Markup |
---|
Sensitive data must be protected from eavesdropping and malicious tampering during transit. An Obfuscatedobfuscated Transfertransfer Objectobject \[[Steel 2005|AA. Bibliography#Steel 05]\] that is strongly encrypted can protect data in exchanges that involve multiple business tiers or end user systems. This approach is known as _sealing_ the object. To guarantee object integrity, apply a digital signature to the sealed object. |
...
- Serializing or transporting sensitive data is necessary
- A secure communication channel such as SSL is absent or is too costly for limited transactions
- Some sensitive Sensitive data must persist over an extended period of time (e.g. on an external for example, on a hard drive)
Avoid using home-brewed cryptographic algorithms; such algorithms almost certainly introduce unnecessary vulnerabilities. Applications that apply home-brewed "cryptography" in the readObject()
and writeObject()
methods are prime examples of anti-patterns.
...
Wiki Markup |
---|
The rationale is that any malicious party can intercept the originally signed encrypted message from the originator, strip the signature and add its own signature to the encrypted message. Both the malicious party, and the receiver have no information about the contents of the original message as it is encrypted and then signed (it can only be decrypted after verifying the signature). The receiver has no way of confirming the sender's identity unless the legitimate sender's public key is obtained over a secure channel. One of the three CCITT X.509 standard protocols was susceptible to such an attack \[[CCITT 1988|AA. Bibliography#CCITT 88]\]. |
This rule involves the intential intentional serialization of sensitive information. See SER03-J. Prevent serialization of unencrypted, sensitive data about preventing the unintentional serialization of sensitive information.
Noncompliant Code Example
Code examples are all based upon the following code exampleThe subsequent code examples all involve the following code sample. This code sample posits a map that is serializable, as well as a method to populate the map with interesting values, and a method to check the map for those values.
Code Block |
---|
class SerializableMap<K,V> implements Serializable { final static long serialVersionUID = -2648720192864531932L; private Map<K,V> map; public SerializableMap() { map = new HashMap<K,V>(); } public Object getData(K key) { return map.get(key); } public void setData(K key, V data) { map.put(key, data); } } public class MapSerializer { public static SerializableMap<String, Integer> buildMap() { SerializableMap<String, Integer> map = new SerializableMap<String, Integer>(); map.setData("John Doe", new Integer(123456789)); map.setData("Richard Roe", new Integer(246813579)); return map; } public static void InspectMap(SerializableMap<String, Integer> map) { System.out.println("John Doe's number is " + map.getData("John Doe")); System.out.println("Richard Roe's number is " + map.getData("Richard Roe")); } public static void main(String[] args) { // ... } } |
...
This code sample posits a serializable map, as well as a method to populate the map with interesting values, and a method to check the map for those values.
This noncompliant code example simply serializes the map and then deserializes it. Consequently, the map is capable of being serialized and transferred across different business tiers. Unfortunately, there are no safeguards against byte stream manipulation attacks while the binary data is in transit. Likewise, anyone can reverse engineer the serialized stream data from its hexadecimal notation to reveal the data in the HashMap
.
...
Noncompliant Code Example (Seal)
To provide message confidentiality, use This noncompliant code example uses the javax.crypto.SealedObject
class to provide message confidentiality. This class encapsulates a serialized object and encrypts (or seals) it. A strong cryptographic algorithm that uses a secure cryptographic key and padding scheme must be employed to initialize the Cipher
object parameter. The seal
and unseal
utility methods provide the encryption and decryption facilities respectively.
This noncompliant code example encrypts the map into a SealedObject
, rendering the data inaccessable inaccessible to prying eyes. However, since because the data is not signed, it provides no proof of authentication.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7a4442e53dd0cf80-5d16b0f8-41ea4bd3-8c6a8c78-0f74bf1fd5255b045cee20c6"><ac:plain-text-body><![CDATA[ | [[MITRE 2009 | AA. Bibliography#MITRE 09]] | [CWE ID 319 | http://cwe.mitre.org/data/definitions/319.html] "Cleartext Transmission of Sensitive Information" | ]]></ac:plain-text-body></ac:structured-macro> |
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9e9063d3823ab1f8-f3f85df3-4a384b2b-a2deb3f5-c3f6a05d1e46f1c5ae5604ef"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="52cf5aee8241ddec-2ec17212-4c1f488c-a7e7be63-ffc337765d1e8f5cac2a5d44"><ac:plain-text-body><![CDATA[ | [[Gong 2003 | AA. Bibliography#Gong 03]] | 9.10 Sealing Objects | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5ef44167292ca569-d3596cdb-47084d4e-97bea081-90bd3e493b574c73d7e13568"><ac:plain-text-body><![CDATA[ | [[Harold 1999 | AA. Bibliography#Harold 99]] | Chapter 11: Object Serialization, Sealed Objects | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2ffa1b0ab9f8e68a-a6a80682-4e454ffa-84b48904-1045e02d978f37c6b89cac0c"><ac:plain-text-body><![CDATA[ | [[Neward 2004 | AA. Bibliography#Neward 04]] | Item 64: Use SignedObject to provide integrity of Serialized objects | ]]></ac:plain-text-body></ac:structured-macro> |
| Item 65: Use SealedObject to provide confidentiality of Serializable objects | |||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7ae5665ef32d8b37-e5f44fec-422f42f2-80818f73-7b0d4df12e81c561b7efeb3b"><ac:plain-text-body><![CDATA[ | [[Steel 2005 | AA. Bibliography#Steel 05]] | Chapter 10: Securing the Business Tier, Obfuscated Transfer Object | ]]></ac:plain-text-body></ac:structured-macro> |
...