
Educational analysis and proof-of-concept exploit for CVE-2022-22965, a Spring MVC/WebFlux remote code execution vulnerability via data binding on JDK 9+ with Tomcat WAR deployment.
हाल ही में Spring में एक बड़ा CVE भेद्यता सामने आया है। CVE जानकारी के अनुसार, "JDK 9+ पर चलने वाला Spring MVC या Spring WebFlux एप्लिकेशन डेटा बाइंडिंग के माध्यम से रिमोट कोड एक्ज़ीक्यूशन (RCE) के लिए संवेदनशील हो सकता है। विशिष्ट एक्सप्लॉइट के लिए एप्लिकेशन को Tomcat पर WAR डिप्लॉयमेंट के रूप में चलाना आवश्यक है। यदि एप्लिकेशन Spring Boot एक्ज़ीक्यूटेबल जार के रूप में डिप्लॉय किया गया है, अर्थात डिफ़ॉल्ट, तो यह एक्सप्लॉइट के लिए संवेदनशील नहीं है। हालांकि, भेद्यता की प्रकृति अधिक सामान्य है, और इसका शोषण करने के अन्य तरीके भी हो सकते हैं।" इस विश्लेषण का उद्देश्य इस CVE को पुन: प्रस्तुत करके भेद्यता के सिद्धांत को सीखना है।
स्प्रिंगएमवीसी के पैरामीटर बाइंडिंग सिद्धांत को देखने से पहले, आइए पहले जावा बीन से संबंधित कुछ API को देखें।
निम्नलिखित java bean क्लास घोषित करें:```java public class User { private String name;
public User() {
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public int getAge() {
return 18;
}
}
निम्नलिखित परीक्षण कोड के साथ देखें कि Introspector.getBeanInfo द्वारा प्राप्त जानकारी क्या है:```java
@Test
public void testIntrospector() throws IntrospectionException {
BeanInfo beanInfo = Introspector.getBeanInfo(User.class);
for (PropertyDescriptor pdesc:beanInfo.getPropertyDescriptors()){
System.out.println("Property: " + pdesc.getName() + ",Class:" + pdesc.getPropertyType());
}
// for (MethodDescriptor md:beanInfo.getMethodDescriptors()) {
// System.out.println("Method: " + md.getName());
// }
}
आउटपुट:```text Property: age,Class:int Property: class,Class:class java.lang.Class Property: name,Class:class java.lang.String
पूर्वानुमानित age और उसके अलावा, एक class गुण भी है, जिसका नाम Class है। यदि आगे Introspector.getBeanInfo(Class.class) को कॉल किया जाए तो classLoader जैसी अधिक जानकारी प्राप्त की जा सकती है:```text jdk11:
Property: annotatedInterfaces
Property: annotatedSuperclass
Property: annotation
Property: annotations
Property: anonymousClass
Property: array
Property: canonicalName
Property: class
Property: classLoader
Property: classes
Property: componentType
Property: constructors
Property: declaredAnnotations
Property: declaredClasses
Property: declaredConstructors
Property: declaredFields
Property: declaredMethods
Property: declaringClass
Property: enclosingClass
Property: enclosingConstructor
Property: enclosingMethod
Property: enum
Property: enumConstants
Property: fields
Property: genericInterfaces
Property: genericSuperclass
Property: interface
Property: interfaces
Property: localClass
Property: memberClass
Property: methods
Property: modifiers
Property: module
Property: name
Property: nestHost
Property: nestMembers
Property: package
Property: packageName
Property: primitive
Property: protectionDomain
Property: signers
Property: simpleName
Property: superclass
Property: synthetic
Property: typeName
Property: typeParameters
इसके अलावा, विभिन्न JDK संस्करणों के अंतर्गत Introspector.getBeanInfo(Class.class) द्वारा प्राप्त जानकारी के अंतर की तुलना करें, ऊपर वाला jdk-11 का आउटपुट है, नीचे वाला JDK8 का आउटपुट है:```text jdk8: Property: annotatedInterfaces Property: annotatedSuperclass Property: annotation Property: annotations Property: anonymousClass Property: array Property: canonicalName Property: class Property: classLoader Property: classes Property: componentType Property: constructors Property: declaredAnnotations Property: declaredClasses Property: declaredConstructors Property: declaredFields Property: declaredMethods Property: declaringClass Property: enclosingClass Property: enclosingConstructor Property: enclosingMethod Property: enum Property: enumConstants Property: fields Property: genericInterfaces Property: genericSuperclass Property: interface Property: interfaces Property: localClass Property: memberClass Property: methods Property: modifiers Property: name Property: package Property: primitive Property: protectionDomain Property: signers Property: simpleName Property: superclass Property: synthetic Property: typeName Property: typeParameters
[No input content provided to translate.]```text
Property: annotatedInterfaces
Property: annotatedSuperclass
Property: annotation
Property: annotations
Property: anonymousClass
Property: array
Property: canonicalName
Property: class
Property: classLoader
Property: classes
Property: componentType
Property: constructors
Property: declaredAnnotations
Property: declaredClasses
Property: declaredConstructors
Property: declaredFields
Property: declaredMethods
Property: declaringClass
Property: enclosingClass
Property: enclosingConstructor
Property: enclosingMethod
Property: enum
Property: enumConstants
Property: fields
Property: genericInterfaces
Property: genericSuperclass
Property: interface
Property: interfaces
Property: localClass
Property: memberClass
Property: methods
Property: modifiers
Property: module
Property: name
Property: package
Property: packageName
Property: primitive
Property: protectionDomain
Property: signers
Property: simpleName
Property: superclass
Property: synthetic
Property: typeName
Property: typeParameters
jdk9 में JDK8 की तुलना में दो अतिरिक्त विशेषताएँ हैं: module और packageName, जबकि JDK11 में module और packageName के अलावा दो और विशेषताएँ हैं: nestHost और nestMembers।