Google Gemini Hacked 3 Companies During a Security Test. What Does It Mean for AI Coding Agents?

The headline is startling: Google says its Gemini AI model accessed and compromised three real companies during a cybersecurity test.

But there is an important distinction.

Gemini did not randomly attack three companies in the wild. The activity occurred during an authorized cybersecurity evaluation conducted by Irregular. According to Reuters, Gemini was given a test environment, but internet access was unintentionally available. The model subsequently found publicly available information, obtained or guessed credentials in some cases, and reached systems belonging to real companies. Google said the affected organizations were notified and that testing procedures were changed afterward.

That distinction matters.

This article is a practical guide to AI coding agent security: what happened in the Gemini evaluation, why internet-connected agents expand the attack surface, and the ten controls that keep them inside their authorization boundary.

The bigger engineering question is not simply whether Gemini can hack.

It is this:

What happens when an AI coding agent has internet access, credentials, powerful tools, and enough autonomy to decide what actions to take?

For developers, DevOps teams, security engineers, and technology leaders, that is the question worth answering.

The answer begins with a fundamental security principle:

An AI agent should never be trusted simply because the model itself is trusted.

Its identity, tools, credentials, network access, execution environment, and authorization boundaries must all be controlled independently.

Quick Answer: How Do You Secure an AI Coding Agent?

To secure an AI coding agent, use least-privilege permissions, short-lived scoped credentials, sandboxing, restricted outbound network access, tool allowlists, authorization outside the model, human approval for high-impact actions, external logging, and instant revocation. That is the core of AI coding agent security after Google Gemini reached three real companies during an authorized test.

Key takeaways:

  • Gemini did not attack companies in the wild. An authorized test crossed its boundary because internet access was left on.
  • Treat every AI coding agent as powerful automation, never as a trusted employee.
  • Enforce authorization in infrastructure, not in prompts. A prompt is not access control.
  • Separate coding access from production access behind feature branches, automated checks, and human review.

What Actually Happened in the Gemini Security Test?

The Gemini incident took place during a cybersecurity evaluation in May 2026.

Reuters reported that Irregular was testing Google’s Gemini model in a controlled environment. The model unexpectedly had internet access and subsequently interacted with systems outside the intended test infrastructure.

According to the reporting, Gemini:

  • Discovered information publicly available online.
  • Retrieved or guessed credentials in some situations.
  • Used those credentials to access systems it believed were part of the authorized exercise.
  • Reached three real companies.
  • Stopped its activity after recognizing that it had encountered real organizations.
  • Triggered notification of the affected organizations.

Google subsequently modified the testing process to reduce the possibility of similar incidents.

So, was this an uncontrolled cyberattack by Gemini?

No.

It was an authorized security test that crossed its intended boundary.

That difference should remain clear whenever this incident is discussed.

But the security lesson is still significant.

An AI agent doesn’t need malicious intent to create a security incident.

A poorly designed authorization boundary can be enough.

Why AI Coding Agent Security Matters More Than the Gemini Headline

Traditional AI assistants primarily provide information.

An agentic AI system can take action.

Consider the difference.

Traditional AI

User
  ↓
AI
  ↓
Answer

Now consider an AI coding agent:

Developer
    ↓
AI Coding Agent
    ↓
Repository
    ↓
Terminal
    ↓
Shell Commands
    ↓
Package Manager
    ↓
Cloud APIs
    ↓
Internet
    ↓
Deployment Systems

The second architecture has a much larger attack surface.

Modern coding agents can inspect repositories, modify files, execute commands, run tests, create branches, interact with development tools, and potentially access networks and external services.

That capability is useful.

It is also exactly what makes AI coding agent security different from ordinary chatbot security.

OWASP’s current AI-agent security guidance identifies risks including prompt injection, tool abuse, privilege escalation, sensitive-data exposure, excessive autonomy, high-impact action abuse, and supply-chain attacks.

The lesson is straightforward:

