From single pull requests to full software packages: Detecting malicious code at scale
Datadog 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.
Related posts
- Detecting malicious pull requests at scale with LLMs
Datadog Engineering mediumAdeptDatadog's SDLC Security team built BewAIre, an LLM-based reviewer that classifies the diff of every merged PR (nearly 10,000 a week) as benign or malicious, with a written rationale emitted as a security signal for real-time triage. Large diffs are recursively chunked at file markers, then newlines, then midpoints, and the most severe chunk verdict wins, with depth and chunk limits to bound cost. A hand-curated, weekly-updated dataset of real and simulated attacks, prompt-level false-positive exclusions, balanced accuracy as the metric, shadow-mode triage and red teaming cut false positives from over 10% to 0.03%. On the curated set it reached over 99.3% accuracy and caught the tj-actions and Nx s1ngularity malicious commits.
- Coding Agent Horror Stories: The 29 Million Secret Problem
Docker mediumAdeptThe s1ngularity supply-chain attack on the Nx npm package used a post-install script to find installed AI coding CLIs (Claude Code, Gemini CLI, Amazon Q) and invoke them with permission-bypass flags like --dangerously-skip-permissions, prompting the agent to inventory secrets across the home directory before exfiltrating them to public repos under the victim's GitHub account. GitGuardian counted 2,349 stolen secrets across 1,079 repos and also found AI-assisted code leaks secrets at about twice the GitHub baseline. Docker Sandboxes is pitched as the mitigation: agents run in microVMs that see only the project workspace, and credentials stay in the host keychain and are injected by a proxy at the network boundary, so the agent only ever holds a placeholder.
- Building an agentic harness that outlasts the model
Shopify Engineering mediumAdeptShopify's AppSec team built Dispatch, a Ruby-orchestrated multi-agent harness that partitions codebases, runs parallel category-specific Hunter agents, verifies candidates with tests written by a different model inside each app's existing test suite, and opens draft fix PRs. Across 80+ applications including the Shopify Core Rails monolith it produced 300+ findings in about six weeks, valued at over $400,000 in bounty equivalents. Full scans cost $50–300 and diff-based incremental scans $5–50. Key lessons: tests are the oracle for web vulns (e.g., two-tenant fixtures for IDOR), partitions sized to 20–30% of the context window improve recall at low cost, category-specific agents beat generalists, and deterministic scripts should own structured output, Git and credentials. Newer models find more candidates but also more noise, so the harness matters more than the model.
- 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.
- 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.