-
Notifications
You must be signed in to change notification settings - Fork 2k
Java: Move more dataflow configurations to *Query.qll files
#12721
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
egregius313
merged 23 commits into
github:main
from
egregius313:egregius313/java/move-configurations-to-libraries
May 5, 2023
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1af6d5f
Add TaintedPermissionsCheckQuery
egregius313 c15ce27
Add SqlConcatenatedQuery
egregius313 c2b6a3f
Add XPathInjectionQuery
egregius313 cc22a7d
Add XssLocalQuery
egregius313 5834e4a
Add UrlRedirectQuery.qll
egregius313 0249187
Add ExternallyControlledFormatStringLocalQuery.qll
egregius313 be24b29
Add UrlRedirectLocalQuery.qll
egregius313 b39d508
Add InsecureCookieQuery
egregius313 aff299e
Add ExecTaintedLocal
egregius313 a0f7575
Add StackTraceExposureQuery
egregius313 91b3533
Add SqlTaintedLocalQuery
egregius313 e4f47ec
Add ResponseSplittingLocalQuery
egregius313 4b76564
Add MaybeBrokenCryptoAlgorithmQuery
egregius313 e65a54b
Add BrokenCryptoAlgorithmQuery
egregius313 f4a6f55
Add NumericCastTaintedQuery
egregius313 24b00ba
Add UnsafeHostnameVerificationQuery
egregius313 77ee80f
Add missing change notes
egregius313 b6361cd
Move CWE-190/ArithmeticCommon.qll to semmle.code.java.security
egregius313 b087cf9
Add Arithmetic query libraries
egregius313 c319ee4
Add TempDirLocalInformationDisclosureQuery
egregius313 74fc638
Add improper validation of array size query libraries
egregius313 3100e98
Add missing change notes and update date
egregius313 5f3c8fe
Privacy markers and fixed imports
egregius313 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
31 changes: 31 additions & 0 deletions
31
java/ql/lib/change-notes/2023-05-04-add-libraries-for-query-configurations.md
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,31 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Added the `ArithmeticCommon.qll` library to provide predicates for reasoning about arithmetic operations. | ||
| * Added the `ArithmeticTaintedLocalQuery.qll` library to provide the `ArithmeticTaintedLocalOverflowFlow` and `ArithmeticTaintedLocalUnderflowFlow` taint-tracking modules to reason about arithmetic with unvalidated user input. | ||
| * Added the `ArithmeticTaintedQuery.qll` library to provide the `RemoteUserInputOverflow` and `RemoteUserInputUnderflow` taint-tracking modules to reason about arithmetic with unvalidated user input. | ||
| * Added the `ArithmeticUncontrolledQuery.qll` library to provide the `ArithmeticUncontrolledOverflowFlow` and `ArithmeticUncontrolledUnderflowFlow` taint-tracking modules to reason about arithmetic with uncontrolled user input. | ||
| * Added the `ArithmeticWithExtremeValuesQuery.qll` library to provide the `MaxValueFlow` and `MinValueFlow` dataflow modules to reason about arithmetic with extreme values. | ||
| * Added the `BrokenCryptoAlgorithmQuery.qll` library to provide the `InsecureCryptoFlow` taint-tracking module to reason about broken cryptographic algorithm vulnerabilities. | ||
| * Added the `ExecTaintedLocalQuery.qll` library to provide the `LocalUserInputToArgumentToExecFlow` taint-tracking module to reason about command injection vulnerabilities caused by local data flow. | ||
| * Added the `ExternallyControlledFormatStringLocalQuery.qll` library to provide the `ExternallyControlledFormatStringLocalFlow` taint-tracking module to reason about format string vulnerabilities caused by local data flow. | ||
| * Added the `ImproperValidationOfArrayConstructionCodeSpecifiedQuery.qll` library to provide the `BoundedFlowSourceFlow` dataflow module to reason about improper validation of code-specified sizes used for array construction. | ||
| * Added the `ImproperValidationOfArrayConstructionLocalQuery.qll` library to provide the `ImproperValidationOfArrayConstructionLocalFlow` taint-tracking module to reason about improper validation of local user-provided sizes used for array construction caused by local data flow. | ||
| * Added the `ImproperValidationOfArrayConstructionQuery.qll` library to provide the `ImproperValidationOfArrayConstructionFlow` taint-tracking module to reason about improper validation of user-provided size used for array construction. | ||
| * Added the `ImproperValidationOfArrayIndexCodeSpecifiedQuery.qll` library to provide the `BoundedFlowSourceFlow` data flow module to reason about about improper validation of code-specified array index. | ||
| * Added the `ImproperValidationOfArrayIndexLocalQuery.qll` library to provide the `ImproperValidationOfArrayIndexLocalFlow` taint-tracking module to reason about improper validation of a local user-provided array index. | ||
| * Added the `ImproperValidationOfArrayIndexQuery.qll` library to provide the `ImproperValidationOfArrayIndexFlow` taint-tracking module to reason about improper validation of user-provided array index. | ||
| * Added the `InsecureCookieQuery.qll` library to provide the `SecureCookieFlow` taint-tracking module to reason about insecure cookie vulnerabilities. | ||
| * Added the `MaybeBrokenCryptoAlgorithmQuery.qll` library to provide the `InsecureCryptoFlow` taint-tracking module to reason about broken cryptographic algorithm vulnerabilities. | ||
| * Added the `NumericCastTaintedQuery.qll` library to provide the `NumericCastTaintedFlow` taint-tracking module to reason about numeric cast vulnerabilities. | ||
| * Added the `ResponseSplittingLocalQuery.qll` library to provide the `ResponseSplittingLocalFlow` taint-tracking module to reason about response splitting vulnerabilities caused by local data flow. | ||
| * Added the `SqlConcatenatedQuery.qll` library to provide the `UncontrolledStringBuilderSourceFlow` taint-tracking module to reason about SQL injection vulnerabilities caused by concatenating untrusted strings. | ||
| * Added the `SqlTaintedLocalQuery.qll` library to provide the `LocalUserInputToArgumentToSqlFlow` taint-tracking module to reason about SQL injection vulnerabilities caused by local data flow. | ||
| * Added the `StackTraceExposureQuery.qll` library to provide the `printsStackExternally`, `stringifiedStackFlowsExternally`, and `getMessageFlowsExternally` predicates to reason about stack trace exposure vulnerabilities. | ||
| * Added the `TaintedPermissionQuery.qll` library to provide the `TaintedPermissionFlow` taint-tracking module to reason about tainted permission vulnerabilities. | ||
| * Added the `TempDirLocalInformationDisclosureQuery.qll` library to provide the `TempDirSystemGetPropertyToCreate` taint-tracking module to reason about local information disclosure vulnerabilities caused by local data flow. | ||
| * Added the `UnsafeHostnameVerificationQuery.qll` library to provide the `TrustAllHostnameVerifierFlow` taint-tracking module to reason about insecure hostname verification vulnerabilities. | ||
| * Added the `UrlRedirectLocalQuery.qll` library to provide the `UrlRedirectLocalFlow` taint-tracking module to reason about URL redirection vulnerabilities caused by local data flow. | ||
| * Added the `UrlRedirectQuery.qll` library to provide the `UrlRedirectFlow` taint-tracking module to reason about URL redirection vulnerabilities. | ||
| * Added the `XPathInjectionQuery.qll` library to provide the `XPathInjectionFlow` taint-tracking module to reason about XPath injection vulnerabilities. | ||
| * Added the `XssLocalQuery.qll` library to provide the `XssLocalFlow` taint-tracking module to reason about XSS vulnerabilities caused by local data flow. |
2 changes: 2 additions & 0 deletions
2
...Security/CWE/CWE-190/ArithmeticCommon.qll → ...e/code/java/security/ArithmeticCommon.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
39 changes: 39 additions & 0 deletions
39
java/ql/lib/semmle/code/java/security/ArithmeticTaintedLocalQuery.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,39 @@ | ||
| /** Provides taint-tracking configurations to reason about arithmetic using local-user-controlled data. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.FlowSources | ||
| private import semmle.code.java.security.ArithmeticCommon | ||
|
|
||
| /** | ||
| * A taint-tracking configuration to reason about arithmetic overflow using local-user-controlled data. | ||
| */ | ||
| module ArithmeticTaintedLocalOverflowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { overflowBarrier(n) } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for arithmetic overflow using local-user-controlled data. | ||
| */ | ||
| module ArithmeticTaintedLocalOverflowFlow = | ||
| TaintTracking::Global<ArithmeticTaintedLocalOverflowConfig>; | ||
|
|
||
| /** | ||
| * A taint-tracking configuration to reason about arithmetic underflow using local-user-controlled data. | ||
| */ | ||
| module ArithmeticTaintedLocalUnderflowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { underflowBarrier(n) } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for arithmetic underflow using local-user-controlled data. | ||
| */ | ||
| module ArithmeticTaintedLocalUnderflowFlow = | ||
| TaintTracking::Global<ArithmeticTaintedLocalUnderflowConfig>; |
29 changes: 29 additions & 0 deletions
29
java/ql/lib/semmle/code/java/security/ArithmeticTaintedQuery.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,29 @@ | ||
| /** Provides taint-tracking configurations to reason about arithmetic with unvalidated user input. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.FlowSources | ||
| private import semmle.code.java.security.ArithmeticCommon | ||
|
|
||
| /** A taint-tracking configuration to reason about overflow from unvalidated user input. */ | ||
| module RemoteUserInputOverflowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { overflowBarrier(n) } | ||
| } | ||
|
|
||
| /** A taint-tracking configuration to reason about underflow from unvalidated user input. */ | ||
| module RemoteUserInputUnderflowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { underflowBarrier(n) } | ||
| } | ||
|
|
||
| /** Taint-tracking flow for overflow from unvalidated user input. */ | ||
| module RemoteUserInputOverflow = TaintTracking::Global<RemoteUserInputOverflowConfig>; | ||
|
|
||
| /** Taint-tracking flow for underflow from unvalidated user input. */ | ||
| module RemoteUserInputUnderflow = TaintTracking::Global<RemoteUserInputUnderflowConfig>; |
39 changes: 39 additions & 0 deletions
39
java/ql/lib/semmle/code/java/security/ArithmeticUncontrolledQuery.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,39 @@ | ||
| /** Provides taint-tracking configuration to reason about arithmetic with uncontrolled values. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.TaintTracking | ||
| private import semmle.code.java.security.RandomQuery | ||
| private import semmle.code.java.security.SecurityTests | ||
| private import semmle.code.java.security.ArithmeticCommon | ||
|
|
||
| private class TaintSource extends DataFlow::ExprNode { | ||
| TaintSource() { | ||
| exists(RandomDataSource m | not m.resultMayBeBounded() | m.getOutput() = this.getExpr()) | ||
| } | ||
| } | ||
|
|
||
| /** A taint-tracking configuration to reason about overflow from arithmetic with uncontrolled values. */ | ||
| module ArithmeticUncontrolledOverflowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof TaintSource } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { overflowBarrier(n) } | ||
| } | ||
|
|
||
| /** Taint-tracking flow to reason about overflow from arithmetic with uncontrolled values. */ | ||
| module ArithmeticUncontrolledOverflowFlow = | ||
| TaintTracking::Global<ArithmeticUncontrolledOverflowConfig>; | ||
|
|
||
| /** A taint-tracking configuration to reason about underflow from arithmetic with uncontrolled values. */ | ||
| module ArithmeticUncontrolledUnderflowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof TaintSource } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { underflowBarrier(n) } | ||
| } | ||
|
|
||
| /** Taint-tracking flow to reason about underflow from arithmetic with uncontrolled values. */ | ||
| module ArithmeticUncontrolledUnderflowFlow = | ||
| TaintTracking::Global<ArithmeticUncontrolledUnderflowConfig>; |
61 changes: 61 additions & 0 deletions
61
java/ql/lib/semmle/code/java/security/ArithmeticWithExtremeValuesQuery.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,61 @@ | ||
| /** Provides predicates and classes for reasoning about arithmetic with extreme values. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.DataFlow | ||
| private import semmle.code.java.security.ArithmeticCommon | ||
|
|
||
| /** | ||
| * A field representing an extreme value. | ||
| * | ||
| * For example, `Integer.MAX_VALUE` or `Long.MIN_VALUE`. | ||
| */ | ||
| abstract class ExtremeValueField extends Field { | ||
| ExtremeValueField() { this.getType() instanceof IntegralType } | ||
| } | ||
|
|
||
| /** A field representing the minimum value of a primitive type. */ | ||
| private class MinValueField extends ExtremeValueField { | ||
| MinValueField() { this.getName() = "MIN_VALUE" } | ||
| } | ||
|
|
||
| /** A field representing the maximum value of a primitive type. */ | ||
| private class MaxValueField extends ExtremeValueField { | ||
| MaxValueField() { this.getName() = "MAX_VALUE" } | ||
| } | ||
|
|
||
| /** A variable access that refers to an extreme value. */ | ||
| class ExtremeSource extends VarAccess { | ||
| ExtremeSource() { this.getVariable() instanceof ExtremeValueField } | ||
| } | ||
|
|
||
| /** A dataflow configuration which tracks flow from maximum values to an overflow. */ | ||
| module MaxValueFlowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { | ||
| source.asExpr().(ExtremeSource).getVariable() instanceof MaxValueField | ||
| } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrierIn(DataFlow::Node n) { isSource(n) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { overflowBarrier(n) } | ||
| } | ||
|
|
||
| /** Dataflow from maximum values to an underflow. */ | ||
| module MaxValueFlow = DataFlow::Global<MaxValueFlowConfig>; | ||
|
|
||
| /** A dataflow configuration which tracks flow from minimum values to an underflow. */ | ||
| module MinValueFlowConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { | ||
| source.asExpr().(ExtremeSource).getVariable() instanceof MinValueField | ||
| } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) } | ||
|
|
||
| predicate isBarrierIn(DataFlow::Node n) { isSource(n) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node n) { underflowBarrier(n) } | ||
| } | ||
|
|
||
| /** Dataflow from minimum values to an underflow. */ | ||
| module MinValueFlow = DataFlow::Global<MinValueFlowConfig>; |
38 changes: 38 additions & 0 deletions
38
java/ql/lib/semmle/code/java/security/BrokenCryptoAlgorithmQuery.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,38 @@ | ||
| /** Provides to taint-tracking configuration to reason about the use of broken or risky cryptographic algorithms. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.security.Encryption | ||
| private import semmle.code.java.dataflow.TaintTracking | ||
|
|
||
| private class ShortStringLiteral extends StringLiteral { | ||
| ShortStringLiteral() { this.getValue().length() < 100 } | ||
| } | ||
|
|
||
| /** | ||
| * A string literal that may refer to a broken or risky cryptographic algorithm. | ||
| */ | ||
| class BrokenAlgoLiteral extends ShortStringLiteral { | ||
| BrokenAlgoLiteral() { | ||
| this.getValue().regexpMatch(getInsecureAlgorithmRegex()) and | ||
| // Exclude German and French sentences. | ||
| not this.getValue().regexpMatch(".*\\p{IsLowercase} des \\p{IsLetter}.*") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * A taint-tracking configuration to reason about the use of broken or risky cryptographic algorithms. | ||
| */ | ||
| module InsecureCryptoConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node n) { n.asExpr() instanceof BrokenAlgoLiteral } | ||
|
|
||
| predicate isSink(DataFlow::Node n) { exists(CryptoAlgoSpec c | n.asExpr() = c.getAlgoSpec()) } | ||
|
|
||
| predicate isBarrier(DataFlow::Node node) { | ||
| node.getType() instanceof PrimitiveType or node.getType() instanceof BoxedType | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for use of broken or risky cryptographic algorithms. | ||
| */ | ||
| module InsecureCryptoFlow = TaintTracking::Global<InsecureCryptoConfig>; | ||
26 changes: 26 additions & 0 deletions
26
java/ql/lib/semmle/code/java/security/ExecTaintedLocalQuery.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,26 @@ | ||
| /** Provides a taint-tracking configuration to reason about use of externally controlled strings for command injection vulnerabilities. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.FlowSources | ||
| private import semmle.code.java.security.ExternalProcess | ||
| private import semmle.code.java.security.CommandArguments | ||
|
|
||
| /** A taint-tracking configuration to reason about use of externally controlled strings to make command line commands. */ | ||
| module ExecTaintedLocalConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node src) { src instanceof LocalUserInput } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof ArgumentToExec } | ||
|
|
||
| predicate isBarrier(DataFlow::Node node) { | ||
| node.getType() instanceof PrimitiveType | ||
| or | ||
| node.getType() instanceof BoxedType | ||
| or | ||
| isSafeCommandArgument(node.asExpr()) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for use of externally controlled strings to make command line commands. | ||
| */ | ||
| module ExecTaintedLocalFlow = TaintTracking::Global<ExecTaintedLocalConfig>; |
20 changes: 20 additions & 0 deletions
20
java/ql/lib/semmle/code/java/security/ExternallyControlledFormatStringLocalQuery.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,20 @@ | ||
| /** Provides a taint-tracking configuration to reason about externally-controlled format strings from local sources. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.FlowSources | ||
| private import semmle.code.java.StringFormat | ||
|
|
||
| /** A taint-tracking configuration to reason about externally-controlled format strings from local sources. */ | ||
| module ExternallyControlledFormatStringLocalConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { | ||
| sink.asExpr() = any(StringFormat formatCall).getFormatArgument() | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for externally-controlled format strings from local sources. | ||
| */ | ||
| module ExternallyControlledFormatStringLocalFlow = | ||
| TaintTracking::Global<ExternallyControlledFormatStringLocalConfig>; |
25 changes: 25 additions & 0 deletions
25
...lib/semmle/code/java/security/ImproperValidationOfArrayConstructionCodeSpecifiedQuery.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,25 @@ | ||
| /** Provides a dataflow configuration to reason about improper validation of code-specified size used for array construction. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.security.internal.ArraySizing | ||
| private import semmle.code.java.dataflow.TaintTracking | ||
|
|
||
| /** | ||
| * A dataflow configuration to reason about improper validation of code-specified size used for array construction. | ||
| */ | ||
| module BoundedFlowSourceConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { | ||
| source instanceof BoundedFlowSource and | ||
| // There is not a fixed lower bound which is greater than zero. | ||
| not source.(BoundedFlowSource).lowerBound() > 0 | ||
| } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { | ||
| any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Dataflow flow for improper validation of code-specified size used for array construction. | ||
| */ | ||
| module BoundedFlowSourceFlow = DataFlow::Global<BoundedFlowSourceConfig>; |
22 changes: 22 additions & 0 deletions
22
java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionLocalQuery.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,22 @@ | ||
| /** Provides a taint-tracking configuration to reason about improper validation of local user-provided size used for array construction. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.security.internal.ArraySizing | ||
| private import semmle.code.java.dataflow.FlowSources | ||
|
|
||
| /** | ||
| * A taint-tracking configuration to reason about improper validation of local user-provided size used for array construction. | ||
| */ | ||
| module ImproperValidationOfArrayConstructionLocalConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { | ||
| any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for improper validation of local user-provided size used for array construction. | ||
| */ | ||
| module ImproperValidationOfArrayConstructionLocalFlow = | ||
| TaintTracking::Global<ImproperValidationOfArrayConstructionLocalConfig>; |
22 changes: 22 additions & 0 deletions
22
java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionQuery.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,22 @@ | ||
| /** Provides a taint-tracking configuration to reason about improper validation of user-provided size used for array construction. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.security.internal.ArraySizing | ||
| private import semmle.code.java.dataflow.FlowSources | ||
|
|
||
| /** | ||
| * A taint-tracking configuration to reason about improper validation of user-provided size used for array construction. | ||
| */ | ||
| module ImproperValidationOfArrayConstructionConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { | ||
| any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Taint-tracking flow for improper validation of user-provided size used for array construction. | ||
| */ | ||
| module ImproperValidationOfArrayConstructionFlow = | ||
| TaintTracking::Global<ImproperValidationOfArrayConstructionConfig>; |
22 changes: 22 additions & 0 deletions
22
java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayIndexCodeSpecifiedQuery.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,22 @@ | ||
| /** Provides a dataflow configuration to reason about improper validation of code-specified array index. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.security.internal.ArraySizing | ||
| private import semmle.code.java.security.internal.BoundingChecks | ||
| private import semmle.code.java.dataflow.DataFlow | ||
|
|
||
|
|
||
| /** | ||
| * A dataflow configuration to reason about improper validation of code-specified array index. | ||
| */ | ||
| module BoundedFlowSourceConfig implements DataFlow::ConfigSig { | ||
| predicate isSource(DataFlow::Node source) { source instanceof BoundedFlowSource } | ||
|
|
||
| predicate isSink(DataFlow::Node sink) { | ||
| exists(CheckableArrayAccess arrayAccess | arrayAccess.canThrowOutOfBounds(sink.asExpr())) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Dataflow flow for improper validation of code-specified array index. | ||
| */ | ||
| module BoundedFlowSourceFlow = DataFlow::Global<BoundedFlowSourceConfig>; | ||
Oops, something went wrong.
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.