-
Notifications
You must be signed in to change notification settings - Fork 2k
Java: Move HeaderSplittingSink and WhitelistedSource into importable library
#3928
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
Merged
aschackmull
merged 10 commits into
github:master
from
rvermeulen:java-importable-cwe-113
Aug 5, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5f560e0
Extract `HeaderSplittingSink` and `WhitelistedSource`
rvermeulen fed506a
Rename TrustedSource to SafeHeaderSplittingSource
rvermeulen b66f391
Extend source and sink from DataFlow::Node instead of DataFlow::exprNode
rvermeulen 7435dac
Move source and sink into importable library
rvermeulen 4ad6357
Add missing Java import
rvermeulen 782573e
Add and format qldocs according to the style guide.
rvermeulen b147be6
Restrict SafeHeaderSplittingSource to RemoteFlowSource
rvermeulen b3bb4cb
Rename and update qldoc of default safe header splitting source
rvermeulen c739c73
Update class qldocs
rvermeulen c2733ad
Apply grammar suggestions
rvermeulen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
java/ql/src/semmle/code/java/security/ResponseSplitting.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /** Provides classes to reason about header splitting attacks. */ | ||
|
|
||
| import java | ||
| import semmle.code.java.dataflow.DataFlow | ||
| import semmle.code.java.dataflow.FlowSources | ||
| import semmle.code.java.frameworks.Servlets | ||
| import semmle.code.java.frameworks.JaxWS | ||
|
|
||
| /** A sink that is vulnerable to an HTTP header splitting attack. */ | ||
| abstract class HeaderSplittingSink extends DataFlow::Node { } | ||
|
|
||
| /** A source that introduces data considered safe to use by a header splitting source. */ | ||
| abstract class SafeHeaderSplittingSource extends DataFlow::Node { | ||
| SafeHeaderSplittingSource() { this instanceof RemoteFlowSource } | ||
| } | ||
|
|
||
| /** A sink that identifies a Java Servlet or JaxWs method that is vulnerable to an HTTP header splitting attack. */ | ||
| private class ServletHeaderSplittingSink extends HeaderSplittingSink { | ||
| ServletHeaderSplittingSink() { | ||
| exists(ResponseAddCookieMethod m, MethodAccess ma | | ||
| ma.getMethod() = m and | ||
| this.asExpr() = ma.getArgument(0) | ||
| ) | ||
| or | ||
| exists(ResponseAddHeaderMethod m, MethodAccess ma | | ||
| ma.getMethod() = m and | ||
| this.asExpr() = ma.getAnArgument() | ||
| ) | ||
| or | ||
| exists(ResponseSetHeaderMethod m, MethodAccess ma | | ||
| ma.getMethod() = m and | ||
| this.asExpr() = ma.getAnArgument() | ||
| ) | ||
| or | ||
| exists(JaxRsResponseBuilder builder, Method m | | ||
| m = builder.getAMethod() and m.getName() = "header" | ||
| | | ||
| this.asExpr() = m.getAReference().getArgument(1) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| /** A default source that introduces data considered safe to use by a header splitting source. */ | ||
| private class DefaultSafeHeaderSplittingSource extends SafeHeaderSplittingSource { | ||
| DefaultSafeHeaderSplittingSource() { | ||
| this.asExpr().(MethodAccess).getMethod() instanceof HttpServletRequestGetHeaderMethod or | ||
| this.asExpr().(MethodAccess).getMethod() instanceof CookieGetNameMethod | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.