Lua: Add Lua as a new CodeQL language#22223
Open
prankster009 wants to merge 1 commit into
Open
Conversation
Add a self-contained extractor, bytecode schema, QL libraries, query packs, security queries, documentation, and tests for Lua 5.1 analysis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds Lua 5.1 analysis as a new, self-contained language capability in CodeQL.
The work is derived from the Lua analysis component of our security research, FirmCross: Detecting Taint-style Vulnerabilities in Modern C-Lua Hybrid Web Services of Linux-based Firmware. That analysis was validated on real-world Lua services and helped identify 610 previously unknown vulnerabilities.
This PR ports that Lua analysis capability into CodeQL's extractor, database schema, QL libraries, queries, and test infrastructure. The resulting implementation is self-contained in this repository and does not depend on external analysis projects at runtime.
Analysis capabilities
The implementation analyzes compiled Lua 5.1 bytecode:
.luacfiles can be analyzed directly..luafiles withluac5.1while preserving their relative directory layout..luafiles are retained as source inventory; semantic and taint analysis is derived from bytecode facts.The analysis currently provides:
The analysis core is mature. The initial public queries use CodeQL's experimental query lifecycle while the new language is being adopted upstream.
Review guidance
The implementation is organized into the following review areas:
The complex integration test contains 46 Lua source files and 46 corresponding stripped Lua 5.1 bytecode files in a realistic module layout. Its compact oracle verifies artifact acceptance, diagnostics, module resolution, interprocedural flow, cross-module taint flow, active findings, and sanitizer behavior.
Validation
Run the extractor unit tests: