
Analisi didattica e proof-of-concept exploit per CVE-2022-22965, una vulnerabilità di esecuzione remota di codice in Spring MVC/WebFlux tramite data binding su JDK 9+ con distribuzione WAR su Tomcat.
Recentemente, Spring ha rilasciato una vulnerabilità CVE di alto livello. Le informazioni sulla CVE indicano: "Un'applicazione Spring MVC o Spring WebFlux in esecuzione su JDK 9+ può essere vulnerabile a esecuzione di codice remoto (RCE) tramite data binding. Lo sfruttamento specifico richiede che l'applicazione venga eseguita su Tomcat come distribuzione WAR. Se l'applicazione viene distribuita come eseguibile JAR di Spring Boot, cioè il default, non è vulnerabile allo sfruttamento. Tuttavia, la natura della vulnerabilità è più generale e potrebbero esserci altri modi per sfruttarla." Questa analisi apprende il principio della vulnerabilità riproducendo la CVE.
Prima di esaminare il principio di binding dei parametri di Spring MVC, diamo un'occhiata ad alcune API relative ai Java Bean.
get/is<XXXX>() o set<XXXX>(<PropertyType>).Dichiarazione di una classe Java Bean come segue:```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;
}
}
Usa il seguente codice di test per vedere le informazioni ottenute da 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());
// }
}
[No content provided to translate.]```text Property: age,Class:int Property: class,Class:class java.lang.Class Property: name,Class:class java.lang.String
Oltre a 'age' e quello previsti, c'è anche un attributo 'class', il nome della classe è Class, e se si continua a chiamare Introspector.getBeanInfo(Class.class) si possono ottenere ulteriori informazioni come classLoader, ecc.:```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
Inoltre, confrontiamo le differenze delle informazioni ottenute da Introspector.getBeanInfo(Class.class) in diverse versioni di JDK: sopra c'è l'output di jdk-11, sotto quello di 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
" wait, the user's message shows:
INPUT:
It appears there is only a newline and then a carriage return (
). That might be empty content. The rules say translate only natural language text, and preserve all markdown. If the input is empty, then output should be empty as well.
But let me double-check the user's message. After "INPUT:" there is a line with just a backtick? Actually the formatting is:
INPUT:
That is a backtick block. Inside: a blank line, then a carriage return character. So likely the chunk is empty or just a newline. Since we must preserve structure exactly, we output exactly the same: a blank line and then a newline? But the instruction says "Return ONLY the translated text. No preamble...". So I will output exactly the same as input: a blank line and then the carriage return? However in textual response, a carriage return is not typical. The input includes a literal carriage return character (
). In plain text, we can preserve that as is? But that might cause issues. Better to output exactly the same characters. Since the input is empty line followed by carriage return, the output should be the same.