CodeQL 2.12.0 (2023-01-10)¶
This is an overview of changes in the CodeQL CLI and relevant CodeQL query and library packs. For additional updates on changes to the CodeQL code scanning experience, check out the code scanning section on the GitHub blog, relevant GitHub Changelog updates, changes in the CodeQL extension for Visual Studio Code, and the CodeQL Action changelog.
Security Coverage¶
CodeQL 2.12.0 runs a total of 365 security queries when configured with the Default suite (covering 150 CWE). The Extended suite enables an additional 116 queries (covering 32 more CWE). 8 security queries have been added with this release.
CodeQL CLI¶
Breaking Changes¶
- The
--[no-]count-lines
option tocodeql database create
and related commands that was deprecated in 2.11.1 has been removed. Users of this option should instead pass--[no-]calculate-baseline
.
Bug Fixes¶
- Fixed a bug where the
codeql pack install
command would fail if a CodeQL configuration file is used and the--additional-packs
option is specified.
New Features¶
Query packs created by
codeql pack create
,codeql pack bundle
, andcodeql pack release
now contain precompiled queries in a new format that aims to be compatible with future (and, to a certain extent, past) releases of the CodeQL CLI. Previously the precompiled queries were in a format specific to each CLI release, and all other releases would need to re-compile queries.Published packs contain precompiled queries in files with a
.qlx
extension located next to each query’s.ql
source file. In case of differences between the.ql
and.qlx
files, the.qlx
file takes priority when evaluating queries from the command line, so if you need to modify a published pack, be sure to delete the.qlx
files first.A new
--precompile
flag tocodeql query compile
can be used to construct*.qlx
file explicitly, but in all usual cases it should be enough to rely oncodeql pack create
doing the right thing.The
codeql database init
command now accepts a PAT that allows you to download queries from external, private repositories when using the--codescanning-config <config-file>
option. For example, you can specify the following queries block in the config file, which will checkout the main branch of thecodeql-test/my-private-repository
repository and evaluate any queries found in that repository:queries: - codeql-test/my-private-repository@main
If the repository is private, you can add a
--external-repository-token-stdin
option and supply a PAT with appropriate permissions via standard input. For more information on queries and external repositories in Code Scanning, see Using queries in QL packs.The baseline information produced by
codeql database init
andcodeql database create
now accounts forpaths
andpaths-ignore
configuration.In the VS Code extension, recursive calls will be marked with inlay hints. These can be disabled with the global inlay hints setting (
editor.inlayHints.enabled
). If you just want to disable them for codeql the settings can be scoped to just codeql files (language id isql
). See Language Specific Editor Settings in the VS Code documentation for more information.The CLI now gives a more helpful error message when asked to run queries on a database that has not been finalized.
Query Packs¶
Bug Fixes¶
C#¶
- Fixes a bug where the Owin.qll framework library will look for “URI” instead of “Uri” in the OwinRequest class.
Minor Analysis Improvements¶
C/C++¶
- The
AlertSuppression.ql
query has been updated to support the new// codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy// lgtm
and// lgtm[query-id]
comments can now also be placed on the line before an alert. - The
cpp/missing-check-scanf
query no longer reports the free’ing ofscanf
output variables as potential reads.
C#¶
- The
AlertSuppression.ql
query has been updated to support the new// codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy// lgtm
and// lgtm[query-id]
comments can now also be placed on the line before an alert. - The extensible predicates for Models as Data have been renamed (the
ext
prefix has been removed). As an example,extSummaryModel
has been renamed tosummaryModel
.
Golang¶
- The
AlertSuppression.ql
query has been updated to support the new// codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy// lgtm
and// lgtm[query-id]
comments can now also be placed on the line before an alert.
Java/Kotlin¶
- The
AlertSuppression.ql
query has been updated to support the new// codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy// lgtm
and// lgtm[query-id]
comments can now also be placed on the line before an alert. - The extensible predicates for Models as Data have been renamed (the
ext
prefix has been removed). As an example,extSummaryModel
has been renamed tosummaryModel
. - The query
java/misnamed-type
is now enabled for Kotlin. - The query
java/non-serializable-field
is now enabled for Kotlin. - Fixed an issue in the query
java/android/implicit-pendingintents
by which an implicit Pending Intent marked as immutable was not correctly recognized as such. - The query
java/maven/non-https-url
no longer alerts about disabled repositories.
JavaScript/TypeScript¶
- The
AlertSuppression.ql
query has been updated to support the new// codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy// lgtm
and// lgtm[query-id]
comments can now also be placed on the line before an alert.
Python¶
- The
analysis/AlertSuppression.ql
query has moved to the root folder. Users that refer to this query by path should update their configurations. The query has been updated to support the new# codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy# lgtm
and# lgtm[query-id]
comments can now also be placed on the line before an alert. - Bumped the minimum keysize we consider secure for elliptic curve cryptography from 224 to 256 bits, following current best practices. This might effect results from the Use of weak cryptographic key (
py/weak-crypto-key
) query. - Added modeling of
getpass.getpass
as a source of passwords, which will be an additional source forpy/clear-text-logging-sensitive-data
,py/clear-text-storage-sensitive-data
, andpy/weak-sensitive-data-hashing
.
Ruby¶
- The
AlertSuppression.ql
query has been updated to support the new# codeql[query-id]
supression comments. These comments can be used to suppress an alert and must be placed on a blank line before the alert. In addition the legacy# lgtm
and# lgtm[query-id]
comments can now also be placed on the line before an alert. - Extended the
rb/kernel-open
query with following sinks:IO.write
,IO.binread
,IO.binwrite
,IO.foreach
,IO.readlines
, andURI.open
.
New Queries¶
C#¶
- Added a new query,
csharp/telemetry/supported-external-api
, to detect supported 3rd party APIs used in a codebase.
Java/Kotlin¶
- Added a new query,
java/summary/generated-vs-manual-coverage
, to expose metrics for the number of API endpoints covered by generated versus manual MaD models. - Added a new query,
java/telemetry/supported-external-api
, to detect supported 3rd party APIs used in a codebase. - Added a new query,
java/android/missing-certificate-pinning
, to find network calls where certificate pinning is not implemented. - Added a new query,
java/android-webview-addjavascriptinterface
, to detect the use ofaddJavascriptInterface
, which can lead to cross-site scripting. - Added a new query,
java/android-websettings-file-access
, to detect configurations that enable file system access in Android WebViews. - Added a new query,
java/android-websettings-javascript-enabled
, to detect if JavaScript execution is enabled in an Android WebView. - The query
java/regex-injection
has been promoted from experimental to the main query pack. Its results will now appear by default. This query was originally submitted as an experimental query by @edvraa.
Ruby¶
- Added a new query,
rb/stack-trace-exposure
, to detect exposure of stack-traces to users via HTTP responses.
Language Libraries¶
Bug Fixes¶
Golang¶
- Fixed an issue in the taint tracking analysis where implicit reads were not allowed by default in sinks or additional taint steps that used flow states.
Java/Kotlin¶
- We now correctly handle empty block comments, like
/**/
. Previously these could be mistaken for Javadoc comments and led to attribution of Javadoc tags to the wrong declaration.
Python¶
except*
is now supported.- The result of
Try.getAHandler
andTry.getHandler(<index>)
is no longer of typeExceptStmt
, as handlers may also beExceptGroupStmt
s (After Python 3.11 introduced PEP 654). Instead, it is of the new typeExceptionHandler
of whichExceptStmt
andExceptGroupStmt
are subtypes. To support selecting only one type of handler,Try.getANormalHandler
andTry.getAGroupHandler
have been added. Existing uses ofTry.getAHandler
for which it is important to select only normal handlers, will need to be updated toTry.getANormalHandler
.
Breaking Changes¶
C/C++¶
- The predicates in the
MustFlow::Configuration
class used by theMustFlow
library (semmle.code.cpp.ir.dataflow.MustFlow
) have changed to be defined directly in terms of the C++ IR instead of IR dataflow nodes.
Golang¶
- The signature of
allowImplicitRead
onDataFlow::Configuration
andTaintTracking::Configuration
has changed fromallowImplicitRead(DataFlow::Node node, DataFlow::Content c)
toallowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c)
.
Major Analysis Improvements¶
Python¶
- The PAM authorization bypass due to incorrect usage (
py/pam-auth-bypass
) query has been converted to a taint-tracking query, resulting in significantly fewer false positives.
Ruby¶
Flow through
initialize
constructors is now taken into account. For example, inclass C def initialize(x) @field = x end end C.new(y)
there will be flow from
y
to the field@field
on the constructedC
object.
Minor Analysis Improvements¶
C/C++¶
- The
ArgvSource
flow source now uses the second parameter ofmain
as its source instead of the uses of this parameter. - The
ArgvSource
flow source has been generalized to handle cases where the argument vector ofmain
is not namedargv
. - The
getaddrinfo
function is now recognized as a flow source. - The
secure_getenv
and_wgetenv
functions are now recognized as local flow sources. - The
scanf
andfscanf
functions and their variants are now recognized as flow sources. - Deleted the deprecated
getName
andgetShortName
predicates from theFolder
class.
C#¶
- C# 11: Added support for list- and slice patterns in the extractor.
- Deleted the deprecated
getNameWithoutBrackets
predicate from theValueOrRefType
class inType.qll
. Element::hasQualifiedName/1
has been deprecated. UsehasQualifiedName/2
orhasQualifiedName/3
instead.- Added TCP/UDP sockets as taint sources.
Golang¶
- The predicate
getNumParameter
onFuncTypeExpr
has been changed to actually give the number of parameters. It previously gave the number of parameter declarations.getNumParameterDecl
has been introduced to preserve this functionality. - The definition of
mayHaveSideEffects
forReturnStmt
was incorrect when more than one expression was being returned. Such return statements were effectively considered to never have side effects. This has now been fixed. In rare circumstancesglobalValueNumber
may have incorrectly treated two values as the same when they were in fact distinct. - Queries that care about SQL, such as
go/sql-injection
, now recognise SQL-consuming functions belonging to thegorqlite
andGoFrame
packages. rsync
has been added to the list of commands which may evaluate its parameters as a shell command.
Java/Kotlin¶
- Added more dataflow models for frequently-used JDK APIs.
- The extraction of Kotlin extension methods has been improved when default parameter values are present. The dispatch and extension receiver parameters are extracted in the correct order. The
ExtensionMethod::getExtensionReceiverParameterIndex
predicate has been introduced to facilitate getting the correct extension parameter index. - The query
java/insecure-cookie
now uses global dataflow to track secure cookies being set to the HTTP response object. - The library
PathSanitizer.qll
has been improved to detect more path validation patterns in Kotlin. - Models as Data models for Java are defined as data extensions instead of being inlined in the code. New models should be added in the
lib/ext
folder. - Added a taint model for the method
java.nio.file.Path.getParent
. - Fixed a problem in the taint model for the method
java.nio.file.Paths.get
. - Deleted the deprecated
LocalClassDeclStmtNode
andLocalClassDeclStmt
classes fromPrintAst.qll
andStatement.qll
respectively. - Deleted the deprecated
getLocalClass
predicate fromLocalTypeDeclStmt
, and the deprecatedgetLocalClassDeclStmt
predicate fromLocalClassOrInterface
. - Added support for Android Manifest
<activity-aliases>
elements in data flow sources.
JavaScript/TypeScript¶
- Deleted the deprecated
Instance
class from theVue
module. - Deleted the deprecated
VHtmlSourceWrite
class fromDomBasedXssQuery.qll
. - Deleted all the deprecated
[QueryName].qll
files from thejavascript/ql/lib/semmle/javascript/security/dataflow
folder, use the corresponding[QueryName]Query.qll
files instead. - The ReDoS libraries in
semmle.code.javascript.security.regexp
has been moved to a shared pack inside theshared/
folder, and the previous location has been deprecated.
Python¶
- Added
subprocess.getoutput
andsubprocess.getoutputstatus
as new command injection sinks for the StdLib. - The data-flow library has been rewritten to no longer rely on the points-to analysis in order to resolve references to modules. Improvements in the module resolution can lead to more results.
- Deleted the deprecated
importNode
predicate from theDataFlowUtil.qll
file. - Deleted the deprecated features from
PEP249.qll
that were not inside thePEP249
module. - Deleted the deprecated
werkzeug
from theWerkzeug
module inWerkzeug.qll
. - Deleted the deprecated
methodResult
predicate fromPEP249::Cursor
.
Ruby¶
- Calls to
Kernel.load
,Kernel.require
,Kernel.autoload
are now modeled as sinks for path injection. - Calls to
mail
andinbound_mail
inActionMailbox
controllers are now considered sources of remote input. - Calls to
GlobalID::Locator.locate
and its variants are now recognized as instances ofOrmInstantiation
. - Data flow through the
ActiveSupport
extensionsEnumerable#index_with
,Enumerable#pick
,Enumerable#pluck
andEnumerable#sole
are now modeled. - When resolving a method call, the analysis now also searches in sub-classes of the receiver’s type.
- Taint flow is now tracked through many common JSON parsing and generation methods.
- The ReDoS libraries in
codeql.ruby.security.regexp
has been moved to a shared pack inside theshared/
folder, and the previous location has been deprecated. - String literals and arrays of string literals in case expression patterns are now recognised as barrier guards.
Deprecated APIs¶
C/C++¶
- Deprecated
semmle.code.cpp.ir.dataflow.DefaultTaintTracking
. Usesemmle.code.cpp.ir.dataflow.TaintTracking
. - Deprecated
semmle.code.cpp.security.TaintTrackingImpl
. Usesemmle.code.cpp.ir.dataflow.TaintTracking
. - Deprecated
semmle.code.cpp.valuenumbering.GlobalValueNumberingImpl
. Usesemmle.code.cpp.valuenumbering.GlobalValueNumbering
, which exposes the same API.
Golang¶
- The
BarrierGuard
class has been deprecated. Such barriers and sanitizers can now instead be created using the newBarrierGuard
parameterized module.