Build radar
Sources 33Updates always the freshest
0 Newsletter
Animated illustration for: Security of AI-written code: five checks before deployment
Create · AI code security · Guide · 9 min read

Security of AI-written code: five checks before deployment

Secrets, dependencies, authorization, input validation and scanning: five checks that catch typical flaws in AI-generated code, with GitHub tools.

In short
  • AI code needs the same review as code from an unknown colleague.
  • Five checks: secrets, dependencies, authorization, input validation and automated scanning.
  • Automate what you can: code scanning and dependency alerts catch many flaws but do not replace thinking about permissions.

Coding agents and builders write code faster than it can be read carefully. That makes the temptation to deploy “because it works” stronger than with hand-written code. Code that works need not be secure: an application can perform its task correctly and at the same time expose a key, another user’s data or a dependency with a known vulnerability. Below are five checks worth doing before every deployment. The background of risks around models is described in the article on the OWASP LLM Top 10.

Check 1: secrets

Check that the code, configuration files or repository history contain no API keys, passwords or tokens. Code run in the browser is especially risky, because every visitor sees everything in it. Keep secrets in environment variables on the server side. GitHub has a secret scanning feature that runs automatically in public repositories and in private ones depends on the plan and enabled options. If a key leaked, revoke it at once, because deleting a file does not remove it from the change history.

Check 2: dependencies

An agent readily adds packages, and each is somebody else’s code with its own vulnerabilities. Review the list of dependencies: is each needed, does it come from a trusted source, is the name not a typo of a known package. Enable Dependabot, which warns about dependencies with known vulnerabilities and can propose updates. Introduce updates consciously, with tests, because an automatic version change can also be a source of errors.

Check 3: authorization

A serious flaw that can appear in application code is a missing check of who may see or change data. Authentication (who this is) is not the same as authorization (what is allowed). For every operation on data ask: does the code check that exactly this user has the right to this record? Test it by hand: log in as user A and try to read user B’s data by changing the identifier in the address. Automated scanners will not judge your application’s permission logic, so this is a check for a human.

Five checks and their tools
What you checkWhat helps
1. SecretsKeys in code, files and historySecret scanning, environment variables
2. DependenciesPackages needed, trusted, up to dateDependabot, review of the package list
3. AuthorizationWho may do what on dataA test with two accounts, human review
4. InputValidation and parameterized queriesSchemas, tests with malicious data
5. ScanningKnown vulnerability patternsCode scanning on every push

Check 4: input validation

Data from a user is untrusted, and in AI applications text returned by the model joins it. Check that data is validated (types, lengths, allowed values), that database queries are parameterized rather than glued from text, and that output displayed in the browser is properly protected against code injection. OWASP lists improper handling of model output as one of the threats to LLM applications: a model can return text that, once inserted into a page, executes as code. I write about validating tool arguments in the article Tools and validation in JavaScript.

Check 5: automated scanning

Finally, turn on what checks for you. Code scanning in GitHub analyzes code for vulnerabilities and errors, shows alerts in the repository and can run on a schedule or on events such as a push. That way new code from an agent is checked every time, not only when somebody remembers. The automation catches known patterns but does not replace thinking, so checks 3 and 4 stay with a human.

  1. 01
    SecretsNo keys in code and history.
  2. 02
    DependenciesNeeded, trusted, no known vulnerabilities.
  3. 03
    AuthorizationA test of access to others' data.
  4. 04
    InputValidation, parameterization, escaping.
  5. 05
    ScanningAutomation on every change.
  6. 06
    DeploymentOnly after green checks.

After deployment the checks do not end: set up alerts, review them weekly and have a plan for an incident, that is know who revokes keys, how to roll back a version and where the backups are. Also write a short note on which checks were done before deployment and when, because at the next change you will know what to repeat.

For a coding agent working with permissions on your computer extra rules apply, described in the text An approvals checklist. You will find all materials on this area in the AI code security hub.

Last checked: 20 October 2026. The availability of GitHub features depends on the repository type and plan; check the current documentation.

Frequently asked questions

Is AI code less secure than hand-written code?
There is no simple answer. AI code can be right or wrong like any other, but it appears fast and in large quantities, so it is easy to deploy without review. That is why review and automated checks matter more than before.
What is code scanning?
A GitHub feature that analyzes the code in a repository for vulnerabilities and errors, shows alerts and can run on a schedule or on events such as a push.
What should I do if an API key landed in a repository?
Revoke it immediately with the provider and generate a new one. Deleting the file from the repository is not enough, since the key stays in the change history.
Are automated tools enough?
No. They catch known patterns but will not judge whether permission logic is right. A human reviews decisions about access to data.

Sources

AI code security

Related