Skip to content

Commit 751bbbf

Browse files
committed
Java: add remote user input for Struts 2 ActionSupport
1 parent a436369 commit 751bbbf

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

java/ql/src/semmle/code/java/dataflow/FlowSources.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import semmle.code.java.frameworks.JaxWS
1818
import semmle.code.java.frameworks.android.Intent
1919
import semmle.code.java.frameworks.SpringWeb
2020
import semmle.code.java.frameworks.Guice
21+
import semmle.code.java.frameworks.struts.StrutsActions
2122

2223
/** Class for `tainted` user input. */
2324
abstract class UserInput extends DataFlow::Node { }
@@ -75,6 +76,8 @@ class RemoteUserInput extends UserInput {
7576
a = this.asParameter().getAnAnnotation() or
7677
a = this.asExpr().(FieldRead).getField().getAnAnnotation()
7778
)
79+
or
80+
exists(Struts2ActionSupportClass c | c.getASetterMethod().getField() = this.asExpr().(FieldRead).getField())
7881
}
7982

8083
/**

java/ql/src/semmle/code/java/frameworks/struts/StrutsActions.qll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,24 @@ class Struts2PrepareMethod extends Method {
124124
exists(Struts2ActionClass actionClass | this = actionClass.getPrepareMethod())
125125
}
126126
}
127+
128+
/**
129+
* A subclass of the Struts 2 `ActionSupport` class.
130+
*/
131+
class Struts2ActionSupportClass extends Class {
132+
Struts2ActionSupportClass() {
133+
this.getASupertype+().hasQualifiedName("com.opensymphony.xwork2", "ActionSupport")
134+
}
135+
136+
/**
137+
* Gets a setter method declared on a subclass of `ActionSupport`.
138+
*/
139+
SetterMethod getASetterMethod() {
140+
result.getDeclaringType() = this and
141+
result.isPublic() and
142+
exists(string name | result.getField().getName().toLowerCase() = name |
143+
result.getName().toLowerCase().substring(3, result.getName().length()) = name and
144+
result.getName().matches("set%")
145+
)
146+
}
147+
}

0 commit comments

Comments
 (0)