LLMs for Coding and Security Auditing: Capability Boundaries and Practical Deployment
Large language models have moved from demos to real-world use in programming and security, but their performance varies by model, task type, and evaluation method. This article examines how models typically perform—and where they fall short—across three scenarios: code engineering, autonomous agents, and security auditing. It also provides concrete evaluation and risk-control steps that organizations can apply before adoption, without relying on unverified performance claims.
LLMs for Coding and Security Auditing: Capability Boundaries and Practical Deployment
The capability gains of large language models in programming and security have moved from demonstrations to practical testing in daily work. However, the magnitude of improvement varies by model, task type, and evaluation method. This article explains how models commonly perform—and where they are limited—across three scenarios, and provides evaluation and risk-control steps that enterprises can execute directly before adoption. No unverified performance figures are cited here; all judgments should be based on your team’s own test results.
1. Code Engineering: What Models Can Do and Where the Boundaries Lie
Early code generation tools could mostly only complete individual functions. Today, most frontier models can work within larger code contexts, handling multi-file modifications, dependency analysis, and small-scale refactoring. They can also recognize a project’s existing naming conventions and design patterns.
These capabilities have clear boundaries. Models use long contexts inconsistently—the more files involved, the higher the probability of missing modification points. They may also produce code that is syntactically correct but violates business rules. A reasonable division of labor is therefore: the model generates the modification plan and a first draft of the code, while developers review the diffs and run tests.
Take a microservice API migration as an example. A typical workflow looks like this: the developer first states the migration goal, such as migrating legacy REST endpoints to a new gateway specification. The model lists the routes, protocol definitions, database mappings, and test files that need changes. After the developer confirms the checklist, the model submits modifications in batches. Each batch must pass compilation, static checks, and unit tests before the next batch begins.
The pseudocode below expresses only the workflow structure and cannot be run directly. In practice, you need to add: authentication and timeout settings for the model client, version control operations for the repository, specific parameters for test commands, and the conditions for escalating failures to human handling.
# Illustrative code: not runnable, only expresses the flow of# "batch changes, verify each batch, retry with a limit"MAX_RETRY = 2 # Max auto-fix attempts per step; escalate to a human beyond thisdef migrate_api(repo_path, intent, llm_client, runner):plan = llm_client.generate_plan(intent, repo_path) # Generate a change list; requires human confirmationfor step in plan.steps:for attempt in range(MAX_RETRY + 1):changed = apply_changes(repo_path, step) # Only modify files in the list; must be idempotentresult = runner.run_checks(changed) # Compile, lint, unit testsif result.passed:breakif attempt == MAX_RETRY:raise RuntimeError(f"Step {step.id} auto-fix failed; manual handling required")step = llm_client.fix(step, result.log) # Feed the error log back to the modelreturn plan.summary
2. Autonomous Agents: Executing Tasks in a Sandbox
An agent is a system that can invoke tools, read outputs, and decide its next step on its own. In DevOps scenarios, an agent can follow natural-language instructions to pull code, install dependencies, run tests, and read logs. When tests fail, it can read the error stack trace and propose a fix patch.
The main risk of agents comes from execution privileges. The environment in which an agent runs should enforce the following five controls:
- Least privilege: The account used by the agent can only access the repositories and directories required for the current task, and cannot read production credentials.
- Network isolation: The sandbox has no public internet access by default; any domains that genuinely need access must be added to a whitelist.
- Command control: Executable commands are whitelisted, and high-risk operations such as deletion, overwriting, and pushing require human confirmation.
- Audit logging: The input, output, and timestamp of every tool invocation are recorded for traceability.
- Human takeover: If the agent fails repeatedly or triggers a high-risk operation, it automatically pauses and notifies the responsible person.
Container platforms, cloud hosts, or other isolation solutions can all provide the execution environment. When choosing one, evaluate whether it supports the five controls above rather than relying on marketing feature names.
3. Security Auditing: Assisting Detection, Not Replacing Humans
Traditional static scanning relies mainly on rules and regular-expression matching, which produces many false positives and struggles to understand business logic. LLMs can read function-level context and judge, for example, whether an input is validated before entering a SQL query, or whether an endpoint lacks a permission check. As a result, they can help identify issues such as SQL injection, cross-site scripting (XSS), broken access control, and hardcoded sensitive information.
However, audit results from models must be evaluated quantitatively. A model may miss cross-file data flows, or misclassify safe code as a vulnerability. Actual performance depends on the programming language, framework, rule coverage, and codebase size. Teams should measure false-positive and false-negative rates using a sample set with known answers, rather than relying on impressions.
The scope of use must also be clearly defined. Auditing may only target your own systems, or targets for which you have obtained written authorization. Vulnerability details produced by the model must not be used to attack other people’s systems.
The recommended process for handling audit results is as follows: the model outputs candidate issues; a security engineer reproduces and confirms them; confirmed issues enter the remediation workflow; after fixes are applied, a human re-tests. Records must be kept at every step.
4. Evaluation and Risk Control Before Deployment
Public leaderboards can serve as a reference—benchmarks such as SWE-bench, which is based on real repository repair tasks, are one example. But leaderboards cannot represent your technology stack, code quality, or business rules. Enterprises should build an internal evaluation set and follow these steps:
- Collect samples: Draw 100 to 300 tasks from real work over the past six months, covering major languages and core modules. Samples should represent day-to-day work; the quantity is only a starting point.
- Define annotation guidelines: Each sample specifies the task description, expected scope of changes, and acceptance tests. Two annotators cross-check each other; samples with major disagreements are adjudicated by a third person.
- Set a baseline: Test the tools currently in use or the previous model generation at the same time, and use the results as a comparison baseline.
- Define metrics: Include code completion accuracy, test pass rate, security issue detection rate, false-positive rate, time per task, and human correction time. Each metric must have a documented calculation method.
- Set pass thresholds: For example, the new model’s test pass rate must be no lower than the baseline, and its security false-positive rate must not exceed the team’s defined upper limit. Thresholds are set before the pilot and are not adjusted retroactively based on results.
- Re-test regularly: Re-run the evaluation after model version or dependency changes, typically once per quarter.
Data security also requires clear rules:
- Data classification: Distinguish public code, internal code, and sensitive data; sensitive data is not sent to external models by default.
- Redaction: Remove keys, tokens, and customer information before sending context.
- Access control: Restrict who can invoke the model and which repositories the model can read.
- Output retention: Preserve prompts, model outputs, and human decisions, with retention periods set according to compliance requirements.
- Deletion policy: Before signing a contract, confirm in writing the vendor-side data retention period and deletion conditions.
5. Suitable Scenarios and Next Steps
Suitable scenarios include: repetitive code tasks with sufficient test coverage that can be rolled back quickly, and rule-based preliminary screening for security checks.
Unsuitable scenarios include: large-scale transformation of legacy systems that lack tests, one-off operations involving funds or production data, and security conclusions without human review.
Next steps can proceed in the following order:
- Select one module for a two-week pilot and record baseline data.
- Build an internal sample set of at least 100 items and complete the annotation guidelines.
- Confirm that the execution sandbox meets the five control requirements.
- Agree with the security team on the false-positive handling process and responsible owners.
