·8 min read
ByDaniel A·Kraftwire Software

Is ChatGPT-Generated Code Safe to Ship? What to Check First

Illustration for Is ChatGPT-Generated Code Safe to Ship? What to Check First

Review generated code against the application’s requirements and test the deployed behavior. Check dependencies, secret handling, resource permissions, and how untrusted data reaches interpreters or browser output. A working example, an AI review, or a clean scan does not establish that the whole application is secure.

The Reality of Shipping AI-Generated Code

Code that looks correct still needs review and tests. The scan figures in this article describe the scanned corpus; they do not compare generated and manually written code or measure model priorities.

A generated answer may contain mistakes or unsupported assumptions. Check relevant library and platform documentation, inspect the implementation, and test the intended behavior. Asking for secure code is a requirement, not evidence that the requirement was met.

Before you merge any ChatGPT-generated pull request or deploy a site built with AI assistance, run through this application security checklist.

1. Dependency Verification And Package-Name Risk

An invented package name can become a supply-chain risk if someone publishes malicious code under that name and developers install it. This scenario is called slopsquatting; the figures here do not measure its prevalence. A name such as fast-stripe-auth-utils is an illustrative example, not a recommendation or a claim about a specific package.

  • Check: Before running npm install, verify the package identity, publisher, source, version, and intended behavior.
  • Inspect: npm view <package-name> can show registry metadata. Age, repository links, or popularity do not by themselves prove safety or maliciousness.
  • Review: Inspect installation scripts and dependency changes, and use maintained packages appropriate to the requirement.

2. Hardcoded Secrets And Placeholders

A placeholder such as const API_KEY = "your_api_key_here"; is not a secret. Replacing it with a live credential in browser-delivered code exposes that value to recipients. See exposed-key remediation.

  • Inspect: Searches for sk_, key, secret, or token are starting points, not complete secret detection.
  • Use appropriate inputs: A URL secret scan checks supported public resources. A history-aware tool such as trufflehog examines repository history under its configured coverage.
  • Remediate: Keep private credentials in server-side secret settings, inspect builds and responses for disclosure, and revoke any exposed credential before investigating and cleaning up its copies.

3. Cryptographic Purpose And Supported APIs

Do not use MD5 to store passwords. A password-hashing scheme such as Argon2 serves a different purpose from authenticated encryption such as AES-256-GCM; configuration and key management matter. Avoid obsolete APIs such as crypto.createCipher and check the runtime’s current supported alternatives.

  • Check: Identify each cryptographic purpose and review the relevant implementation documentation.
  • Tokens: The JWT debugger decodes claims and supports a limited optional signature check; it does not establish that your backend validates issuer, audience, expiry, and authorization. Test those controls on the server.

4. Broken Access Control

For a function such as updateUserRecord(id, data), verify that the caller may change the requested id and the requested fields. Enforce and test authentication and authorization on the backend. See broken access control.

  • Check: For each operation, define who may act on which resource and fields.
  • Database: For Postgres RLS designs, review grants, policies, and bypass roles, then test allowed and denied access. See RLS policies.
  • Enforce: Apply the intended owner, shared, tenant, or administrative permission rules; ownership alone is not every application’s policy.

Reviewing Changes Made With AI Tools

Keep changes small enough to review and test. Inspect source changes and deployed configuration whether you use Lovable, Bolt.new, Cursor, or another workflow. Review returned security headers and CORS behavior where they are relevant.

Test Failure And Abuse Cases

Include cases beyond successful input:

  • Oversized or repeated requests and expensive operations.
  • Untrusted values reaching SQL, shell, HTML, or other interpreters; use appropriate safe APIs rather than merely rejecting punctuation. See injection prevention.
  • Signed-out, wrong-user, and insufficient-permission requests.

How to Use ChatGPT as a Security Auditor

You can ask a model to suggest issues for investigation, then validate each suggestion against the code and runtime. This is an additional review aid, not a security audit result by itself.

Generate

Get your initial code from the AI.

Refine

Review and integrate the proposed change, including error behavior and permission checks.

