Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Datadog Engineering 12 min read Case study mediumAdept

Detecting malicious pull requests at scale with LLMs

Datadog'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.

Assumes: LLM prompting basicsGitHub pull requests and Actionssoftware supply chain attacks

Related posts

  • From single pull requests to full software packages: Detecting malicious code at scale

    Datadog Engineering mediumAdept

    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.

  • Finding leaked passwords with AI: How we built Copilot secret scanning

    GitHub Engineering mediumAdept

    GitHub replaced regex-based detection of generic passwords with an LLM prompt that judges candidate secrets from their file context. The first GPT-3.5-Turbo few-shot prompt broke on unusual file types in customer repos. GitHub responded by expanding offline evals with customer reports and GPT-4-generated cases, adding GPT-4 as a confirming scanner, and adopting Microsoft's MetaReflection hybrid chain-of-thought/few-shot prompt. To scale full-history scans, they excluded low-value files and built a workload-aware rate limiter in which workloads borrow unused LLM capacity from each other. Mirror testing on preview repos showed up to a 94% drop in false positives with little recall loss.

  • Leveraging AI for efficient incident response

    Meta Engineering mediumAdept

    Meta's AI-assisted root cause analysis system narrows suspect code changes in its web monorepo by combining a heuristic retriever with a fine-tuned Llama 2 (7B) ranker. The retriever uses signals such as code and directory ownership and the runtime code graph to cut thousands of changes down to a few hundred. The ranker then runs an 'election': each prompt holds up to 20 changes and picks the top five, and results are aggregated and repeated until five candidates remain. Backtesting shows the root cause lands in the top five for 42% of investigations at creation time. The biggest gain came from continued pre-training on internal artifacts plus supervised fine-tuning on about 5,000 historical RCA examples, including logprob-ranked list outputs, while confidence thresholds suppress low-confidence suggestions in favor of precision.

  • When an AI agent came knocking: Catching malicious contributions in Datadog’s open source repos

    Datadog Engineering mediumAdept

    An 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.

  • How Dropbox uses MCP and Dash to close the design-to-code security gap

    Dropbox Tech easyNovice

    Dropbox built a code-review agent that uses Dash's MCP server to retrieve relevant threat models and has a foundational LLM check whether a pull request actually implements the security requirements agreed during design review. Analysis of 150 security design reviews found only 12% of implementing PRs link back to their review, the median gap between review and PR is about five weeks, and 69% of review-to-code connections were recoverable only through semantic search. Surfacing threat-model context exposed missing controls and contradictions that static analysis cannot detect. Design principles include validating findings before showing them, tracing each finding to a source requirement, keeping most findings advisory, and handling stale requirements.

The quest for software engineering knowledge.

Look:
Layout: