CodeQL 2.21.0 (2025-04-03)¶
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.21.0 runs a total of 452 security queries when configured with the Default suite (covering 168 CWE). The Extended suite enables an additional 136 queries (covering 35 more CWE). 1 security query has been added with this release.
CodeQL CLI¶
Miscellaneous¶
On macOS the
CODEQL_TRACER_RELOCATION_EXCLUDEenvironment variable can now be used to exclude certain paths from the tracer relocation and tracing process. This environment variable accepts newline-separated regex patterns of binaries to be excluded.
Query Packs¶
Bug Fixes¶
JavaScript/TypeScript¶
Fixed a bug, first introduced in
2.20.3, that would preventv-htmlattributes in Vue files from being flagged by thejs/xssquery. The original behaviour has been restored and thev-htmlattribute is once again functioning as a sink for thejs/xssquery.Fixed a bug that would in rare cases cause some regexp-based checks to be seen as generic taint sanitisers, even though the underlying regexp is not restrictive enough. The regexps are now analysed more precisely, and unrestrictive regexp checks will no longer block taint flow.
Fixed a recently-introduced bug that caused
js/server-side-unvalidated-url-redirectionto ignore valid hostname checks and report spurious alerts after such a check. The original behaviour has been restored.
Python¶
The
py/unused-global-variablenow no longer flags variables that are only used in forward references (e.g. theFooindef bar(x: "Foo"): ...).
GitHub Actions¶
Fixed typos in the query and alert titles for the queries
actions/envpath-injection/critical,actions/envpath-injection/medium,actions/envvar-injection/critical, andactions/envvar-injection/medium.
Major Analysis Improvements¶
Java/Kotlin¶
Updated the
java/unreleased-lockquery so that it no longer report alerts in cases where a boolean variable is used to track lock state.
Minor Analysis Improvements¶
C/C++¶
Fixed a bug in the models for Microsoft’s Active Template Library (ATL).
The query “Use of basic integral type” (
cpp/jpl-c/basic-int-types) no longer produces alerts for the standard fixed width integer types (int8_t,uint8_t, etc.), and the_Boolandbooltypes.
C#¶
Improved dependency resolution in
build-mode: noneextraction to handle failingdotnet restoreprocesses that managed to download a subset of the dependencies before the failure.Increase query precision for
cs/useless-gethashcode-callby not flagging calls toGetHashCodeonuint,longandulong.Increase query precision for
cs/constant-conditionand allow the use of discards in switch/case statements and also take the condition (if any) into account.The
cs/local-not-disposedquery no longer flags un-disposed tasks as this is often not needed (explained here).Increase query precision for
cs/useless-assignment-to-localandcs/constant-conditionwhen unknown types are involved (mostly relevant forbuild-mode: nonedatabases).Don’t consider an if-statement to be useless in
cs/useless-if-statementif there is at least a comment.
Golang¶
False positives in “Log entries created from user input” (
go/log-injection) and “Clear-text logging of sensitive information” (go/clear-text-logging) which involved the verb%Tin a format specifier have been fixed. As a result, some users may also see more alerts from the “Use of constantstatevalue in OAuth 2.0 URL” (go/constant-oauth2-state) query.
Java/Kotlin¶
Fixed a false positive in “Time-of-check time-of-use race condition” (
java/toctou-race-condition) where a field of a non-static class was not considered always-locked if it was accessed in a constructor.Overrides of
BroadcastReceiver::onReceivewith no statements in their body are no longer considered unverified by thejava/improper-intent-verificationquery. This will reduce false positives fromonReceivemethods which do not perform any actions.
Python¶
The
py/special-method-wrong-signaturehas been modernized and rewritten to no longer rely on outdated APIs. Moreover, the query no longer flags cases where a default value is never used, as these alerts were rarely useful.
New Queries¶
C#¶
Added a new query,
csharp/path-combine, to recommend against thePath.Combinemethod due to it silently discarding its earlier parameters if later parameters are rooted.
Java/Kotlin¶
Added a new quality query,
java/empty-method, to detect empty methods.The query
java/spring-boot-exposed-actuatorshas been promoted from experimental to the main query pack. Its results will now appear by default, and the query itself will be removed from the CodeQL Community Packs. This query was originally submitted as an experimental query by @ggolawski.
Swift¶
Added a new summary query counting the total number of extracted AST nodes.
Language Libraries¶
Bug Fixes¶
Java/Kotlin¶
In
build-mode: nonewhere the project has a Gradle build system, database creation no longer attempts to download some non-existent jar files relating to non-jar Maven artifacts, such as BOMs. This was harmless, but saves some time and reduces spurious warnings.Java extraction no longer freezes for a long time or times out when using libraries that feature expanding cyclic generic types. For example, this was known to occur when using some classes from the Blazebit Persistence library.
Java build-mode
noneno longer fails when a required version of Gradle cannot be downloaded using thegradle wrappercommand, such as due to a firewall. It will now attempt to use the system version of Gradle if present, or otherwise proceed without detailed dependency information.Java build-mode
noneno longer fails when a required version of Maven cannot be downloaded, such as due to a firewall. It will now attempt to use the system version of Maven if present, or otherwise proceed without detailed dependency information.Java build-mode
nonenow correctly uses Maven dependency information on Windows platforms.
Python¶
MatchLiteralPatterns such ascase None: ...are now never pruned from the extracted source code. This fixes some situations where code was wrongly identified as unreachable.
GitHub Actions¶
The query
actions/code-injection/mediumnow produces alerts for injection vulnerabilities onpull_requestevents.
Major Analysis Improvements¶
JavaScript/TypeScript¶
Added support for TypeScript 5.8.
Minor Analysis Improvements¶
C#¶
The models for
System.Urihave been modified to better model the flow of tainted URIs.Modeled parameter passing between Blazor parent and child components.
Golang¶
We no longer track taint into a
sync.Mapvia the key of a key-value pair, since we do not model any way in which keys can be read from async.Map.databasesource models have been added for v1 and v2 of thegithub.com/couchbase/gocbpackage.Added
databasesource models for thegithub.com/Masterminds/squirrelORM package.
Java/Kotlin¶
Java extraction is now able to download Maven 3.9.x if a Maven Enforcer Plugin configuration indicates it is necessary. Maven 3.8.x is still preferred if the enforcer-plugin configuration (if any) permits it.
Added a path injection sanitizer for calls to
java.lang.String.matches,java.lang.String.replace, andjava.lang.String.replaceAllthat make sure/,\,..are not in the path.
JavaScript/TypeScript¶
Added support for additional
fs-extramethods as sinks in path-injection queries.Added support for the newer version of
Hapiwith the@hapi/hapiimport andserverfunction.Improved modeling of the
node:fsmodule:await-ed calls toreadandreadFileare now supported.Added support for the
@sap/hana-client,@sap/hdbextandhdbpackages.Enhanced
axiossupport with new methods (postForm,putForm,patchForm,getUri,create) and added support forinterceptors.requestandinterceptors.response.Improved support for
gotpackage withOptions,paginate()andextend()Added support for the
ApolloServerclass from@apollo/serverand similar packages. In particular, the incoming data in a GraphQL resolver is now seen as a source of untrusted user input.Improved support for
superagentto handle the case where the package is directly called as a function, or via the.del()or.agent()method.Added support for the
underscore.stringpackage.Added additional flow step for
unescape()andescape().Added support for the
@tanstack/vue-querypackage.Added taint-steps for
unescape().Added support for the
@tanstack/angular-query-experimentalpackage.Improved support for the
@angular/common/httppackage, detecting outgoing HTTP requests in more cases.Improved the modeling of the
markdown-tablepackage to ensure it handles nested arrays properly.Added support for the
react-relaylibrary.
Python¶
Added the methods
getMinArgumentsandgetMaxArgumentsto theFunctionclass. These return the minimum and maximum positional arguments that the given function accepts.
New Features¶
C/C++¶
Added
Node.asUncertainDefinitionandNode.asCertainDefinitionto theDataFlow::Nodeclass for querying whether a definition overwrites the entire destination buffer.
JavaScript/TypeScript¶
Extraction now supports regular expressions with the
vflag, using the new operators:Intersection
&&Subtraction
--qquoted string