Skip to content

Diff-informed queries: phase 3 (non-trivial locations) #19957

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

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
09daa56
[TEST] C++: CWE-020/ExternalAPI: add tests based on qlhelp (TODO: pro…
d10c Jul 15, 2025
b3db51e
[TEST] C++: CleartextSqliteDatabase: add new test
d10c Jul 15, 2025
87db121
[TEST] Java: CWE-020/ExternalAPI: new test based on qhelp
d10c Jul 15, 2025
0bfc400
[TEST] Java: LogInjection: convert test to qlref
d10c Jul 15, 2025
e1cce4e
[TEST] Java: UnsafeCertTrust: convert test to qlref
d10c Jul 15, 2025
9fa5760
[TEST] Java: TrustBoundaryViolations: convert test to qlref
d10c Jul 15, 2025
3247321
[TEST] Java: SensitiveLogInfo: convert to qlref
d10c Jul 15, 2025
fd18b62
[TEST] Java: ConditionalBypass: convert to qlref
d10c Jul 15, 2025
64689b2
[TEST] Java: SensitiveCommunication: convert to qlref
d10c Jul 15, 2025
29c3916
[TEST] Python: TimingAttackAgainstHash: add qlref test to existing so…
d10c Jul 15, 2025
0874f86
[DIFF-INFORMED] Actions: ArgumentInjection
d10c Jul 15, 2025
96a39da
[DIFF-INFORMED] Actions: ArtifactPoisoning
d10c Jul 15, 2025
3f30cf0
[DIFF-INFORMED] Actions: CodeInjection
d10c Jul 15, 2025
3eb1a87
[DIFF-INFORMED] Actions: CommandInjection
d10c Jul 15, 2025
75b211f
[DIFF-INFORMED] Actions: EnvPathInjection
d10c Jul 15, 2025
570e70d
[DIFF-INFORMED] Actions: EnvVarInjection
d10c Jul 15, 2025
8cc0537
[DIFF-INFORMED] C++: OverflowDestination
d10c Jul 15, 2025
fa15582
[DIFF-INFORMED] C++: ConstantSizeArrayOffByOne
d10c Jul 15, 2025
698fbde
[DIFF-INFORMED] C++: DecompressionBombs
d10c Jul 15, 2025
56e6187
[DIFF-INFORMED] C++: NonConstantFormat
d10c Jul 15, 2025
7044eb4
[DIFF-INFORMED] C++: LeapYear
d10c Jul 16, 2025
d7ae55a
[DIFF-INFORMED] C++: (IR) ExternalAPIs
d10c Jul 16, 2025
3a83961
[DIFF-INFORMED] C++: TaintedPath
d10c Jul 16, 2025
1cc2793
[DIFF-INFORMED] C++: ExecTainted
d10c Jul 16, 2025
db3df32
[DIFF-INFORMED] C++: CgiXss
d10c Jul 16, 2025
803cfcf
[DIFF-INFORMED] C++: SqlTainted
d10c Jul 16, 2025
3b0cfc5
[DIFF-INFORMED] C++: UnboundedWrite
d10c Jul 16, 2025
6ff8746
[DIFF-INFORMED] C++: ImproperNullTerminationTainted
d10c Jul 16, 2025
905635b
[DIFF-INFORMED] C++: CWE-190/ArithmeticTainted,etc.
d10c Jul 16, 2025
89cc942
[DIFF-INFORMED] C++: AuthenticationBypass
d10c Jul 16, 2025
858f4fd
[DIFF-INFORMED] C++: SSLResultConflation (has secondary config but pa…
d10c Jul 16, 2025
c75b1f1
[DIFF-INFORMED] C++: CWE-311/Cleartext…
d10c Jul 16, 2025
dfc1ace
[DIFF-INFORMED] C++: CleartextSqliteDatabase
d10c Jul 16, 2025
1a24e5d
[DIFF-INFORMED] C++: UseOfHttp
d10c Jul 16, 2025
5bb53d3
[DIFF-INFORMED] C++: InsufficientKeySize
d10c Jul 16, 2025
d7710fc
[DIFF-INFORMED] C++: IteratorToExpiredContainer
d10c Jul 16, 2025
382b482
[DIFF-INFORMED] C++: UnsafeCreateProcessCall
d10c Jul 16, 2025
233c015
[DIFF-INFORMED] C++: UnsafeDaclSecurityDescriptor
d10c Jul 16, 2025
94611b8
[DIFF-INFORMED] C++: TaintedCondition
d10c Jul 16, 2025
61a3495
[DIFF-INFORMED] C++: TypeConfusion
d10c Jul 16, 2025
f18fbf8
[DIFF-INFORMED] C#: ConditionalBypass
d10c Jul 16, 2025
398ad9a
[DIFF-INFORMED] C#: ExternalAPIs
d10c Jul 16, 2025
0f5fc82
[DIFF-INFORMED] C#: UnsafeDeserializationQuery
d10c Jul 16, 2025
3b56f5b
[DIFF-INFORMED] C#: ThreadUnsafeCryptoTransformLambda
d10c Jul 16, 2025
e3714a8
[DIFF-INFORMED] C#: HardcodedConnectionString
d10c Jul 16, 2025
f8ba5af
[DIFF-INFORMED] Go: AllocationSizeOverflow
d10c Jul 16, 2025
a6547a5
[DIFF-INFORMED] Go: CommandInjection
d10c Jul 16, 2025
dab97f3
[DIFF-INFORMED] Go: ExternalAPIs
d10c Jul 16, 2025
c1a5881
[DIFF-INFORMED] Go: HardcodedCredentials
d10c Jul 16, 2025
53f4c94
[DIFF-INFORMED] Go: IncorrectIntegerConversion
d10c Jul 16, 2025
e7935b6
[DIFF-INFORMED] Go: InsecureRandomness
d10c Jul 16, 2025
40f7a3b
[DIFF-INFORMED] Go: ReflectedXss
d10c Jul 16, 2025
5527221
[DIFF-INFORMED] Go: RequestForgery, SafeUrlFlow
d10c Jul 16, 2025
cccf6e6
[DIFF-INFORMED] Go: SensitiveConditionBypass
d10c Jul 16, 2025
e94b492
[DIFF-INFORMED] Go: ConditionalBypass
d10c Jul 16, 2025
f3453c7
[DIFF-INFORMED] Go: SSRF
d10c Jul 16, 2025
8594d31
[DIFF-INFORMED] Go: AuthCookie
d10c Jul 16, 2025
9ec0d13
[DIFF-INFORMED] Go: UnhandledCloseWritableHandle
d10c Jul 16, 2025
9ecf0f2
[DIFF-INFORMED] Go: InsecureHostKeyCallback
d10c Jul 16, 2025
a2b8db8
[DIFF-INFORMED] Go: BadRedirectCheck
d10c Jul 16, 2025
03d4adc
[DIFF-INFORMED] Java: (Android)SensitiveCommunication
d10c Jul 16, 2025
f6e7f63
[DIFF-INFORMED] Java: ArithmeticTainted
d10c Jul 16, 2025
d837355
[DIFF-INFORMED] Java: ArithmeticUncontrolled
d10c Jul 16, 2025
e84c8bd
[DIFF-INFORMED] Java: ConditionalBypass
d10c Jul 16, 2025
dbcb1fb
[DIFF-INFORMED] Java: UntrustedDataToExternalAPI
d10c Jul 16, 2025
d7258a9
[DIFF-INFORMED] Java: ExternallyControlledFormatString
d10c Jul 16, 2025
94de00b
[DIFF-INFORMED] Java: ImproperValidationOfArray…
d10c Jul 16, 2025
52c0d62
[DIFF-INFORMED] Java: InsecureCookie
d10c Jul 16, 2025
4a985bf
[DIFF-INFORMED] Java: InsecureLdapAuth
d10c Jul 16, 2025
650a5dd
[DIFF-INFORMED] Java: LogInjection
d10c Jul 16, 2025
0b9d638
[DIFF-INFORMED] Java: MaybeBrokenCryptoAlgorithm
d10c Jul 16, 2025
9cb55f3
[DIFF-INFORMED] Java: SensitiveLogging
d10c Jul 16, 2025
5228767
[DIFF-INFORMED] Java: SqlConcatenated
d10c Jul 16, 2025
3197508
[DIFF-INFORMED] Java: TaintedEnvironmentVariable
d10c Jul 16, 2025
69e93eb
[DIFF-INFORMED] Java: TempDirLocalInformationDisclosure
d10c Jul 16, 2025
f10210c
[DIFF-INFORMED] Java: TrustBoundaryViolation
d10c Jul 16, 2025
5e05aeb
[DIFF-INFORMED] Java: UnsafeCertTrust
d10c Jul 16, 2025
06add01
[DIFF-INFORMED] Java: AndroidWebViewSettingsAllowsContentAccess
d10c Jul 16, 2025
89dd8a8
[DIFF-INFORMED] JS: IndirectCommandInjection
d10c Jul 16, 2025
2a5eae2
[DIFF-INFORMED] JS: ShellCommandInjectionFromEnvironment
d10c Jul 16, 2025
81bbcda
[DIFF-INFORMED] JS: EnvValueAndKeyInjection
d10c Jul 16, 2025
272a97d
[DIFF-INFORMED] JS: decodeJwtWithoutVerification
d10c Jul 16, 2025
e7b6ad2
[DIFF-INFORMED] Python: (Possible)TimingAttackAgainstHash
d10c Jul 16, 2025
9f72a2f
[DIFF-INFORMED] Ruby: MissingFullAnchor
d10c Jul 16, 2025
2ba8234
[DIFF-INFORMED] Rust: RegexInjection
d10c Jul 16, 2025
2afffd3
[DIFF-INFORMED] Rust: TaintedPath
d10c Jul 16, 2025
7e4f37f
[DIFF-INFORMED] Rust: SqlInjection
d10c Jul 16, 2025
b3f76ce
[DIFF-INFORMED] Rust: CleartextTransmission
d10c Jul 16, 2025
d25c8cd
[DIFF-INFORMED] Rust: CleartextLogging
d10c Jul 16, 2025
ca1848e
[DIFF-INFORMED] Rust: UncontrolledAllocationSize
d10c Jul 16, 2025
ab6be38
[DIFF-INFORMED] Rust: AccessAfterLifetime
d10c Jul 16, 2025
a0215ae
[DIFF-INFORMED] Rust: AccessInvalidPointer
d10c Jul 16, 2025
162781d
[DIFF-INFORMED] Swift: CleartextStorageDatabase
d10c Jul 16, 2025
37e6e2c
[DIFF-INFORMED] Swift: CleartextStoragePreferences
d10c Jul 16, 2025
649df5b
[DIFF-INFORMED] Swift: InsecureTLS
d10c Jul 16, 2025
085720a
[DIFF-INFORMED] Swift: UnsafeWebViewFetch
d10c Jul 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
private import actions
private import codeql.actions.TaintTracking
private import codeql.actions.dataflow.ExternalFlow
private import codeql.actions.security.ControlChecks
import codeql.actions.dataflow.FlowSources
import codeql.actions.DataFlow

Expand Down Expand Up @@ -88,6 +89,19 @@ private module ArgumentInjectionConfig implements DataFlow::ConfigSig {
run.getScript().getAnEnvReachingArgumentInjectionSink(var, _, _)
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
exists(Event event | result = event.getLocation() |
inPrivilegedContext(sink.asExpr(), event) and
not exists(ControlCheck check | check.protects(sink.asExpr(), event, "argument-injection"))
)
}
}

/** Tracks flow of unsafe user input that is used to construct and evaluate a code script. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import codeql.actions.DataFlow
import codeql.actions.dataflow.FlowSources
import codeql.actions.security.PoisonableSteps
import codeql.actions.security.UntrustedCheckoutQuery
import codeql.actions.security.ControlChecks

string unzipRegexp() { result = "(unzip|tar)\\s+.*" }

Expand Down Expand Up @@ -318,6 +319,19 @@ private module ArtifactPoisoningConfig implements DataFlow::ConfigSig {
exists(run.getScript().getAFileReadCommand())
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
exists(Event event | result = event.getLocation() |
inPrivilegedContext(sink.asExpr(), event) and
not exists(ControlCheck check | check.protects(sink.asExpr(), event, "artifact-poisoning"))
)
}
}

/** Tracks flow of unsafe artifacts that is used in an insecure way. */
Expand Down
49 changes: 49 additions & 0 deletions actions/ql/lib/codeql/actions/security/CodeInjectionQuery.qll
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ private import codeql.actions.TaintTracking
private import codeql.actions.dataflow.ExternalFlow
import codeql.actions.dataflow.FlowSources
import codeql.actions.DataFlow
import codeql.actions.security.ControlChecks
import codeql.actions.security.CachePoisoningQuery

class CodeInjectionSink extends DataFlow::Node {
CodeInjectionSink() {
Expand Down Expand Up @@ -35,6 +37,53 @@ private module CodeInjectionConfig implements DataFlow::ConfigSig {
exists(run.getScript().getAFileReadCommand())
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
// where clause from CodeInjectionCritical.ql
exists(Event event, RemoteFlowSource source | result = event.getLocation() |
inPrivilegedContext(sink.asExpr(), event) and
isSource(source) and
source.getEventName() = event.getName() and
not exists(ControlCheck check | check.protects(sink.asExpr(), event, "code-injection")) and
// exclude cases where the sink is a JS script and the expression uses toJson
not exists(UsesStep script |
script.getCallee() = "actions/github-script" and
script.getArgumentExpr("script") = sink.asExpr() and
exists(getAToJsonReferenceExpression(sink.asExpr().(Expression).getExpression(), _))
)
)
or
// where clause from CachePoisoningViaCodeInjection.ql
exists(Event event, LocalJob job, DataFlow::Node source | result = event.getLocation() |
job = sink.asExpr().getEnclosingJob() and
job.getATriggerEvent() = event and
// job can be triggered by an external user
event.isExternallyTriggerable() and
// the checkout is not controlled by an access check
isSource(source) and
not exists(ControlCheck check | check.protects(source.asExpr(), event, "code-injection")) and
// excluding privileged workflows since they can be exploited in easier circumstances
// which is covered by `actions/code-injection/critical`
not job.isPrivilegedExternallyTriggerable(event) and
(
// the workflow runs in the context of the default branch
runsOnDefaultBranch(event)
or
// the workflow caller runs in the context of the default branch
event.getName() = "workflow_call" and
exists(ExternalJob caller |
caller.getCallee() = job.getLocation().getFile().getRelativePath() and
runsOnDefaultBranch(caller.getATriggerEvent())
)
)
)
}
}

/** Tracks flow of unsafe user input that is used to construct and evaluate a code script. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ private import codeql.actions.TaintTracking
private import codeql.actions.dataflow.ExternalFlow
import codeql.actions.dataflow.FlowSources
import codeql.actions.DataFlow
import codeql.actions.security.ControlChecks

private class CommandInjectionSink extends DataFlow::Node {
CommandInjectionSink() { madSink(this, "command-injection") }
Expand All @@ -16,6 +17,22 @@ private module CommandInjectionConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }

predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjectionSink }

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
// where clause from CommandInjectionCritical.ql
exists(Event event | result = event.getLocation() |
inPrivilegedContext(sink.asExpr(), event) and
not exists(ControlCheck check |
check.protects(sink.asExpr(), event, ["command-injection", "code-injection"])
)
)
}
}

/** Tracks flow of unsafe user input that is used to construct and evaluate a system command. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,30 @@ private module EnvPathInjectionConfig implements DataFlow::ConfigSig {
exists(run.getScript().getAFileReadCommand())
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
// where clause from EnvPathInjectionCritical.ql
exists(Event event, RemoteFlowSource source | result = event.getLocation() |
inPrivilegedContext(sink.asExpr(), event) and
isSource(source) and
(
not source.getSourceType() = "artifact" and
not exists(ControlCheck check | check.protects(sink.asExpr(), event, "code-injection"))
or
source.getSourceType() = "artifact" and
not exists(ControlCheck check |
check.protects(sink.asExpr(), event, ["untrusted-checkout", "artifact-poisoning"])
) and
sink instanceof EnvPathInjectionFromFileReadSink
)
)
}
}

/** Tracks flow of unsafe user input that is used to construct and evaluate the PATH environment variable. */
Expand Down
34 changes: 34 additions & 0 deletions actions/ql/lib/codeql/actions/security/EnvVarInjectionQuery.qll
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,40 @@ private module EnvVarInjectionConfig implements DataFlow::ConfigSig {
exists(run.getScript().getAFileReadCommand())
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
// where clause from EnvVarInjectionCritical.ql
exists(Event event, RemoteFlowSource source | result = event.getLocation() |
inPrivilegedContext(sink.asExpr(), event) and
isSource(source) and
// exclude paths to file read sinks from non-artifact sources
(
// source is text
not source.getSourceType() = "artifact" and
not exists(ControlCheck check |
check.protects(sink.asExpr(), event, ["envvar-injection", "code-injection"])
)
or
// source is an artifact or a file from an untrusted checkout
source.getSourceType() = "artifact" and
not exists(ControlCheck check |
check
.protects(sink.asExpr(), event,
["envvar-injection", "untrusted-checkout", "artifact-poisoning"])
) and
(
sink instanceof EnvVarInjectionFromFileReadSink or
madSink(sink, "envvar-injection")
)
)
)
}
}

/** Tracks flow of unsafe user input that is used to construct and evaluate an environment variable. */
Expand Down
10 changes: 10 additions & 0 deletions cpp/ql/src/Critical/OverflowDestination.ql
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ module OverflowDestinationConfig implements DataFlow::ConfigSig {
nodeIsBarrierEqualityCandidate(node, access, checkedVar)
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(FunctionCall fc | result = fc.getLocation() |
sourceSized(fc, sink.asIndirectConvertedExpr())
)
}
}

