Skip to content

Commit c1d2fe9

Browse files
geoffw0Copilot
andcommitted
unified: Clarify format string port limitations and refresh help reference
Record the remaining printf models and extraction prerequisite for custom variadic-call heuristics. Use the verified canonical OWASP reference and clarify the predicate-injection negative case. Help XML and samples validate, and all five affected query and model tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 842f2c4 commit c1d2fe9

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎unified/ql/src/queries/security/CWE-134/UncontrolledFormatString.qhelp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ an untrusted source. This also helps to prevent errors where the format argument
3131

3232
<li>
3333
OWASP:
34-
<a href="https://owasp.org/www-community/attacks/Format_string_attack">Format string attack</a>.
34+
<a href="https://community.owasp.org/attacks/Format_string_attack">Format string attack</a>.
3535
</li>
3636

3737
</references>

‎unified/ql/src/queries/security/CWE-134/UncontrolledFormatString.ql‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ module TaintedFormatConfig implements DataFlow::ConfigSig {
1919
predicate isSource(DataFlow::Node node) { Models::isSource(node, _) }
2020

2121
predicate isSink(DataFlow::Node node) {
22+
// TODO: Model the remaining printf variants from original Swift's StringFormat.qll.
2223
// TODO: Port the variadic-call heuristic from original Swift's
23-
// UncontrolledFormatStringExtensions.qll, excluding predicate-injection sinks.
24+
// UncontrolledFormatStringExtensions.qll once variadic parameters are extracted,
25+
// excluding predicate-injection sinks.
2426
Models::isSink(node, "format-string")
2527
}
2628

‎unified/ql/test/query-tests/security/CWE-134/UncontrolledFormatString/UncontrolledFormatString.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func tests() throws {
134134
s.appendFormat(NSString(string: "%s"), "abc") // GOOD: not tainted
135135
s.appendFormat(NSString(string: tainted), "abc") // $ Alert
136136

137-
_ = NSPredicate(format: tainted) // GOOD: this should be flagged by `swift/predicate-injection`, not `swift/uncontrolled-format-string`
137+
_ = NSPredicate(format: tainted) // GOOD: predicate injection, not printf-style formatting
138138

139139
tainted.withCString({
140140
cstr in

0 commit comments

Comments
 (0)