By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.
18px_cookie
e-remove
Blog

AI SAST Remediation: Fixing Vulnerabilities in First-Party Code

Published on
November 19, 2026
Updated on
November 19, 2026
Topics

TL;DR

  • AI SAST remediation uses AI agents to generate and deliver code fixes for confirmed vulnerabilities in first-party code, the code your developers and AI coding agents write, then helps verify those fixes before they merge.
  • First-party flaws have no patched version to bump. Unlike open source CVEs, the fix has to be written into your own code, so it should reuse the helpers, sanitizers, and framework-safe APIs your repo already has.
  • Verify every AI fix by re-scanning the finding, adding a regression test that sends the attack input, and getting human review before it merges. The code owner owns the fix.
  • Burn down the backlog by fixing confirmed, reachable, high-severity findings first, then grouping the rest by root cause so one shared fix closes many findings.

What is AI SAST remediation?

AI SAST remediation is the use of AI agents to generate and deliver code fixes for confirmed vulnerabilities in first-party code, meaning the code your developers and your AI coding agents write, and then help you verify those fixes before they merge. It picks up after detection, once agents have traced and confirmed a finding that requires a code change.

Almost half of companies now have codebases that are at least 50% AI-generated, up from 20% at the start of 2025. More generated code means more first-party findings, and every one of them needs a fix that fits the application it lives in.

This post covers the fix workflow: how fixes are built, where they show up, how to verify them, who owns them, and how to measure whether the program is working. For detection basics, start with the guide to what AI SAST is. For the wider view across dependencies and the rest of the SDLC, see how AI vulnerability remediation works across your stack.

Why first-party fixes are different from dependency upgrades

A first-party vulnerability has no patched version to bump. When a CVE lands in an open source library, the fix usually exists already: a maintainer shipped a new release, and your job is to adopt it without breaking anything. When the flaw is in your own request handler, nobody upstream is going to fix it. Your team has to write the change into your code.

First-party remediation Open source dependency remediation
What changes Your source code: a handler, a query, a helper, an authorization check A dependency version, or a backported patch applied to the current version
Who writes the change Your developer or coding agent, with a proposed fix from AI SAST The upstream maintainer wrote it; your team picks the path to adopt it
What can break Application behavior, if the fix ignores how the app works Your code, if the upgrade brings breaking API changes
Endor Labs workflow AI SAST and AI Security Review propose context-aware fixes Upgrade Impact Analysis ranks upgrade paths by breaking-change risk; Endor Patches applies backported patches without an upgrade

"Use parameterized queries" and "canonicalize the path" are correct as principles, but a developer still has to translate them into the specific change their codebase needs. Developers spend 4+ hours researching a single real vulnerability when they have to work out data flow, impact, and a safe fix. A careless translation can leave the bug exploitable or break the feature it was meant to protect.

Access control is a clear example. Broken access control is OWASP's #1 application security risk, and its fix depends on application-specific authorization logic. A correct fix has to call your app's own permission checks, the ones that know what a tenant, an owner, or an admin means in your system. A generic code snippet can't account for that.

Dependency findings follow their own path. If you're dealing with a vulnerable library, see how to fix open source vulnerabilities without breaking changes using Upgrade Impact Analysis and Endor Patches. The rest of this post stays on code you own.

How remediation agents build context-aware fixes

Endor Labs AI SAST runs a pipeline of specialized agents, and remediation comes last on purpose. Detection agents trace user-controlled data from source to sink across multi-file architectures. Triage agents classify every finding as true positive, false positive, or unknown. Remediation agents then propose fixes for the findings that hold up.

That order matters. A fix for a false positive is wasted review time at best, and at worst it's an unnecessary change to working code. 

The remediation agents work from the Endor Labs code context graph, which models application behavior with line-level detail. That model is what lets a fix reuse the building blocks the repo already has:

  • Shared sanitizers and validators that other handlers already call
  • Authentication and authorization helpers that encode your app's permission model
  • Framework-safe APIs, such as a framework's own file-serving or query-building functions
  • Established patterns, so the fix looks like the code around it and passes review faster

The result is a fix a reviewer recognizes. It calls the same helper the last three handlers call, instead of introducing a fourth way to do the same thing. The Endor Labs AI SAST documentation covers how the scan is configured and how findings are reported. For more on the agent model, read about agentic remediation, and for the full architecture, see how the agents, program analysis, and rules work together.

Worked example: fixing path traversal with the helper your repo already has

This is an illustrative example in Python with Flask. The weakness is path traversal, CWE-22, described in the OWASP Path Traversal entry.

Version 1: vulnerable

import os
from flask import Flask, request, send_file

app = Flask(__name__)
UPLOAD_DIR = "/srv/uploads"

@app.route("/download")
def download():
    name = request.args.get("name", "")
    return send_file(os.path.join(UPLOAD_DIR, name))

‍