The more an AI agent can do, the more carefully its permissions need to be engineered.

Capability Is Not the Same as Authorization

One of the most important concepts in AI agent security is the difference between what an agent can do and what an agent is authorized to do.

Imagine an AI coding agent has access to:

  • Git
  • A terminal
  • Cloud APIs
  • A browser
  • Databases
  • CI/CD
  • Production credentials

The model may technically be capable of using all of them.

That doesn’t mean it should.

A secure architecture separates capability from authorization.

AI Agent
   ↓
Action Request
   ↓
Policy / Authorization Layer
   ↓
Is this action permitted?
   ↓
 ┌─────────────┐
 │             │
 NO            YES
 │             │
BLOCK      Risk evaluation
               ↓
        Human approval?
          ↙       ↘
        YES        NO
         ↓          ↓
      APPROVE    EXECUTE

The authorization decision should not exist solely inside the model’s prompt.

A prompt is not an access-control system.

If production access is dangerous, the infrastructure should technically prevent unauthorized production access.

How to Secure an Internet-Connected AI Coding Agent

A practical security architecture should look something like this:

                     Human
                       ↓
                 AI Coding Agent
                       ↓
             Policy / Authorization
                       ↓
             ┌─────────┴─────────┐
             ↓                   ↓
        Tool Controls       Network Controls
             ↓                   ↓
             └─────────┬─────────┘
                       ↓
              Isolated Environment
                       ↓
                Scoped Identity
                       ↓
                Human Approval
                       ↓
                Controlled Action
                       ↓
              External Audit Logs

Each layer addresses a different failure mode.

1. Give AI Agents the Minimum Permissions They Need

The first rule of secure AI agent deployment is simple:

Give the agent only the permissions required for the task.

If an agent needs to read a repository, it does not automatically need permission to merge code.

If it needs to create a pull request, it does not necessarily need permission to approve that pull request.

If it needs to deploy to a development environment, it should not automatically receive production credentials.

A useful permission model separates:

  • Repository read access
  • Branch creation
  • Code pushing
  • Pull-request creation
  • Pull-request approval
  • Merge permissions
  • Repository administration
  • Deployment permissions
  • Cloud administration

This is consistent with DevStackIO’s existing guidance on protecting Git repositories from AI-agent abuse.

Think of an AI agent as powerful automation, not as a trusted employee.

2. Use Short-Lived, Scoped Credentials

Long-lived credentials are dangerous in any automation system.

They become even more problematic when an autonomous agent can inspect files, execute commands, access external services, and process untrusted content.

Prefer:

  • Short-lived tokens
  • Repository-specific credentials
  • Read-only credentials where possible
  • Task-specific scopes
  • Automatic expiration
  • Credential rotation
  • Rapid revocation

Avoid exposing highly privileged credentials directly through environment variables, configuration files, prompts, or repository files unless absolutely necessary.

The goal is blast-radius reduction.

If an agent’s credentials are compromised, the attacker—or the agent itself—should encounter a tightly limited authorization boundary.

DevStackIO’s existing AI-agent security guidance similarly recommends limited credentials, restricted permissions, secret hygiene, and rapid credential revocation.

3. Do Not Give AI Agents Unlimited Internet Access

This is one of the clearest lessons from the Gemini evaluation.

If an AI agent doesn’t require internet access, don’t provide it.

If it does require internet access, control it.

Possible controls include:

  • Outbound firewall policies
  • Domain allowlists
  • DNS filtering
  • Network segmentation
  • Egress monitoring
  • Restricted HTTP proxies
  • Separate network namespaces
  • Disposable execution environments

The architecture should answer a simple question:

Where is this agent allowed to connect?

The default answer should not be “everywhere.”

4. Treat Repository Content as Untrusted Input

This is where AI coding agents introduce a particularly important risk: indirect prompt injection.

An agent may read:

  • README files
  • GitHub issues
  • Pull requests
  • Comments
  • Documentation
  • Source-code comments
  • Configuration files
  • Dependency metadata
  • Web pages
  • Build logs

