Skip to content

Conversation

aschackmull
Copy link
Contributor

This cherry-picks the addition of FastJson deserialization sinks from #3674 and adds a check for safe mode sanitization and a change note.

Copy link
Contributor

@aibaars aibaars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some test cases please.

*/
class FastJson extends RefType {
FastJson() {
this.hasQualifiedName("com.alibaba.fastjson", "JSON") or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe JSONObject is a subclass of JSON so there should be no need for the or. There are also several other subclasses of JSON . See: https://github.com/alibaba/fastjson/tree/master/src/main/java/com/alibaba/fastjson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed JSONObject. It never really made sense to include, since the relevant methods are static.

*/
class FastJsonParseMethod extends Method {
FastJsonParseMethod() {
this.getDeclaringType() instanceof FastJson and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.getDeclaringType() instanceof FastJson and
this.getDeclaringType().getASourceSupertype*() instanceof FastJson and

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that these are static methods.

exists(Method m |
this.getMethod() = m and
m.hasName("setSafeMode") and
m.getDeclaringType().hasQualifiedName("com.alibaba.fastjson.parser", "ParserConfig")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add getASourceSupertype*() to also cover subclasses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary here. I think it's quite unlikely that this will be overridden.

@aschackmull
Copy link
Contributor Author

Rebased to fix merge conflict.

@aschackmull aschackmull merged commit 2cf10a7 into github:main Nov 23, 2020
@aschackmull aschackmull deleted the java/fastjson branch November 23, 2020 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants