Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is CodeQL?

CodeQL is GitHub’s semantic code analysis engine. It compiles a codebase into a relational database and lets you query it for vulnerable patterns with a declarative language called QL.

Illustration for the cybersecurity term CodeQL
Home / Blog / Cybersecurity Terms / What Is CodeQL?
17 November 2026

What Is CodeQL?

What Is CodeQL?

CodeQL treats source code as data. Instead of matching text patterns, it compiles a codebase into a relational database that captures the syntax tree, the type information, and the control and data flow, then lets you ask questions of that database in QL, a declarative language in the Datalog family. A query that finds SQL injection is, quite literally, a query: find every path from a value controlled by a request to a method that executes a statement, where nothing on the path neutralises it.

The engine came from Semmle, a spin-out from the University of Oxford, which GitHub acquired in September 2019. It now powers GitHub code scanning.

Databases, Queries, and Taint Tracking

Analysis happens in two stages. First you build a database, which for compiled languages means observing a real build so that the extractor sees exactly what the compiler sees:

codeql database create db --language=java --command="mvn -B clean package -DskipTests"
codeql database analyze db codeql/java-queries --format=sarif-latest --output=results.sarif

Then you run queries against it. The queries that matter for security are mostly taint-tracking queries, built from three sets: sources (where untrusted data enters), sinks (where it becomes dangerous), and sanitisers (what makes it safe again). Because the model is explicit, results come with a full path from entry point to sink, which is the single biggest difference when triaging findings. A reviewer can see the seven frames between the HTTP parameter and the command execution rather than guessing whether a flagged line is reachable at all.

Supported languages include C and C++, C#, Go, Java and Kotlin, JavaScript and TypeScript, Python, Ruby, Rust, Swift, and GitHub Actions workflows.

What It Catches That Pattern Matching Misses

Consider a value read from a request header, stored in a map, passed through two helper methods in different files, and finally concatenated into a shell command. A regular-expression scanner sees nothing suspicious at any single line. CodeQL follows the value across files and reports the path. The same mechanism finds insecure direct object references where an identifier reaches a data access layer without an ownership check, unsafe deserialisation, path traversal, and the kinds of command injection that hide behind a wrapper function.

GitHub Security Lab publishes the queries it uses to find real vulnerabilities in open-source projects, and reading those queries is the fastest way to understand what the language can express. Variant analysis is the other distinctive use: after a vulnerability is fixed, write a query describing the mistake and run it across every repository you own to find the other eleven places someone made it.

The Cost Side

Precision is expensive. A CodeQL database for a large C++ project can take an hour to build and several gigabytes to store, and the analysis adds more. That is acceptable on a nightly schedule or on the default branch, and painful on every pull request, which is why most teams run the full query suite on a schedule and a reduced suite on pull requests. Build observation is also a genuine operational constraint — if the continuous integration job cannot reproduce a working build, there is no database to analyse.

Licensing deserves attention. The CodeQL CLI and the standard query packs are free for analysis of open-source code, but use against private or commercial codebases requires GitHub Advanced Security. Unlike Semgrep, which pairs an open-source engine with a quick rule-writing syntax, CodeQL is deep but commercially gated and has a steeper learning curve for custom rules.

Using It Well

Static analysis of this kind pairs with dynamic testing rather than replacing it; the two find different classes of defect. At Privia Security, we combine automated analysis with manual review in our web application security services.

FAQ – Frequently Asked Questions

Is CodeQL Free?

It is free to analyse public repositories and open-source projects, both through GitHub code scanning and with the standalone CLI. Running it against private or commercial code requires a GitHub Advanced Security licence. That distinction catches teams out when they prototype on an open-source repository and then discover the production codebase needs a paid plan.

How Is CodeQL Different From Semgrep?

Semgrep matches patterns that look like the code you want to find and runs in seconds, which makes it excellent for custom organisational rules and fast pull request feedback. CodeQL builds a full semantic database and performs cross-file data flow analysis, which finds deeper issues and produces traceable paths, at the cost of longer build times and a harder query language. Many teams run both.

Can I Write My Own CodeQL Queries?

Yes, and for internal frameworks it is the main reason to use the tool. Queries are written in QL, imported into a query pack, and run with the CLI or added to a code scanning configuration. Expect a real learning curve: the language is declarative and unlike anything most developers have written. Start by modifying an existing query from the standard library rather than writing one from scratch.

Why Does CodeQL Need to Watch My Build?

For compiled languages the extractor runs alongside the compiler so it can see exactly which files were compiled, with which flags, and against which dependencies. Without that, generated code, conditional compilation, and dependency resolution would be guesswork. Interpreted languages such as Python, Ruby, and JavaScript do not need a build command, so their databases are much quicker to create.

Related Terms

You May Be Interested In These

What Is Diffie-Hellman Key Exchange?

Cybersecurity Terms

17 November 2026

What Is Diffie-Hellman Key Exchange?

Read More
What Is 3-D Secure?

Cybersecurity Terms

17 November 2026

What Is 3-D Secure?

Read More
What Is AI Agent Security?

Cybersecurity Terms

17 November 2026

What Is AI Agent Security?

Read More