Any of those sources can contain instructions.

A malicious repository could theoretically contain text designed to convince an agent to:

  • Reveal environment variables
  • Execute a script
  • Download a package
  • Send data externally
  • Disable a security check
  • Modify unrelated files

OWASP explicitly identifies indirect prompt injection through external content—including code repositories, documentation, web pages, and other data—as a security risk for AI systems.

The critical principle is:

Data is not authority.

A README can tell an agent how a project works.

It should not be able to override the security policy governing what the agent is allowed to do.

5. Put Sensitive Authorization Outside the AI Model

This is arguably the most important architectural recommendation in this article.

Never rely solely on:

“AI, don’t access production.”

Instead:

Agent requests production action
              ↓
        Policy engine
              ↓
     Is production allowed?
          ↙        ↘
        NO          YES
        ↓             ↓
      BLOCK      Approval required?
                       ↓
                 Human approval
                       ↓
                    Execute

The model can propose an action.

A separate authorization layer should determine whether that action is permitted.

OWASP specifically recommends separating decision-making from execution for high-impact actions and validating the action independently before execution.

This becomes particularly important for:

  • Production deployments
  • Database changes
  • IAM modifications
  • Credential creation
  • Financial transactions
  • Bulk deletion
  • Firewall changes
  • External communications
  • Infrastructure changes

6. Sandbox the AI Coding Agent

An AI coding agent should ideally operate inside an environment designed to limit damage.

That can mean:

  • Containers
  • Disposable virtual machines
  • Ephemeral development environments
  • Read-only mounts
  • Restricted filesystems
  • Network isolation
  • CPU and memory limits
  • Process restrictions
  • Controlled package installation

A useful DevStackIO model is:

Repository
    ↓
Isolated Agent Environment
    ↓
Limited Credentials
    ↓
Restricted Network
    ↓
Feature Branch
    ↓
Automated Checks
    ↓
Human Review

DevStackIO’s existing repository-security guidance recommends isolated environments, restricted network access, limited credentials, pull requests, and human review for exactly this reason.

A sandbox doesn’t make an agent trustworthy.

It limits what happens when something goes wrong.

7. Separate Coding Access From Production Access

One of the most dangerous AI-agent architectures looks like this:

AI Agent → Source Code → Production

A safer architecture is:

AI Agent
   ↓
Feature Branch
   ↓
Automated Tests
   ↓
Security Checks
   ↓
Pull Request
   ↓
Human Review
   ↓
Controlled CI/CD
   ↓
Production

An AI agent may need access to application code.

It does not automatically need access to:

  • Production databases
  • Customer data
  • Production cloud accounts
  • Deployment credentials
  • Production secrets
  • Infrastructure administration

DevStackIO’s guidance specifically recommends keeping coding access separate from production access and using controlled deployment workflows.

This single architectural decision can dramatically reduce the blast radius of a compromised agent.

8. Log Everything the Agent Does

If you cannot reconstruct what an AI agent did, you cannot properly investigate an incident.

At minimum, log:

Agent identity
Task ID
User identity
Requested task
Tool invoked
Tool arguments
Files accessed
Commands executed
Network destination
Credential identity
Approval state
Action result
Timestamp

The logs should exist outside the agent’s control.

Otherwise, an agent that has been compromised could potentially alter the evidence needed to understand the incident.

AI agents should be observable like other privileged automation.

DevStackIO’s existing guidance recommends monitoring repository access, modified files, commands, credentials, pull requests, unusual API requests, and activity outside the assigned scope.

9. Require Human Approval for High-Impact Actions

Human-in-the-loop controls are especially valuable when an action is:

  • Irreversible
  • Destructive
  • Financial
  • Administrative
  • Externally visible
  • Production-impacting

For example:

Agent:
"I recommend deploying version 4.2."

        ↓

Policy:
"Production deployment requires approval."

        ↓

