오늘 닫기

Go to Top

Go to Top

Security Insights

Security Insights

Security Insights

How Secure Is AI-Generated Code? What Whit Hat Hackers Check in the Era of Vibe Coding

How Secure Is AI-Generated Code? What Whit Hat Hackers Check in the Era of Vibe Coding

How Secure Is AI-Generated Code? What Whit Hat Hackers Check in the Era of Vibe Coding

ENKI Whitehat

ENKI Whitehat

Content

Content

Content

Over the past year, how development teams work has changed rapidly. With AI coding assistants like Cursor, GitHub Copilot, and Claude Code becoming daily tools, development speed has become much faster. As AI's role in development deepens and broadens, smaller teams can develop more features in less time.

The issue is that as AI-driven development spreads, the time humans spend validating logic and security also decreases. With trends of AI reviewing AI-generated code rising, security gaps grow, repeatedly leading to vulnerabilities like missing auth checks, exposed secrets, and outdated dependencies in production. Thus, while LLMs excel at generating "functional code," they often fail to fully validate production-level authentication, authorization, or permission flows.

Therefore, from an NSHC Whitehat hacker's perspective, this post outlines recurring security issues in AI coding environments and organizational countermeasures to ensure safer development when using AI coding assistants.

AI Coding Assistant Development: 3 Must-Check Points

1. Hardcoded Secrets and API Keys

AI coding assistants are optimized to quickly output code that works. In the process, example API keys, test DB credentials, and sample JWT secrets often remain directly in the code.

We saw a similar case in a Red Team project by ENKI Whitehat. Inside a corporate repository, they found an exposed API_KEY and system credentials that were then used to spread laterally inside the network. This links back to Supply Chain Attacks, the #2 risk in our 'Top 5 Attack Routes Used by White Hat Hackers'. A single token left in a repo can become the key to taking over the entire build pipeline.

Global studies show that commits with AI assistance leak secrets at about twice the rate of commits written solely by humans (Apiiro — 4x Velocity, 10x Vulnerabilities). In 2025 alone, the volume of newly exposed secrets on public GitHub has continued to rise. (GitGuardian — State of Secrets Sprawl 2026)

To address these risks, organizations can implement the following measures.

Mitigation measures

  • Regularly run secret scanners (gitleaks, trufflehog, etc.) across the entire Git history.

  • Move files like .env or secrets.yaml to a secrets manager (AWS Secrets Manager, HashiCorp Vault, etc.).

  • Enable "Hardcoded Credentials" rules in the Static Application Security Testing (SAST) pipeline.

  • Revoke and rotate any credentials or API keys that have been publicly exposed to repositories.

  • Use pre-commit hooks to block sensitive strings from being committed in the first place.


2. Outdated Libraries and Dependencies

AI coding assistants tend to recommend library versions based on their training cutoff date. Developers who accept these suggestions unquestioningly may end up with versions in package.json or requirements.txt that are months or a year old. This is a primary driver of 1-day vulnerabilities, the #4 risk in the Top 5 Attack Routes. These are flaws with existing patches and CVEs, yet our team remains unpatched. In a previous Red Team exercise, we found a SaaS product’s AI-generated template that defaulted to an authentication library with known CVEs.

Mitigation measures

  • Generate a Software Bill of Materials (SBOM) to gain visibility into which versions are being deployed.

  • Include npm audit, pip-audit, or osv-scanner as standard routines in your CI pipeline.

  • Utilize automated update tools such as Dependabot or Renovate.

  • Manually verify dependency versions suggested by AI assistants during the code review process.

Additionally, supply chain attacks targeting the npm and PyPI ecosystems are on the rise. Malicious packages with names mimicking legitimate ones, and malicious updates via compromised maintainer accounts, are reported continuously. In a recent TeamPCP Supply Chain Attack case, attackers abused a chain of stolen CI/CD tokens and open-source updates to exploit automated development environments. Therefore, automated update tools should be used inside a process that verifies package trust and changes rather than applying "auto-merges" blindly.


3. Incomplete Authentication and Authorization

AI-generated authentication and authorization code works well for standard cases. It produces clean code for logins, token issuing, and basic role checks. The problem lies in edge cases. Patterns frequently identified by ENKI Whitehat through OFFen PTaaS include:

  • Endpoints accessible with revoked tokens due to missing JWT expiration validation logic.

  • Insecure Direct Object Reference (IDOR): routes leaking other users' data by simply changing an object ID.

  • Cases where permission checks are applied strictly on the frontend but bypassed on backend routes.

  • Admin APIs and standard user APIs sharing the same handler with missing conditional routing.