module OverflowDestination = TaintTracking::Global<OverflowDestinationConfig>;
Expand Down
13 changes: 13 additions & 0 deletions cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ module NonConstFlowConfig implements DataFlow::ConfigSig {
cannotContainString(t)
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) { none() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.getLocation()
or
exists(FormattingFunctionCall call, Expr formatString | result = call.getLocation() |
isSinkImpl(sink, formatString) and
call.getArgument(call.getFormatParameterIndex()) = formatString
)
}
}

module NonConstFlow = TaintTracking::Global<NonConstFlowConfig>;
Expand Down
12 changes: 12 additions & 0 deletions cpp/ql/src/Likely Bugs/Leap Year/LeapYear.qll
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ private module LeapYearCheckConfig implements DataFlow::ConfigSig {
predicate isSink(DataFlow::Node sink) {
exists(ChecksForLeapYearFunctionCall fc | sink.asExpr() = fc.getAnArgument())
}

predicate observeDiffInformedIncrementalMode() {
none() // only used negatively in UncheckedLeapYearAfterYearModification.ql
}
}

module LeapYearCheckFlow = DataFlow::Global<LeapYearCheckConfig>;
Expand Down Expand Up @@ -285,6 +289,14 @@ private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::C
aexpr.getLValue() = fa
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) {
result = source.asExpr().getLocation()
}