A request with name=../../etc/passwd walks out of the upload directory and serves the system password file. os.path.join also discards UPLOAD_DIR entirely if name is an absolute path like /etc/passwd.

Version 2: a generic fix that is still exploitable

import os
from flask import Flask, abort, request, send_file

app = Flask(__name__)
UPLOAD_DIR = "/srv/uploads"

@app.route("/download")
def download():
    name = request.args.get("name", "")
    path = os.path.realpath(os.path.join(UPLOAD_DIR, name))
    if not path.startswith(UPLOAD_DIR):
        abort(404)
    return send_file(path)

‍

This is the "canonicalize the path" advice, applied the way many developers and plenty of models would apply it. It stops ../../etc/passwd. It doesn't stop ../uploads_old/secret.txt, which resolves to /srv/uploads_old/secret.txt. That string starts with /srv/uploads, so the check passes and a sibling directory is exposed. A string prefix check can't tell a sibling directory from a subdirectory, so CWE-22 is still open.

Version 3: a context-aware fix that reuses the repo's helper

Say the repo already has a resolve_upload_path() helper that other handlers use to serve avatars and attachments:

# app/storage.py (existing helper, already used by other handlers)
import os
from flask import abort

UPLOAD_DIR = "/srv/uploads"

def resolve_upload_path(name: str) -> str:
    base = os.path.realpath(UPLOAD_DIR)
    path = os.path.realpath(os.path.join(base, name))
    if os.path.commonpath([base, path]) != base or not os.path.isfile(path):
        abort(404)
    return path

The context-aware fix calls it:

# app/routes.py
from flask import Flask, request, send_file
from app.storage import resolve_upload_path

app = Flask(__name__)

@app.route("/download")
def download():
    return send_file(resolve_upload_path(request.args.get("name", "")))

os.path.commonpath compares whole path components, so /srv/uploads_old no longer counts as inside /srv/uploads. The endpoint now behaves like every other file-serving handler in the app, including how it responds to a missing file.

If the repo has no such helper, the framework-safe option is Flask's own send_from_directory:

from flask import Flask, request, send_from_directory

app = Flask(__name__)
UPLOAD_DIR = "/srv/uploads"

@app.route("/download")
def download():
    return send_from_directory(UPLOAD_DIR, request.args.get("name", ""))

send_from_directory joins the path safely and rejects anything that resolves outside the base directory, returning a 404. Either way, the fix closes CWE-22 and matches how the application already serves files.

Where fixes show up: pull requests, the IDE, and coding agents

Fixes reach developers in pull request comments through AI Security Review, and they reach coding agents and AI code editors through AURI by Endor Labs.

AI Security Review runs the AI SAST engine on every pull request. A PR scan with AI Security Review runs in about a minute, and every confirmed finding ships with a context-aware fix. The developer sees the data flow, the impact, and a proposed change in the PR they're already reviewing, so the fix lands while the code is still fresh in their head.

For code written inside an AI code editor or by a coding agent, AURI by Endor Labs is the security harness that connects to the agent through Hooks, Skills, MCP, CLI, and API. AURI hands the agent the finding, the fix, and the secure-coding context it needs, so the agent can apply a correct change before a human ever opens the PR. For more on how this fits agent-driven development, see AI SAST and code security for the agentic SDLC.

How do you verify an AI-generated fix?

You verify an AI-generated fix by re-scanning the finding, running a test that sends the attack input, and having a human approve the change before it merges. Each step catches something the others miss:

  1. Re-scan the code to confirm the original finding closes.
  2. Add a regression test that encodes the specific attack, so the fix can't quietly regress.
  3. Run the existing test suite to confirm normal behavior still works.
  4. Get review from the code owner, plus AppSec for high-risk changes.

Here's the regression test for the path traversal example, using pytest and the Flask test client:

import pytest
from app.routes import app

@pytest.fixture
def client():
    app.config["TESTING"] = True
    with app.test_client() as client:
        yield client

@pytest.mark.parametrize("name", [
    "../../etc/passwd",
    "../uploads_old/secret.txt",
])
def test_download_rejects_traversal(client, name):
    response = client.get("/download", query_string={"name": name})
    assert response.status_code == 404

Version 1 fails both cases. Version 2 passes the first and fails the second, which is the point: the sibling-directory input catches the flawed startswith fix that looks right in review. Version 3 passes both. Pair it with a test that a valid file in the upload directory still returns 200, so you know the fix didn't break downloads.

Every AI fix needs human review before it merges. An unreviewed fix is still unreviewed AI code, and code review is the last mile of AI productivity for fixes as much as for features. AI SAST also scans the fix itself when it lands in a PR, so a remediation that introduces a new issue gets flagged like any other change. For more on where scanning helps and where it needs backup, see what static analysis catches and misses in AI-generated code.

This loop maps to practices security leaders already report against. The NIST Secure Software Development Framework covers code review and analysis in PW.7 and assessing, prioritizing, and remediating vulnerabilities in RV.2.

Who owns the fix

