Skip to content

Commit 15a43ff

Browse files
Simplified returnsRemoteInvocationSerializingExporter()
1 parent e02b51f commit 15a43ff

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

java/ql/src/experimental/Security/CWE/CWE-502/SpringHttpInvokerUnsafeDeserialization.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ private predicate isRemoteInvocationSerializingExporter(RefType type) {
3030
* Holds if `method` returns an object that extends `RemoteInvocationSerializingExporter`.
3131
*/
3232
private predicate returnsRemoteInvocationSerializingExporter(Method method) {
33-
isRemoteInvocationSerializingExporter(method.getReturnType()) or
3433
isRemoteInvocationSerializingExporter(method.getReturnType().(RefType).getASupertype*())
3534
}
3635

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| SpringHttpInvokerUnsafeDeserialization.java:9:32:9:37 | unsafe | Unasafe deserialization in a remote service exporter in 'unsafe' method |
1+
| SpringHttpInvokerUnsafeDeserialization.java:10:32:10:63 | unsafeHttpInvokerServiceExporter | Unasafe deserialization in a remote service exporter in 'unsafeHttpInvokerServiceExporter' method |
2+
| SpringHttpInvokerUnsafeDeserialization.java:18:41:18:88 | unsafeCustomeRemoteInvocationSerializingExporter | Unasafe deserialization in a remote service exporter in 'unsafeCustomeRemoteInvocationSerializingExporter' method |

java/ql/test/experimental/query-tests/security/CWE-502/SpringHttpInvokerUnsafeDeserialization.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
import org.springframework.context.annotation.Bean;
22
import org.springframework.context.annotation.Configuration;
33
import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
4+
import org.springframework.remoting.rmi.RemoteInvocationSerializingExporter;
45

56
@Configuration
67
public class SpringHttpInvokerUnsafeDeserialization {
78

8-
@Bean(name = "/unsafe")
9-
HttpInvokerServiceExporter unsafe() {
9+
@Bean(name = "/unsafeHttpInvokerServiceExporter")
10+
HttpInvokerServiceExporter unsafeHttpInvokerServiceExporter() {
1011
HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
1112
exporter.setService(new AccountServiceImpl());
1213
exporter.setServiceInterface(AccountService.class);
1314
return exporter;
1415
}
1516

17+
@Bean(name = "/unsafeCustomeRemoteInvocationSerializingExporter")
18+
RemoteInvocationSerializingExporter unsafeCustomeRemoteInvocationSerializingExporter() {
19+
return new CustomeRemoteInvocationSerializingExporter();
20+
}
21+
1622
HttpInvokerServiceExporter notABean() {
1723
HttpInvokerServiceExporter exporter = new HttpInvokerServiceExporter();
1824
exporter.setService(new AccountServiceImpl());
@@ -21,6 +27,8 @@ HttpInvokerServiceExporter notABean() {
2127
}
2228
}
2329

30+
class CustomeRemoteInvocationSerializingExporter extends RemoteInvocationSerializingExporter {}
31+
2432
class NotAConfiguration {
2533

2634
@Bean(name = "/notAnEndpoint")
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
package org.springframework.remoting.rmi;
22

3-
public abstract class RemoteInvocationSerializingExporter {
4-
5-
}
3+
public abstract class RemoteInvocationSerializingExporter {}

0 commit comments

Comments
 (0)