New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] support add constraint on typeVariable while perform virtual dispatch in java query #7486
Comments
|
It sounds like you are observing data flow starting from |
|
@adityasharad Yes |
|
This issue is stale because it has been open 14 days with no activity. Comment or remove the |
|
Can reproduce with test case import java.io.ObjectInputStream;
import java.io.Serializable;
public class Test2<E> {
public static String source() { return "tainted"; }
public static void sink(Object o) { }
public void test(ObjectInputStream in) {
try {
String tainted = source();
E data = (E) in.readObject();
data.equals(tainted);
}
catch(Throwable t) {}
}
}/**
* @kind path-problem
*/
import java
import semmle.code.java.dataflow.DataFlow
import DataFlow::PathGraph
class TestConfig extends DataFlow::Configuration {
TestConfig() { this = "TestConfig" }
override predicate isSource(DataFlow::Node n) {
n.asExpr() = any(MethodAccess ma | ma.getMethod().getName() = "source")
}
override predicate isSink(DataFlow::Node n) {
n.asExpr() = any(MethodAccess ma | ma.getMethod().getName() = "sink").getAnArgument()
}
}
from TestConfig c, DataFlow::PathNode src, DataFlow::PathNode sink
where c.hasFlowPath(src, sink)
select src, src, sink, "message" |
|
@KiruaLawliet the cause is that Possible workarounds: if you were to constrain the type variable |


Is it possible to add class type constraint on TypeVariable while perform virtual dispatch in java query?
Take this sinppet for example:
It seems
datacan be any class and have data flow tracked intoequalsmethod as long as the class has one even if the class is unserializable.The text was updated successfully, but these errors were encountered: