Skip to content

Commit 1fb7f08

Browse files
bdrodesMathiasVP
andauthored
Update cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql
Co-authored-by: Mathias Vorreiter Pedersen <[email protected]>
1 parent 9e50fc6 commit 1fb7f08

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
* to a mismatch between the number of arguments defined by the 'format' and the number
55
* of arguments actually passed to the function. If the format string ultimately stems
66
* from an untrusted source, this can be used for exploits.
7-
* This query finds all sources leading to a format string that cannot be verified to be literal.
8-
* Even if the format string type is `const char*` it is still considered non-constant if the
9-
* value is not a string literal. For example, a parameter to a function that is never observed to be called
10-
* that takes in a `const char*` and uses it as a format string, there is no way to verify the originating
11-
* value was a string literal. This is especially problematic with conversion of c strings to char *,
12-
* via `c_str()`, which returns a `const char*`, regardless if the original string was a string literal or not.
13-
* The query does not consider uninitialized variables as non-constant sources. Uninitialized
14-
* variables are a separate vulnerability concern and should be addressed by a separate query.
7+
* This query finds format strings coming from non-literal sources. Note that format strings of
8+
* type `const char*` it is still considered non-constant if the value is not coming from a string
9+
* literal. For example, for a parameter with type `const char*` of an exported function that is
10+
* used as a format string, there is no way to ensure the originating value was a string literal.
1511
* @kind problem
1612
* @problem.severity recommendation
1713
* @security-severity 9.3

0 commit comments

Comments
 (0)