Skip to content Skip to footer

How to Secure AI Agents Against OAuth Abuse, Phishing and Third-Party Code

What Happened

Recent research highlights three trust boundaries that AI-enabled security programs cannot ignore. A compromised vendor script in the OPTIMJACK attack showed how borrowed code can expose a website [1]. In a controlled test, approval of an attacker-initiated GitHub device code gave an attacker-controlled client an OAuth token and enabled several potential abuses of GitHub Copilot CLI access. Those proof-of-concept outcomes have not been observed in the wild; remote session steering also depended on additional settings and approvals [3]. Separately, a high-volume campaign used fake Microsoft 365 outage notices to direct recipients to non-Microsoft sites. Microsoft assessed it as likely credential phishing but did not confirm credential theft or compromise [4].

On the defensive side, Microsoft announced general availability of Perception, which coordinates security agents for tasks such as triage, investigation and vulnerability reduction while reserving high-impact actions for human control. Some associated integrations and capabilities remain in preview [2].

Why It Matters to Businesses

AI agents inherit the permissions of the accounts, tokens, tools and data they can reach. A legitimate sign-in page does not make an attacker-initiated device-code request safe, and a legitimate vendor relationship does not make every delivered script trustworthy [1][3]. Faster AI-assisted exploitation also increases pressure on remediation: Microsoft reported a critical PHP exploit built in roughly a day while millions of exposed services remained vulnerable nearly two weeks after disclosure [2].

Kimbodo Engineering Perspective

The priority is to constrain what a successful compromise can reach, not to assume detection will always precede abuse. Keep agent identities separate from human identities, grant repository and tool access by task, and require approval for consequential changes. Treat agent memories, synced sessions and tool responses as security-relevant data: misleading memory entries were one demonstrated outcome of the device-code test [3]. Security agents can shorten investigation time, but their recommendations need evidence, audit trails and human review before disruptive action [2].

How We Would Implement It

  • Inventory AI agents, OAuth applications, vendor scripts and the data and actions each can access. Remove unused grants and narrow repository permissions [1][3].
  • Broker agent tool access through scoped credentials, allowlisted actions and logged approval gates. Keep high-impact response actions under human control [2].
  • Isolate third-party website code where feasible, restrict its network and data access, and monitor vendor changes rather than treating a trusted domain as a permanent assurance [1].
  • Correlate device-code approvals with OAuth grants and subsequent GitHub activity. For suspected abuse, revoke unexpected authorizations and inspect sessions, repositories and Copilot Memory; disabling Memory does not delete existing entries [3].
  • For outage-themed phishing, remove delivered messages, review clicks and post-click activity, and direct staff to verify incidents in the Microsoft 365 admin center. Investigate credential use before asserting compromise [4].

Risks, Costs and Security

Least-privilege access, isolation and approval gates add integration work and can slow legitimate workflows. Broad telemetry and automated security agents add operating cost and may create false positives. Validate what each connector actually records before relying on it in an investigation, and distinguish generally available controls from preview features when designing production response paths [2][3].

Where Kimbodo Comes In

Kimbodo builds and operates this in production for businesses — see our AI Security & Guardrails practice, or Request a Security Review.

Sources

  1. [1] Borrowed Code, Real Consequences: What OPTIMJACK Teaches Us
  2. [2] Security for the agentic era, powered by Microsoft Perception 
  3. [3] The risks of device code authentication for AI coding agents
  4. [4] High volume phishing campaign uses Microsoft 365 outage lures to target multiple industry sectors

Leave a comment

0.0/5

Engineering Founded & Customer Focused

KIMBODO LLC. © 2026. All Rights Reserved.