This is an area where automated tools particularly struggle. Since authorization calls are present in code but not enforced at runtime, SAST often misses them. DAST also struggles to run unauthorized request scenarios, like changing object IDs or bypassing frontend controls to hit the server directly. It is an area that must be examined through an attacker's eyes to be detected.

Mitigation measures

  • Make authentication and authorization logic a mandatory code review checklist item. You must manually verify if unauthorized requests are blocked.

  • Check if newly added APIs or routes are exposed without authorization, as AI-generated code might miss permission checks or leave test endpoints behind.

  • Validate that auth logic works as intended with unit and integration tests prior to deployment. Test abnormal scenarios like unauthenticated access and cross-user requests.

  • Repeatedly run automated pentesting scenarios to ensure newly added APIs or modified authorization logic do not reintroduce identical issues.

  • Validate edge cases using external PTaaS at least once a quarter or when auth systems change. Patterns like IDOR or auth bypass must be manually checked from an attacker's perspective.

AI vibe coding era, avoiding vulnerabilities: step-by-step

1. In the Coding Phase

AI-generated code must be reviewed by separating 'functionality' from 'security'. Just because a feature works does not mean it is secure.

  • First check if AI-generated dependencies are actual, legitimate packages (beware of typosquatting attacks targeting non-existent package names) and verify they are the latest stable versions.

  • Do not use AI-generated authentication and authorization logic as-is; reviewers must manually verify edge cases (expired tokens, direct requests from unauthorized users, etc.).

  • Recently, approaches like specifying RBAC (Role-Based Access Control), auth Middleware, and JWT verification logic in the LLM prompt stage are used to enforce permission structures from the start.

  • Files like .env and secrets.yaml must never be committed and should be managed using secret managers (AWS Secrets Manager, HashiCorp Vault, etc.).


2. In the Pre-Commit Phase

Use automated tools to supplement where human review might fall short.

  • Enforce identical secret scanning and static analysis checks during the CI stage to prevent any omissions.

  • Perform dependency scanning for each framework using tools like osv-scanner in the CI pipeline to review package security.

  • Generate a Software Bill of Materials (SBOM) to ensure visibility into which versions are being deployed.


3. In the Live Production Phase

Continuous monitoring is essential even after code deployment. For active services, block abnormal requests and behaviors in real time using WAF or runtime threat detection, and collect security logs centrally to identify anomaly attempts early.

  • Use Dependabot or Renovate to auto-receive patch release PRs to reduce delays, but maintain code reviews before merging. Since auto-updates can also be supply chain attack paths, human merge is recommended.

  • Continuously monitor externally exposed assets and leaked credential footprints.

  • Conduct penetration testing, including auth edge cases, from an external expert's view at least once a quarter. Design-level flaws missed by automated tools will be uncovered here.

The types of flaws found at this stage must be fed back into coding guides, prompt rules, and security policies. It is not just about patching vulnerabilities, but continuously improving the development and deployment process to prevent recurring issues.

Summary

The final responsibility for code written by an AI assistant lies with the committer and the deploying organization. As AI generates code faster and in larger volumes, validation systems must be strengthened accordingly.

Ultimately, what matters most is not whether AI is used, but what validation systems an organization has in place. Security validation must be integrated from code generation to review, deployment, and operation, combining automated tools with human attacker-perspective reviews.

While AI significantly boosts developer productivity, it does not assume responsibility for security. In the future development landscape, "how to validate and operate" will be just as critical a competitive advantage as "how fast can you build."

ENKI Whitehat

ENKI Whitehat

ENKI Whitehat
ENKI Whitehat

Offensive security experts delivering deeper security through an attacker's perspective.

Offensive security experts delivering deeper security through an attacker's perspective.

The Beginning of Flawless Security System, From the Expertise of the No.1 White Hacker

Prepare Before a Security Incident Occurs

The Beginning of Flawless Security System, From the Expertise of the No.1 White Hacker

Prepare Before a Security Incident Occurs

The Beginning of Flawless Security System, From the Expertise of the No.1 White Hacker

Prepare Before a Security Incident Occurs

구독하기

콘텐츠가 유용했다면?
엔키 레터를 구독하세요!

Copyright © 2025. ENKI WhiteHat Co., Ltd. All rights reserved.

Copyright © 2025. ENKI WhiteHat Co., Ltd. All rights reserved.

Copyright © 2025. ENKI WhiteHat Co., Ltd. All rights reserved.