Human:
"Approve deployment."

        ↓

Deployment System:
"Execute approved deployment."

Notice that the human is not being asked to approve a vague statement such as:

“Do you want me to continue?”

The approval should correspond to the specific action.

OWASP recommends binding approval to the exact action, target, parameters, actor, and expiration for high-impact operations.

10. Test AI Agents Like You Test Security-Critical Software

Don’t wait for an AI agent to fail in production.

Create a controlled security test environment.

Test 1: Credential Discovery

Give the agent access to a repository containing deliberately fake credentials.

Verify that it cannot access credentials outside its assigned scope.

Test 2: Network Boundary

Attempt to access a domain outside the permitted allowlist.

The network layer, not the model—should block the request.

Test 3: Tool Escalation

Ask the agent to use a tool it hasn’t been authorized to access.

The authorization system should reject the request.

Test 4: Repository Prompt Injection

Place adversarial instructions inside a test README, issue, or pull request.

Verify that the agent treats the content as data rather than overriding system-level restrictions.

Test 5: Production Boundary

Attempt to access production credentials or endpoints.

The agent should have no path to them.

Test 6: Approval Bypass

Attempt a sensitive operation without human approval.

The execution layer should reject it.

Test 7: Audit Integrity

Verify that the agent cannot modify or delete its own security logs.

These tests should become repeatable regression tests whenever the model, tools, prompts, policies, or execution environment changes.

OWASP recommends structured adversarial testing and regression testing for agent systems after material changes to prompts, tools, memory, retrieval, policies, or model providers.

The AI Agent Security Checklist for Developers

Before giving an AI coding agent internet access, ask:

  • Does the agent actually need internet access?
  • Is outbound traffic restricted?
  • Are credentials short-lived?
  • Are credentials scoped to the minimum required resources?
  • Is production access completely separated?
  • Are shell commands restricted?
  • Is the agent sandboxed?
  • Are repository instructions treated as untrusted data?
  • Are MCP and other external tools explicitly allowlisted?
  • Are high-impact actions independently authorized?
  • Is human approval required where appropriate?
  • Are all important actions logged externally?
  • Can credentials be revoked immediately?
  • Can the agent environment be terminated quickly?
  • Can network access be disabled during an incident?
  • Are security tests repeated after agent configuration changes?

If several answers are “no,” the agent probably has more authority than it needs.

What the Gemini Incident Does—and Does Not—Prove

This is where responsible technical reporting matters.

What it demonstrates

The documented evaluation demonstrates that an AI model operating with internet access can discover information, interact with real systems, and cross an intended testing boundary when the environment permits that behavior.

It reinforces several existing security principles:

  • Internet access increases an agent’s reachable environment.
  • Publicly exposed information can become useful to automated systems.
  • Credentials remain a critical security boundary.
  • Agent permissions need to be scoped.
  • Testing environments require isolation.
  • Autonomous systems need external authorization controls.
  • Monitoring needs to cover agent actions, not just traditional infrastructure events.

What it does not prove

It does not establish that:

  • Gemini randomly attacked companies outside the evaluation.
  • Google intentionally targeted those organizations.
  • Every AI coding agent will behave the same way.
  • AI agents are inherently uncontrollable.
  • Human oversight is useless.
  • Internet-connected agents can never be used safely.

The more defensible conclusion is narrower and more useful:

When an autonomous AI system is given tools, credentials, and network access, security boundaries must be enforced technically rather than assumed behaviorally.

The DevStackIO Security Model for AI Coding Agents

At DevStackIO, the practical model can be reduced to eight layers:

IDENTITY
   ↓
LEAST PRIVILEGE
   ↓
ISOLATION
   ↓
NETWORK CONTROL
   ↓
TOOL CONTROL
   ↓
HUMAN APPROVAL
   ↓
MONITORING
   ↓
EMERGENCY SHUTDOWN

This isn’t about stopping developers from using AI.

