85 agentic tools audited for security incidents · Talk to the lab →
MotionticBook a call
Guides

· 7 min read

Pull request security checks every AI team should run

Nine pull request security checks for teams shipping AI-written code: what each catches, its false-positive cost, and the order to run them in.

A dashed branch with one tangerine commit merges into a main line through a dotted checkpoint ring

Pull request security checks are automated gates that run on each PR before it merges: secret scanning, dependency review, static analysis, infrastructure scanning and a review of AI-specific risk. Teams shipping code from Claude Code, Cursor or Copilot need them because agents open more PRs than humans can read line by line.

Why AI-written pull requests need their own checks

AI-written pull requests fail in predictable ways that a quick human skim misses. The code compiles, the tests the agent wrote pass, and the diff looks tidy. The flaw sits in what the agent assumed: an unchecked input, a package it half-remembered, a permission it widened to make an error go away.

Academic work backs this up. In the NYU study Asleep at the Keyboard?, researchers found that a large share of Copilot completions for security-relevant scenarios contained known weakness classes. A Stanford user study, Do Users Write More Insecure Code with AI Assistants?, found participants with an assistant wrote less secure code and felt more confident about it.

Volume makes it worse. A coding agent can open ten PRs before lunch. Reviewers start approving on trust, a pattern known as approval fatigue. Automated checks are the only reviewer that reads each diff with the same attention.

The pull request security checks checklist

Run these nine checks on each PR. The list goes from cheapest and least noisy to most expensive.

  1. Secret scanning with push protection
  2. Dependency review and package existence
  3. Lockfile and license policy
  4. Static analysis (SAST) on changed files
  5. Infrastructure-as-code and workflow scanning
  6. Auth and permission diff review
  7. Prompt and agent surface review
  8. Test integrity check
  9. Ownership and approval rules

1. Secret scanning with push protection

Secret scanning catches API keys, tokens and connection strings before they reach the default branch. Agents paste credentials into config files and test fixtures when they want a failing call to work. GitHub's secret scanning with push protection blocks the push itself, which beats rotating a key after the fact.

False-positive cost is low. Test fixtures with fake keys trigger it, and an allowlist for a fixtures/ path fixes that in minutes.

2. Dependency review and package existence

Dependency review flags new packages with known CVEs and packages that should not exist at all. Language models sometimes suggest package names that sound right but were never published. Attackers register those names, a technique researchers call slopsquatting. The paper We Have a Package for You! measured how often models hallucinate packages and found it common enough to exploit.

Your check should fail any PR that adds a dependency younger than a set age or with almost no download history, then ask a human to confirm it. Expect a handful of false positives a month from legitimate new libraries.

3. Lockfile and license policy

A lockfile check catches PRs that change package.json or pyproject.toml without a matching lockfile, or that pull in a copyleft license your legal team has banned. Agents regenerate lockfiles freely, so a small feature can arrive with hundreds of changed transitive versions that nobody asked for.

Noise is moderate. Pin the policy to the licenses you care about and fail only on new additions, not on the existing tree.

4. Static analysis on changed files

SAST finds injection, path traversal, unsafe deserialization and weak crypto in the diff. GitHub's CodeQL code scanning is one option; Semgrep is another. The OWASP Top 10 is a sensible reference for which classes to prioritise.

Scan changed files only on the PR and run the full scan nightly. Full-repo scans on each PR produce a backlog of old findings that developers learn to ignore. False positives are the highest of any check here, so tune rules for two weeks before you make SAST blocking.

5. Infrastructure-as-code and workflow scanning

This check reads Terraform, Kubernetes manifests, Dockerfiles and CI workflow files. Agents fix deployment errors by opening security groups to 0.0.0.0/0, running containers as root or adding permissions: write-all to a GitHub Actions job.

Treat any change under .github/workflows/ as high risk. GitHub's Actions hardening guide lists the patterns to block, including untrusted input in run: steps. Noise is low once you suppress known exceptions per resource.

6. Auth and permission diff review

An auth diff check flags any change to middleware, role checks, CORS settings, session handling or database row policies. Generic SAST rarely catches a removed @require_role("admin") decorator, because the remaining code is valid.

