Visitar URL original
Add binding between annotation and sink-param by ka1n4t · Pull Request #11368 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20221124051046/https://github.com/github/codeql/pull/11368
Skip to content
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

Add binding between annotation and sink-param #11368

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

ka1n4t
Copy link

@ka1n4t ka1n4t commented Nov 22, 2022

Add binding between annotation and sink-param.

In below case, the rule MyBatisAnnotationSqlInjection.ql will find a vulnerability at parameter name in function testParamAnno1(). That is false positive.

@Select("select * from user_info where name = #{name} and age = ${age}")
String testParamAnno1(@Param("name") String name, Integer age);

@Select("select * from user_info where age = #{age}")
String testParamAnno2(@Param("age") String age);

The root cause is, isMybatisXmlOrAnnotationSqlInjection() find annotation @Param in testParamAnno2() and bind it to ${age} in @Select("select * from user_info where name = #{name} and age = ${age}") when processing parameter name in testParamAnno1(). So it raise a vulnerability to name when it saw ${age} binding with @Param("age").

@ka1n4t ka1n4t requested a review from a team as a code owner Nov 22, 2022
@github-actions github-actions bot added the Java label Nov 22, 2022
@atorralba
Copy link
Contributor

atorralba commented Nov 22, 2022

This looks like an interesting addition, thanks for the contribution! Would you mind adding a test case highlighting the issue you're fixing?

@ka1n4t
Copy link
Author

ka1n4t commented Nov 23, 2022

This looks like an interesting addition, thanks for the contribution! Would you mind adding a test case highlighting the issue you're fixing?

Of course! I have committed the test case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants