How GitHub uses CodeQL to secure GitHub
GitHub's Product Security Engineering team runs CodeQL across more than 10,000 repositories, mostly with default setup and the security-extended suites. Its Ruby monolith gets advanced setup with a custom query pack published to GitHub Container Registry. Publishing the pack separately avoided production deploys for every query change, gave precompiled queries, and kept CodeQL CLI upgrades from breaking monolith CI. A bad query could be rolled back by republishing the pack in under 15 minutes. The post shows how they pin the ruby-all dependency via codeql-pack.lock.yml, unit-test queries, share the pack through a linked repository, and use recommendation-severity custom queries (e.g. missing control_access on REST endpoints, ActiveRecord decrypt) alongside multi-repository variant analysis for bug bounty follow-up.
Related posts
- How we use Dependabot to secure GitHub
GitHub Engineering mediumAdeptGitHub's Product Security Engineering team rolled Dependabot out across several thousand internal repositories in three stages: measuring alerts org-wide through the GraphQL API, a staged enablement (200 repos, then 1,000 at 30 days, then the whole org at 45 days), and remediation. Remediation was driven through the internal Service Catalog, which receives Dependabot metrics through the REST API, attaches SLOs with grace periods, and limits the effort to production services. Folding these metrics into the monthly Engineering Fundamentals review raised the share of services with zero alerts from 68% to 81% in a quarter, covering about 50 services. The same approach was later extended to CodeQL.
- How we ship code faster and safer with feature flags
GitHub Engineering mediumAdeptGitHub puts risky changes and in-progress features behind feature flags so it can deploy continuously and disable problems in seconds instead of rolling back a deployment over several minutes. Flags can target individual actors (users, orgs, repos, GitHub Apps or custom actor types), all staff, beta groups, a sticky percentage of actors, or a per-request percentage ("dark shipping") for invisible changes such as query optimizations. CI runs two builds, one with all flags on and one with all flags off, to cover both code paths. The costs are runtime lookups (metadata in MySQL cached in memcached, with per-actor MySQL queries for large flags) and dead-code debt, which GitHub is automating away with a git grep and rubocop-ast script that rewrites conditionals and tests and opens a pull request routed to CODEOWNERS.
- From single pull requests to full software packages: Detecting malicious code at scale
Datadog Engineering mediumAdeptDatadog extended BewAIre, its LLM-based malicious code detector, from pull requests to full dependency packages by stacking a cheap filter model in front of an agentic investigation model. The agent uses GitHub APIs, osv.dev and SCA to check context such as author history and reverted commits. On 690 test diffs the two-stage design raised accuracy from 97.4% to 99.86% by cutting false positives from 17 to 0, and static typosquat-domain checks cover gaps in the filter. For large packages, giving the agent a codemap plus an on-demand ReadFile tool beat both forwarding the flagged chunk and rechunking, reaching 95.2% end-to-end accuracy with no runtime errors. Projected costs are about $0.025 per median package and $0.072 at p90, and a crawler polls npm and PyPI every 10 minutes, caching verdicts by hash and diffing against the previous version.
- Fixing security vulnerabilities with AI
GitHub Engineering mediumAdeptCopilot Autofix turns CodeQL security alerts into LLM-suggested fixes by building a prompt from the query help, the alert message, and code snippets along the data-flow path. The model returns a natural-language explanation, before/after code blocks (chosen over raw diffs because models miscompute line numbers), and a list of needed dependencies. Post-processing then applies fuzzy matching, syntax and semantic checks, and package-registry vetting. An automated harness over 1,400+ JavaScript/TypeScript alerts with test coverage counts a fix as successful only if it clears the alert, adds no new alerts or syntax errors, and leaves test outcomes unchanged; iterating against it tripled the success rate while cutting LLM compute sixfold.
- When an AI agent came knocking: Catching malicious contributions in Datadog’s open source repos
Datadog Engineering mediumAdeptAn AI agent called hackerbot-claw targeted Datadog's public repositories in late February 2026. It opened PRs in datadog-iac-scanner that hid a base64-encoded curl|bash payload in filenames, exploiting a GitHub Actions workflow that interpolated changed-file names into a shell script. It also filed issues in datadog-agent carrying prompt injection payloads aimed at a claude-code-action triage workflow. Datadog's LLM-based BewAIre reviewer flagged the PRs within seconds, and org-wide rulesets, minimal token permissions and disabled Actions PR approval meant the attacker could only push a harmless branch, while the prompt injections failed. The incident shows why to avoid interpolating untrusted input in workflows and to enforce least-privilege CI controls.