Location getASelectedSinkLocation(DataFlow::Node sink) { result = sink.asExpr().getLocation() }
}

module PossibleYearArithmeticOperationCheckFlow =
Expand Down
4 changes: 4 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-020/ExternalAPIsSpecific.qll
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ private module UntrustedDataToExternalApiConfig implements DataFlow::ConfigSig {
}

predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }

predicate observeDiffInformedIncrementalMode() {
none() // risky since used in library: normal use in UntrustedDataToExternalApi.ql; used via ExternalApiUsedWithUntrustedData (no location) in CountUntrustedDataToExternalAPI.ql
}
}

module UntrustedDataToExternalApiFlow = TaintTracking::Global<UntrustedDataToExternalApiConfig>;
4 changes: 4 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIsSpecific.qll
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ private module UntrustedDataToExternalApiConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }

predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }

predicate observeDiffInformedIncrementalMode() {
none() // risky since used in library: normal use in IRUntrustedDataToExternalApi.ql; used via ExternalApiUsedWithUntrustedData (no location) in IRCountUntrustedDataToExternalAPI.ql
}
}

module UntrustedDataToExternalApiFlow = TaintTracking::Global<UntrustedDataToExternalApiConfig>;
6 changes: 6 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-022/TaintedPath.ql
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ module TaintedPathConfig implements DataFlow::ConfigSig {
// make sinks barriers so that we only report the closest instance
isSink(node)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
result = sink.asIndirectArgument().getLocation()
}
}