Write a small rule set: any PR that touches files matching auth, middleware, policy or rls needs a named security owner to approve. False positives are frequent, but each one costs a reviewer a minute.

7. Prompt and agent surface review

If your product calls a model, the PR can change what that model is allowed to do. This check looks for new tools exposed to an agent, system prompts that concatenate user input, and model output passed to eval, SQL or a shell. Those paths turn prompt injection from a curiosity into an exploit. The OWASP Top 10 for LLM Applications gives a fuller list to review against.

Few off-the-shelf scanners cover this today. Most teams start with a reviewer checklist and grep rules for tool definitions and prompt templates.

8. Test integrity check

Agents under pressure to make CI green sometimes delete a failing assertion, add skip, or mock the function under test. A test integrity check fails a PR that reduces assertion count, adds skip markers or lowers a coverage threshold without a label explaining why.

This check produces almost no false positives and catches a behaviour humans rarely spot in review.

9. Ownership and approval rules

The last gate decides who must approve. Use CODEOWNERS to route auth, infra and workflow paths to named people, and protected branches to require passing checks and one human approval that is not the PR author. When an agent opened the PR, the person who prompted it should not be the only approver.

How to order the checks so developers keep them on

Order checks by speed and signal, and make only the high-signal ones blocking. A gate that fails one PR in five for noise gets disabled within a month.

A layout that holds up in practice:

  1. Blocking from day one: secret scanning, workflow file changes, test integrity, ownership rules.
  2. Blocking after a week of tuning: dependency review, lockfile policy, IaC scanning.
  3. Warning-only until tuned: SAST, auth diff review, prompt surface review.

Keep total PR check time under ten minutes. Run the slow full-repo scans on a schedule and file results as issues, not PR failures.

Where an AI-specific risk review fits

Checks 6 to 8 are the gaps that generic scanners leave, and they matter more as agents write a larger share of the diff. The Motiontic Security Layer (MSL) covers that layer. It runs on each pull request inside the team's own CI, scores changes against the ARI-42 risk index, and posts a PR comment listing each risk with its fix.

MSL also produces a dashboard and a buyer-ready PDF report, which helps when an enterprise prospect sends a security questionnaire. Teams can connect it directly to CI or have a Motiontic engineer set it up on their infrastructure. Setup takes a 15-minute call and the first report arrives within 48 hours.

Rolling the checks out in one week

A small team can stand up the full checklist in five working days.

  1. Day 1: turn on secret scanning with push protection and branch protection on main.
  2. Day 2: add CODEOWNERS for auth, infra and .github/workflows/.
  3. Day 3: add dependency review and a lockfile check.
  4. Day 4: add SAST on changed files in warning mode and the test integrity rule.
  5. Day 5: add IaC scanning and an AI-specific review, then review a week of findings and decide what becomes blocking.

Log each override with a reason. After a month, the override log tells you which rules to tune and which developers need a conversation.

FAQ

Which pull request security checks should block a merge?

Block on secret scanning, CI workflow changes, test integrity and required approvals from the start. Make SAST and auth review blocking only after a tuning period, because early noise trains developers to ignore failures.

Do AI-written PRs need different checks than human ones?

The same checks apply, but agents fail in different places. They hallucinate packages, weaken tests to pass CI and widen permissions to clear errors, so dependency existence, test integrity and permission diffs deserve more weight. See AI guardrails for the broader controls.

How long should PR security checks take to run?

Aim for under ten minutes in total. Run full-repository scans on a nightly schedule and keep the PR path focused on changed files.

Can a coding agent approve its own pull request?

It should not. Require at least one human approval from someone other than the PR author, and route sensitive paths to named owners with CODEOWNERS. Limiting what the agent can touch also shrinks the blast radius of a bad merge.

How do PR checks help with enterprise security reviews?

Buyers ask how code is reviewed before release. A record of checks run on each PR, with findings and fixes, answers that question with evidence instead of policy text. Motiontic's compliance page covers how that evidence maps to audits.

Check your pull requests against ARI-42

Motiontic can show what an AI-specific review finds in your current PRs. Book a 20-minute call.

Motiontic · Published

Running agents that have to hold up?

Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.