760 likes | 909 Views
Michael Bond Varun Srivastava Kathryn McKinley Vitaly Shmatikov University of Texas at Austin. Efficient, Context-Sensitive Detection of Real-World Semantic Attacks. Real Semantic Exploits & Efficient, Context-Sensitive Detection. How an applet loads a class.
E N D
Michael Bond VarunSrivastava Kathryn McKinley VitalyShmatikov University of Texas at Austin Efficient, Context-Sensitive Detection of Real-World Semantic Attacks
Real Semantic Exploits & Efficient, Context-Sensitive Detection
How an applet loads a class • classLoader.loadClass(“java.util.HashSet”);
classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); }
Access-control security • classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess()
classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... }
classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“sun/applet/AppletClassLoader”); Sun Java Virtual Machine 1.3
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); }
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess()
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() • Semantic exploit • Examples: • Omitted security check • Untrusted code executes in wrong context • Misconfigured security policy ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() How to detect this exploit? Infeasible path detection? Does not violate semantics (e.g., type & memory safety, control-flow integrity) ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() How to detect this exploit? Check against specification? No specification available ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() How to detect this exploit? Infer specification from dynamic behavior? ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“sun/applet/AppletClassLoader”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 Which dynamic behavior? FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
loadClass(“java.util.HashMap”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“sun/applet/AppletClassLoader”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“MyClass”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :139 File.exists()
loadClass(“java.util.HashMap”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“sun/applet/AppletClassLoader”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“MyClass”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :139 File.exists() Train Deploy
classLoader.loadClass(“MyClass”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); }
classLoader.loadClass(“MyClass”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess()
classLoader.loadClass(“MyClass”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
loadClass(“java.util.HashMap”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“sun/applet/AppletClassLoader”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“MyClass”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :139 File.exists()
loadClass(“java.util.HashMap”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“sun/applet/AppletClassLoader”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“MyClass”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :139 File.exists()
loadClass(“java.util.HashMap”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“sun/applet/AppletClassLoader”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :121 File.exists() loadClass(“MyClass”); … SecurityManager.checkPackageAccess() … … FileURLLoader.getResource():73 walkPathComponents() :139 File.exists() Train Deploy Train
ClassLoader.loadClass():312 ClassLoader.loadClass():341 More context sensitivity FileURLLoader.getResource():73 FileURLLoader.walkPathComponents():121 File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
ClassLoader.loadClass():312 ClassLoader.loadClass():341 More context sensitivity False positives False negatives FileURLLoader.getResource():73 FileURLLoader.walkPathComponents():121 File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
ClassLoader.loadClass():312 ClassLoader.loadClass():341 More context sensitivity False positives Overhead False negatives FileURLLoader.getResource():73 FileURLLoader.walkPathComponents():121 File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } S ←walkStack () check ( S ) SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 S ←walkStack () check ( S ) SecurityManager.checkRead()
Costs of Context Sensitivity Proportional to depth & security calls High overhead at security calls
Efficient, Depth-Limited Context Sensitivity
Probabilistic Calling Context[Bond & McKinley ’07] Represent calling context as probabilistically unique integer
Probabilistic Calling Context[Bond & McKinley ’07] Compute value at every call Use value at security calls
Probabilistic Calling Context[Bond & McKinley ’07] Compute value at every call Use value at security calls Always-available context Low overhead at security calls
classLoader.loadClass(“java.util.HashSet”); loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); V0←0 loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } V1←f ( V0, cs1 ) SecurityManager.checkPackageAccess() ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); V0←0 loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } V1←f ( V0, cs1 ) SecurityManager.checkPackageAccess() V2←f ( V0, cs2) ClassLoader.loadClass():341 FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } File.exists():268 File.checkRead():1485 SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); V0←0 loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } V1←f ( V0, cs1 ) SecurityManager.checkPackageAccess() V2←f ( V0, cs2) V3←f ( V2, cs3) ClassLoader.loadClass():341 V4←f ( V3 , cs4) FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } V5←f ( V4 , cs5) File.exists():268 V6←f ( V5 , cs6) File.checkRead():1485 V7←f ( V6 , cs7 ) SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); V0←0 loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } V1←f ( V0, cs1 ) check ( V1 ) SecurityManager.checkPackageAccess() V2←f ( V0, cs2) V3←f ( V2, cs3) ClassLoader.loadClass():341 V4←f ( V3 , cs4) FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } V5←f ( V4 , cs5) File.exists():268 V6←f ( V5 , cs6) File.checkRead():1485 V7←f ( V6 , cs7 ) check ( V7 ) SecurityManager.checkRead()
classLoader.loadClass(“java.util.HashSet”); V0←0 loadClass(name) { ... if (name.lastIndexOf(‘.’) != -1) securityManager.checkPackageAccess(name); ... super.loadClass(); } V1←f ( V0, cs1 ) check ( V1 ) SecurityManager.checkPackageAccess() V2←f ( V0, cs2) • History • sensitivity V3←f ( V2, cs3) ClassLoader.loadClass():341 V4←f ( V3 , cs4) FileURLLoader.getResource():73 walkPathComponents() { ... 121: { ... if (file.exists()) ... } ... 139: { ... if (file.exists()) ... } ... } V5←f ( V4 , cs5) File.exists():268 V6←f ( V5 , cs6) File.checkRead():1485 V7←f ( V6 , cs7 ) check ( V7 ) SecurityManager.checkRead()
PCC Function f ( V , cs ) ≡ 3V +cs(mod 232)
PCC Function f ( V , cs ) ≡ 3V +cs(mod 232) Motivated by MPI data-type hashing [Langou et al. ’05] [Gropp ’00]
PCC Function f ( V , cs ) ≡ 3V +cs(mod 232) Encodes entire calling context
PCC Function f ( V , cs ) ≡ 232/kV +cs(mod 232) Encodes last k call sites
PCC Function f ( V , cs ) ≡ 232/kV +cs(mod 232) • Cheap to compute
PCC Function f ( V , cs ) ≡ 232/kV +cs(mod 232) • Cheap to compute • Composition cheap to compute
PCC Function f ( V , cs ) ≡ 232/kV +cs(mod 232) • Cheap to compute • Composition cheap to compute • Non-commutative