module TaintedPath = TaintTracking::Global<TaintedPathConfig>;
Expand Down
11 changes: 11 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-078/ExecTainted.ql
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ module ExecTaintConfig implements DataFlow::StateConfigSig {
predicate isBarrierOut(DataFlow::Node node) {
isSink(node, _) // Prevent duplicates along a call chain, since `shellCommand` will include wrappers
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(DataFlow::Node concatResult, Expr command, ExecState state |
result = [concatResult.getLocation(), command.getLocation()] and
isSink(sink, state) and
isSinkImpl(sink, command, _) and
concatResult = state.getOutgoingNode()
)
}
}

module ExecTaint = TaintTracking::GlobalWithState<ExecTaintConfig>;
Expand Down
6 changes: 6 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-079/CgiXss.ql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ module Config implements DataFlow::ConfigSig {
or
node.asCertainDefinition().getUnspecifiedType() instanceof ArithmeticType
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSourceLocation(DataFlow::Node source) {
exists(QueryString query | result = query.getLocation() | query = source.asIndirectExpr())
}
}

module Flow = TaintTracking::Global<Config>;
Expand Down
6 changes: 6 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ module SqlTaintedConfig implements DataFlow::ConfigSig {
sql.barrierSqlArgument(input, _)
)
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(Expr taintedArg | result = taintedArg.getLocation() | taintedArg = asSinkExpr(sink))
}
}

module SqlTainted = TaintTracking::Global<SqlTaintedConfig>;
Expand Down
6 changes: 6 additions & 0 deletions cpp/ql/src/Security/CWE/CWE-120/UnboundedWrite.ql
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ module Config implements DataFlow::ConfigSig {
// Block flow if the node is guarded by any <, <= or = operations.
node = DataFlow::BarrierGuard<lessThanOrEqual/3>::getABarrierNode()
}

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(BufferWrite bw | result = bw.getLocation() | isSink(sink, bw, _))
}
}

module Flow = TaintTracking::Global<Config>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ private module Config implements DataFlow::ConfigSig {
}

predicate isSink(DataFlow::Node sink) { isSink(sink, _) }

predicate observeDiffInformedIncrementalMode() { any() }

Location getASelectedSinkLocation(DataFlow::Node sink) {
exists(VariableAccess va | result = va.getLocation() | isSink(sink, va))
}
}

module Flow = TaintTracking::Global<Config>;
Expand Down
Loading
Loading