javasecurecodingfeb2011
javasecurecodingfeb2011
• Runtime Security
• Behavior enforced by the Java
Runtime
• Enables applications to be run Applications
safely in a restricted environment
• Security Libraries Security Tools
Security
Libraries
• Standard APIs for Crypto, PKI, Runtime
Security
Authentication, Policy & Secure
Communication
• Pluggable implementations
• Security Tools
• keytool, jarsigner, policytool
2011 Oracle Corporation – Proprietary and Confidential 5
Java SE Security Components
Security Manager
CertPath
JAAS Java SASL
Digital Signature
CRLs
Java GSS
JSSE
PKI
Kerberos
Kerberos
XML
JCE
SW Crypto PKCS 11
Certificate Directory
Server Server HW Crypto Smart Card
Accelerator
• Definition
• A weakness in a system allowing an attacker to
violate the integrity, confidentiality, access control,
availability, consistency or audit mechanism of the
system or the data and applications it hosts
• Causes
• Faulty assumptions in the application architecture
• Errors in configuration
• Insecure programming practices (antipatterns)
package java.lang;
public class Class {
private Object[] signers;
public Object[] getSigners() {
return signers;
}
}
package java.lang;
public class Class {
private Object[] signers;
public Object[] getSigners() {
return signers;
}
}
java.util.Properties
extends
java.util.Properties
extends
java.util.Properties
extends
package sun.net.www.protocol.http;
urlConn.setRequestProperty
("Accept",
"*.*\r\n\r\nGET http://victim_host HTTP/1.0\r\n\r\n");
client
host GET http://origin_host HTTP/1.0
Accept: *.*
Web Applet
proxy origin
host
Victim
host GET http://victim_host HTTP/1.0
Intranet Internet
package org.apache.xpath.compiler;
package org.apache.xpath.compiler;
FunctionTable.m_functions = <new_table>;
package java.lang;
protected ClassLoader() {
securityCheck();
init();
initialized = true; // check flag in all relevant
// methods
}
}
2011 Oracle Corporation – Proprietary and Confidential 46
Antipattern 6: Believing a Constructor
Exception Destroys the Object - Guidelines
• For Java SE 6 and later only, exceptions thrown before
super() is invoked do destroy the object
• Use -target 1.6 or higher
• Does not work with Java SE 5.0 or earlier
public class ClassLoader {
protected ClassLoader() {
this(securityCheck());
}
private ClassLoader(Void ignored) { // not accessible
super();
init();
}
// no flag to check
}
package java.math;
• Ongoing updates
• v3.0 for JDK 7 GA
• Integration into Oracle Secure Coding Standards
(SCS)
• Possible OU training course material
Appendix