github / github/codeql

LGTM.com - Java - Lost type information leads to incomplete path and false positive

Đang mở
#2,332 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
false-positive Java
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**Description of the false-positive**

It looks like the query language is connecting sources and sinks through a type checking system that is interpreting methods like `Object::toString` when called on `Object` when at runtime that type will be `String` to be the same as `MyCustomType::toString`.

**URL to the alert on the project page on LGTM.com**
https://lgtm.com/projects/g/spring-projects/spring-framework/snapshot/a21fcec7555409e8859aba85fb2fe95d53760f80/files/spring-web/src/main/java/org/springframework/web/context/support/HttpRequestHandlerServlet.java?sort=name&dir=ASC&mode=heatmap#xe877feaabe7d1240:1

**Analysis**

QL Correctly identifies a source of user-supplied data and correctly tracks it to a place where it is used in the `toString` method.

![part1](https://user-images.githubusercontent.com/1323708/68895831-258ee800-06f8-11ea-9d92-a62439e7004b.png)

Now we have some arbitrary location in the codebase where `toString` is called on `Object`.
![part1a](https://user-images.githubusercontent.com/1323708/68895934-5f5fee80-06f8-11ea-9322-79a86a6ed883.png)

Now we see where those code paths allow this `toString` value to be returned up the stack.

![part2](https://user-images.githubusercontent.com/1323708/68896014-8dddc980-06f8-11ea-8e27-ff90071a49fc.png)

Now we get to the sink location. However, we see that `StringUtils.arrayToDelimitedString` is being passed a `String[]` not a `ServletWebRequest` that would mean this was indeed a vulnerability.

![part3](https://user-images.githubusercontent.com/1323708/68896062-aa7a0180-06f8-11ea-85a1-d35c82ed48a7.png)

TL;DR: Looks like a type confusion issue? Or perhaps there's no logic for detecting the true type that `toString` will be called on.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.