The code owner owns the fix. AppSec owns the policy, and coding agents propose changes without approving them.

In practice, that splits into a few clear responsibilities:

  • Code owners accept, edit, or reject proposed fixes on their own PRs. They know the feature and its edge cases.
  • AppSec sets policy for which findings require a fix and how fast, and reviews fixes that touch authentication, cryptography, or shared helpers.
  • Coding agents can apply a proposed fix through AURI by Endor Labs, but a person approves the PR.
  • When a coding agent wrote the vulnerable code, the human who merges that agent's PR owns the fix.

Shared helpers deserve extra attention. A change to resolve_upload_path() affects every handler that calls it, so it should get review from both the owning team and AppSec.

Burning down the first-party backlog

The fastest way to shrink a first-party backlog is to fix confirmed findings by root cause instead of one at a time. Many findings share a cause: a missing sanitizer, a skipped authorization check, a file-serving pattern copied across a dozen handlers. Fix the cause once and many findings close together.

Start with a backlog of real findings. Endor Labs AI SAST delivers up to 95% false positive reduction, according to the Endor Labs AI SAST whitepaper, so the list you work from is made of issues worth fixing rather than noise to triage.

Then work in this order:

  1. Fix confirmed, reachable, high-severity findings first. These carry the most risk per hour of effort.
  2. Group the remaining confirmed findings by root cause, such as all handlers that build file paths from user input or all endpoints that load records without an ownership check.
  3. For each group, fix or introduce the shared helper once, with AppSec review.
  4. Roll out the call-site fixes in batched PRs per owning team, so each team reviews changes to its own code.

Grouping by root cause lines up with RV.3 in the NIST SSDF, which calls for analyzing vulnerabilities to find their root causes and checking the software for other instances of the same problem.

Metrics that show remediation is working

The four numbers that show whether first-party remediation is working are MTTR for confirmed SAST findings, fix acceptance rate, fix rate against inflow, and regression rate. Each one answers a different question a security leader gets asked.

Metric Formula What it tells you
MTTR for confirmed SAST findings Total time from confirmation to verified fix merged ÷ findings fixed How quickly real issues get closed
Fix acceptance rate AI fixes merged as proposed or with minor edits ÷ AI fixes proposed Whether developers trust the proposed fixes
Fix rate against inflow Confirmed findings closed per sprint ÷ new confirmed findings per sprint Whether the backlog is shrinking (above 1) or growing (below 1)
Regression rate Fixed findings that reappear on re-scan ÷ findings fixed Whether fixes hold over time

Track MTTR on confirmed SAST findings separately from dependency findings, since the two workflows move at different speeds. For the general definition and how to calculate it, see how to measure mean time to remediate.

A falling fix acceptance rate is an early warning: developers are rejecting fixes, and you want to know why before trust erodes. A rising regression rate usually means call sites are bypassing the shared helper again, which is a signal to add a lint rule or a test.

How long does remediation take? Without context-aware fixes, developers spend 4+ hours researching a single real vulnerability when they have to work out data flow, impact, and a safe fix. With AI Security Review, a PR scan runs in about a minute and every confirmed finding ships with a context-aware fix, so the research step shrinks to reviewing a proposed change. Across Endor Labs deployments, teams see 6x faster remediation.

Fix first-party vulnerabilities with Endor Labs AI SAST

Good fixes start with finding the right issues. In Endor Labs' June 2026 GA benchmark, AI SAST found 192 real vulnerabilities across 8 real-world projects, 2.6x more than the strongest frontier model in the test. Each confirmed finding arrives with a context-aware fix that reuses the helpers, frameworks, and patterns your repo already has, delivered in the PR or straight to your coding agent through AURI by Endor Labs.

See how Endor Labs AI SAST finds and fixes first-party vulnerabilities, or go back to the AI SAST guide for the detection side of the story.

FAQs

Can AI SAST fix business logic and access control flaws, or only injection bugs?

AI SAST can propose fixes for business logic and access control flaws, including IDORs and authentication bypasses, as well as injection bugs. Those fixes depend on your app's own authorization logic, which is why context matters: a correct IDOR fix calls the ownership or permission check your application already uses, the same way the path traversal fix above calls resolve_upload_path().

Does AI SAST remediation work on code written by AI coding agents?

AI SAST remediation works the same way on code written by AI coding agents as on code written by developers. AI Security Review scans the agent's pull request and proposes fixes in PR comments. AURI by Endor Labs can also feed findings and fixes to the agent through Hooks, Skills, MCP, CLI, and API, so the agent corrects the code before a human reviews it. A person still approves the merge.

Is AI SAST remediation the same as autofix in a linter?

AI SAST remediation is a fix written for a confirmed vulnerability after agents trace the data flow across files and check the finding against your code. Linter autofix applies a fixed rewrite to a single matched pattern in one place. The AI SAST fix accounts for where the data came from, which helpers your repo already has, and how the rest of the application handles the same operation.