Request A Review

Provide the relevant code and requirements only if you are authorized to share them with the chosen service. Remove secret values and unnecessary personal data. A separate conversation is optional, not proof of a better review.

Prompt

"Review this code against the stated permissions and data-flow requirements. Identify concrete injection, access-control, or disclosure paths with locations and assumptions. Explain what needs testing; do not invent findings to meet a quota."

Test and verify the suggestions. Changing the requested role does not force a model to find every flaw or make its claims correct. See AI code review for a structured review workflow.

Performance and SEO: The Hidden Risks

Measure page resources, response behavior, and crawlable content independently of how the code was written. Inspect dependencies and assets that affect load time; see performance guidance. For public content, test metadata and crawler-visible output as part of AEO review. These checks do not guarantee search inclusion or a particular conversion rate.

Final Pre-Ship Checklist

Before you hit deploy, ensure these five items are checked:

No Secrets in Frontend

Use the free scan for supported public-resource secret patterns, then investigate findings and additional exposure paths.

TLS Checks

Use the SSL checker for supported certificate and protocol signals, and review the rest of the transport configuration.

Security Headers

Inspect Content-Security-Policy and X-Frame-Options with the header tools, then test policies appropriate to the app’s resources and embedding needs. Header presence alone is insufficient.

Dependency Audit

Use a supported advisory checker such as npm audit or the command appropriate to your Yarn version; yarn audit applies to Yarn Classic. Review results and dependency reachability.

Uptime And Monitoring

Configure uptime monitoring for supported HTTP availability failures. Alerts depend on check intervals, thresholds, and delivery; they do not report every application-logic error.

Moving Beyond the First Draft

Use the security checklist to organize review of the actual implementation and deployment. Assign responsibility for investigating findings and testing changes; a checklist does not eliminate the risk of defects.

SimplyScan reports across 8 dimensions, including security, speed, and compliance signals. Free results expose selected findings with usage limits. A scan does not certify legal compliance or establish that every private access path is secure.

These live figures describe all scanned sites. They do not establish prevalence for an AI-built subgroup, compare development methods, or attribute findings to AI generation.

32% of the 127 live sites SimplyScan has scanned (41 sites) have at least one high or critical security issue.

80% of the 127 live sites SimplyScan has scanned (101 sites) have at least one medium-severity speed issue, such as render-blocking scripts or no route-based code splitting.

10% of the 127 live sites SimplyScan has scanned (13 sites) have at least one medium-severity architecture issue, such as a library with a known vulnerability or no rate limiting.

Frequently asked questions

Generated code needs review against explicit requirements and tests of the deployed behavior. Inspect dependencies, permissions, secret handling, and failure paths. Treating output as a draft is useful, but no review process or scan makes an application categorically safe.
Slopsquatting describes publishing a package under a name a model may invent, hoping a developer installs it. fast-stripe-auth-utils is an illustrative name, not a recommendation or an allegation about an existing package. Verify publisher identity, source, installation scripts, and dependency changes; registry presence alone is insufficient.
Inspect source, history, client builds, responses, and logs. A URL [secret scanner](/tools/secret-scanner) checks supported public resources; a history-aware tool such as trufflehog uses different inputs. Revoke exposed credentials, investigate usage, and clean up copies. No pattern scan proves all secrets are absent.
Do not infer compliance with current practices from the model or the appearance of its answer. Check relevant runtime and library documentation, verify dependencies, and test the security controls. A [review checklist](/blog/security-audit-checklist) helps organize work but does not certify a standard.
It can suggest issues to investigate, but it can also miss vulnerabilities or report incorrect ones. Provide relevant requirements and reviewable code, then validate the findings. Neither a fresh session nor a security-review persona establishes accuracy or complete coverage.
Review access controls, secret exposure, dependencies, untrusted input and output, resource limits, and failure handling. Measure performance and crawlable content separately. Assess the resulting implementation without attributing a finding to AI generation from aggregate scan figures.

Is your app secure? Run a free security scan in 30 seconds · free account required.

Scan your app free →