Initial support for Java - Play Framework > 2.6.x#4299
Initial support for Java - Play Framework > 2.6.x#4299aschackmull merged 20 commits intogithub:mainfrom
Conversation
smowton
left a comment
There was a problem hiding this comment.
Looks good; some suggestions and comments. Am I right understanding this currently only covers sources of untrusted information? In order to measure the effectiveness of the models it would be best to have some sinks to cover as well -- for example, https://www.playframework.com/documentation/1.2/security#xss their template engine normally escapes things for us, but use of the raw method allows us to bypass that, or https://stackoverflow.com/questions/14743199/how-to-pass-raw-html-to-play-framework-view shows some other ways a lazy dev might bypass the sanitizing template engine :)
We can go ahead as-is if you prefer, but including at least one common attack sink would likely make this a lot more productive for not much effort.
java/ql/src/semmle/code/java/frameworks/play/PlayMVCResults.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayMVCResults.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayMVCResults.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayMVCResults.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayMVCResults.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayAddCSRFToken.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayHTTPRequestHeader.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayBodyParser.qll
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Thank you for taking the time to review this. @smowton Like said this covers mostly sources. Play depends a lot of its basic security on its configuration, direct security impact sinks as such are less likely within the framework.
I will have a check on the raw method, as well as any other possible sinks and how its being used in the version 2.x and above and probably raise it as a different PR.
@smowton there was a mistake with a blind git add done, hence the couple of bad git conflict markers in commits, apologies for the same.
java/ql/src/semmle/code/java/frameworks/play/PlayAddCSRFToken.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayBodyParser.qll
Outdated
Show resolved
Hide resolved
fa523e4 to
f7d63f8
Compare
java/ql/src/semmle/code/java/frameworks/play/PlayHTTPRequestHeader.qll
Outdated
Show resolved
Hide resolved
smowton
left a comment
There was a problem hiding this comment.
Some more simplifications, plus I think rather than have lots of small files with a class or two each, let's put them into a single Play.qll for now, then we can split it as and when it becomes ungainly.
Regarding testing, let me know if you decide to implement or punt on the sinks, then I'll start a test job.
java/ql/src/semmle/code/java/frameworks/play/PlayAddCSRFToken.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayHTTPRequestHeader.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayController.qll
Outdated
Show resolved
Hide resolved
java/ql/src/semmle/code/java/frameworks/play/PlayController.qll
Outdated
Show resolved
Hide resolved
…d methods to remotetainted method for play
smowton
left a comment
There was a problem hiding this comment.
There are some parts of this PR that are untested still:
Test by checking these are recognised as sources, as is already done in the taintsources/remote.expected file:
- Parameters of an action method that returns a Result promise
- Parameters of an action method that returns a Result CompletionStage
- (negative test: add a method that returns some other type and check it is not wrongly detected)
- The header getQueryString method
Then regarding any of these classes that are not currently contributing to a RemoteFlowSource, such as everything to do with the Results class, PlayAddCSRFTokenAnnotation, PlayBodyParserAnnotation and so on, create a simple test under https://github.com/github/codeql/tree/main/java/ql/test/library-tests/frameworks that does something like from PlayAddCSRFTokenAnnotation ann select ann, just to check they are indeed binding the right classes / methods.
As a rule, make sure everything that is proposed for addition is covered by some test.
|
@smowton This should contain most of the test required for the PlayFramework, including the remoteflowsources. Fixed the other suggestions as mentioned. |
|
Thanks for the additional tests! Passing this on to get a code-owner review |
|
It doesn't look like the tests compile. |
@aschackmull Can you let me know which ones are failing ? All of them pass for me with following command below. |
java/ql/test/library-tests/frameworks/play/resources/Resource.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
|
Looks like there might be compilation errors or something like it in the tests: |
@aschackmull Works for me locally |
|
Weird. It passes locally for me as well. I'll try to rerun the test. |
|
A colleague of mine figured it out. There are a bunch of |
|
|
hmm @aschackmull i am still not able to reproduce with codeql 2.4.4 (latest available) |
|
Then I guess it hasn't yet made it into a released version. The above log output with the error positions should make it easy to fix, though. |
|
|
|
Could you also add a change note stating that Play Query Parameters are now recognized as remote sources of taint. See |


Initial Support for Play Framework (2.6.x)
RemoteFlowSourceand some of the methods toRemoteTaintedMethodI couldn't find much guidelines on how to contribute a framework, mostly the structure was stubbed out of
Spring.N.B: Haven't checked for full compatibility on 2.8.x and other latest etc, but should work.
Let me know if this looks good !!