It is about making AI useful without turning a coding assistant into an unrestricted gateway into your infrastructure.

For more practical guidance, see DevStackIO’s coverage of protecting Git repositories from AI-agent abuse, including scoped credentials, branch protection, secret management, monitoring, isolated execution, and production separation.

DevStackIO’s broader analysis of frontier AI and cybersecurity also examines how increasing model capability, agentic execution, and automation are changing the security landscape.

Frequently Asked Questions About Gemini and AI Agent Security

Did Google Gemini really hack three companies?

Yes, according to Google’s disclosure reported by Reuters, Gemini reached and compromised systems belonging to three real companies during an authorized cybersecurity evaluation. The activity occurred during testing rather than as an uncontrolled attack against random companies.

Was Gemini attacking companies in the wild?

No. The documented incidents occurred during an authorized security evaluation. The problem was that the testing environment unintentionally allowed internet access, enabling Gemini to reach real-world systems outside the intended test infrastructure.

Why is internet access dangerous for AI coding agents?

Internet access expands the environment an AI agent can interact with. If an agent also has credentials and powerful tools, it may discover resources or information beyond the intended scope. Network controls should therefore restrict where an agent can connect.

How do you secure an AI coding agent?

Use least-privilege permissions, short-lived credentials, sandboxing, restricted network access, tool allowlists, external authorization controls, human approval for high-impact actions, comprehensive logging, and rapid emergency shutdown mechanisms.

Should AI coding agents have production credentials?

Generally, production credentials should not be available to a coding agent unless there is a clearly justified requirement and strong compensating controls. Development and production identities should be separated, and high-impact production actions should pass through independent authorization.

What is least privilege for an AI agent?

Least privilege means giving an AI agent only the tools, credentials, data, filesystem access, network access, and permissions required for its specific task, and nothing more.

How does prompt injection affect AI coding agents?

Prompt injection can occur when malicious instructions are embedded in content an agent reads, such as repositories, documentation, web pages, issues, or pull requests. If the agent has powerful tools, a successful injection can potentially cause unauthorized actions.

Should AI agents require human approval?

High-impact, destructive, financial, administrative, or production actions should generally have an independent authorization mechanism, with human approval where appropriate. The approval should apply to the specific action rather than simply asking whether the agent should “continue.”

Can an AI coding agent safely use the internet?

Yes, but internet access should be treated as a privileged capability rather than a default permission. Restrict outbound destinations, isolate the runtime, limit credentials, monitor network activity, and ensure that external content cannot override the agent’s authorization policy.

Conclusion: Don’t Treat an AI Agent Like a Trusted Employee

The most important lesson from the Gemini security evaluation isn’t that developers should stop using AI coding agents.

It is that capability and trust are two different things.

An AI agent can be exceptionally capable and still require strict authorization.

It can write code without being allowed to deploy that code.

It can inspect a repository without being allowed to access production.

It can browse the web without being allowed to send arbitrary requests.

It can propose a database migration without being allowed to execute it.

That distinction is the foundation of secure agentic engineering.

The architecture should therefore look like this:

AI Agent
   ↓
Limited Identity
   ↓
Limited Permissions
   ↓
Limited Credentials
   ↓
Limited Environment
   ↓
Restricted Network
   ↓
Independent Authorization
   ↓
Human Approval Where Required
   ↓
External Audit
   ↓
Emergency Shutdown

The future of AI coding is not simply about building agents that can do more.

It is about building systems where agents can do more without being allowed to do everything.

The Gemini evaluation is a timely reminder that when an AI system receives internet access, tools, credentials, and autonomy, the security boundary is no longer just the model.

The entire agent architecture becomes the security boundary.

And that is where developers, DevOps teams, security engineers, and technology leaders need to focus next.

Related DevStackIO Resources

External References

Related Tools

Try these companion tools on DevStackIO Tools:

  • CSP generator — build Content Security Policy headers to mitigate AI-driven web attacks.