CodeQL 2.17.0 (2024-04-04)¶
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.17.0 runs a total of 410 security queries when configured with the Default suite (covering 160 CWE). The Extended suite enables an additional 130 queries (covering 34 more CWE).
CodeQL CLI¶
Deprecations¶
The
--[no-]analysis-summary-v2and--[no-]new-analysis-summaryoptions that were used to enable (or disable) improved summary information printed at the end of acodeql database analyzeinvocation are no longer supported. Improved summary information is now enabled for all invocations.Support for overwriting default CodeQL SARIF run properties using the
--sarif-run-propertycommand line option has been removed. This removes the ability to overwrite thesemmle.formatSpecifier,metricResults, andcodeqlConfigSummaryproperties in the SARIF run file.
Improvements¶
TRAP import (a part of
codeql database createandcodeql database finalize) now performs better in low-memory situations. (Put another way, it now needs less RAM to achieve the same performance as before.)The worst-case performance of transitive closure computation (using the
+or*postfix operators or thefastTChigher-order primitive in QL) has been greatly improved.
Miscellaneous¶
The build of Eclipse Temurin OpenJDK that is used to run the CodeQL CLI has been updated to version 21.0.2.
Query Packs¶
Major Analysis Improvements¶
C#¶
The
Storedvariants of some queries (cs/stored-command-line-injection,cs/web/stored-xss,cs/stored-ldap-injection,cs/xml/stored-xpath-injection,cs/second-order-sql-injection) have been removed. If you were using these queries, their results can be restored by enabling thefileanddatabasethreat models in your threat model configuration.
Java/Kotlin¶
The
java/missing-case-in-switchquery now gives only a single alert for each switch statement, giving some examples of the missing cases as well as a count of how many are missing.
Minor Analysis Improvements¶
C/C++¶
The “Missing return-value check for a ‘scanf’-like function” query (
cpp/missing-check-scanf) has been converted to apath-problemquery.The “Potentially uninitialized local variable” query (
cpp/uninitialized-local) has been converted to apath-problemquery.Added models for
GLiballocation and deallocation functions.
C#¶
The alert message of
cs/wrong-compareto-signaturehas been changed to remove unnecessary element references.Data flow queries that track flow from local flow sources now use the current threat model configuration instead. This may lead to changes in the produced alerts if the threat model configuration only uses remote flow sources. The changed queries are
cs/code-injection,cs/resource-injection,cs/sql-injection, andcs/uncontrolled-format-string.
Golang¶
The query
go/hardcoded-credentialsno longer discards string literals based on “weak password” heuristics.The query
go/sql-injectionnow recognizes more sinks in the packagegithub.com/Masterminds/squirrel.
Java/Kotlin¶
Variables named
tokenImageare no longer sources for thejava/sensitive-logquery. This is because this variable name is used in parsing code generated by JavaCC, so it causes a large number of false positive alerts.Added sanitizers for relative URLs,
List.contains(), and checking the host of a URI to thejava/ssrfandjava/unvalidated-url-redirectionqueries.
JavaScript/TypeScript¶
The call graph has been improved, leading to more alerts for data flow based queries.
New Queries¶
C/C++¶
Added a new query,
cpp/type-confusion, to detect casts to invalid types.
Golang¶
The query “Slice memory allocation with excessive size value” (
go/uncontrolled-allocation-size) 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 @Malayke.
Java/Kotlin¶
The query
java/unsafe-url-forward-dispatch-loadhas been promoted from experimental to the main query pack asjava/unvalidated-url-forward. Its results will now appear by default. This query was originally submitted as an experimental query by @haby0 and by @luchua-bc.
Query Metadata Changes¶
C/C++¶
@precision mediummetadata was added to thecpp/boost/tls-settings-misconfigurationandcpp/boost/use-of-deprecated-hardcoded-security-protocolqueries, and these queries are now included in the security-extended suite. The@namemetadata of these queries were also updated.
JavaScript/TypeScript¶
The
@precisionof thejs/unsafe-external-linkhas been reduced tolowto reflect the fact that modern browsers do not expose the opening window for such links. This mitigates the potential security risk of having a link withtarget="_blank".
Language Libraries¶
Breaking Changes¶
C#¶
The CIL extractor has been deleted and the corresponding extractor option
cilhas been removed. It is no longer possible to do CIL extraction.The QL library C# classes no longer extend their corresponding
DotNetclasses. Furthermore, CIL related data flow functionality has been deleted and allDotNetandCILrelated classes have been deprecated. This effectively means that it no longer has any effect to enable CIL extraction.
Java/Kotlin¶
The Java extractor no longer supports the
ODASA_SNAPSHOTlegacy environment variable.
Major Analysis Improvements¶
JavaScript/TypeScript¶
Added support for TypeScript 5.4.
Swift¶
Upgraded to Swift 5.10
New AST node is extracted:
ThenStmt
Minor Analysis Improvements¶
C/C++¶
Added destructors for temporary objects with extended lifetimes to the intermediate representation.
C#¶
Added new source models for the
Dapperpackage. These models can be enabled by enabling thedatabasethreat model.Additional models have been added for
System.IO. These are primarily source models with thefilethreat model, and summaries related to reading from a file or stream.Support for C# 12 / .NET8.
Added the
windows-registrysource kind and threat model to represent values which come from the registry on Windows.The models for
System.Net.Http.HttpRequestMessagehave been modified to better model the flow of tainted URIs.The .NET standard libraries APIs for accessing command line arguments and environment variables have been modeled using the
commandargsandenvironmentthreat models.The
cs/assembly-path-injectionquery has been modified so that it’s sources rely onThreatModelFlowSource. In order to restore results from command line arguments, you should enable thecommandargsthreat model.The models for
System.IO.TextReaderhave been modified to better model the flow of tainted text from aTextReader.
Golang¶
The
CODEQL_EXTRACTOR_GO_FAST_PACKAGE_INFOoption, which speeds up retrieval of dependency information, is now on by default. This was originally an external contribution by @xhd2015.Added dataflow sources for the package
gopkg.in/macaron.v1.
Java/Kotlin¶
Increased the precision of some dataflow models of the class
java.net.URLby distinguishing the parts of a URL.The Java extractor and QL libraries now support Java 22, including support for anonymous variables, lambda parameters and patterns.
Pattern cases with multiple patterns and that fall through to or from other pattern cases are now supported. The
PatternCaseclass gains the newgetPatternAtIndexandgetAPatternpredicates, and deprecatesgetPattern.Added a
path-injectionsink for theopenmethods of theandroid.os.ParcelFileDescriptorclass.
Ruby¶
Data flow is now tracked through
ActiveRecordscopes.Modeled instances of
ActionDispatch::Http::UploadedFilethat can be obtained from element reads ofActionController::Parameters, with calls tooriginal_filename,content_type, andreadnow propagating taint from their receiver.The second argument,
subquery_name, of theActiveRecord::QueryMethods::frommethod, is now recognized as an sql injection sink.Calls to
Typhoeus::Request.neware now considered as instances of theHttp::Client::Requestconcept, with the response body being treated as a remote flow source.New command injection sinks have been added, including
Process.spawn,Process.exec,Terrapin::CommandLineand theopen4gem.
New Features¶
C/C++¶
Added a
TaintInheritingContentclass that can be extended to model taint flowing from a qualifier to a field.Added a predicate
GuardCondition.comparesEq/4to query whether an expression is compared to a constant.Added a predicate
GuardCondition.ensuresEq/4to query whether a basic block is guarded by an expression being equal to a constant.Added a predicate
GuardCondition.comparesLt/4to query whether an expression is compared to a constant.Added a predicate
GuardCondition.ensuresLt/4to query whether a basic block is guarded by an expression being less than a constant.Added a predicate
GuardCondition.valueControlsto query whether a basic block is guarded by a particularcaseof aswitchstatement.