# Claude Code Security Part 2: Bypassing Enterprise Policy by Going Offline

**Blog:** [vschroeder.blog](https://vschroeder.blog)  
**Author:** Victor Schroeder  
**Published:** 2026-08-25  
**Tags:** [ai](/tags/ai.md), [security](/tags/security.md), [software-engineering](/tags/software-engineering.md)

> When an AI coding agent cannot reach its remote policy server, should it fail closed or run unrestricted? Claude Code chooses the latter, leaving a one-hour security blackout on demand.


[View as HTML](/posts/20260825-claude-code-offline-bypass-fail-open/)

---

_This post is part of a ~~4-part~~ 5-part series on security vulnerabilities
in Claude Code's managed settings engine and the disclosure process:_

- **Part 1:** [How Cosmetic Remote Settings Kill Root Policies](/posts/20260824-claude-code-managed-settings-silent-override)
- **Part 2:** [Bypassing Enterprise Policy by Going Offline](/posts/20260825-claude-code-offline-bypass-fail-open)
- **Part 3:** [Forging Remote Settings in User Space](/posts/20260826-claude-code-cache-tampering-total-bypass)
- **Part 4:** [The 5-Minute HackerOne Rejection Speedrun](/posts/20260827-hackerone-speedrun-and-responsible-disclosure)
- **Part 5:** [Working as Designed... Until Quietly Patched](/posts/20261107-claude-code-security-part-5-working-as-designed-until-patched)

---

## Update (November 2026)

This series gained a new [5th part](/posts/20261107-claude-code-security-part-5-working-as-designed-until-patched)
with some major plot twists. After closing all of these reports in minutes as
"working as designed," Anthropic spent the next ten weeks quietly shipping fixes
for every single one of them. Read Part 5 for the changelog receipts and a
testimonial on how Anthropic's "bug bounty" strategy works in practice.

---

In enterprise security, the most fundamental rule of access control is simple:
**fail closed**.

If an endpoint cannot reach the central authority that defines what it is
allowed to do, it should refuse to execute privileged operations until
connectivity and policy are established. Failing open is acceptable for a weather
widget; it is catastrophic for a tool that can run shell commands and read
private source code.

In [Part 1](/posts/20260824-claude-code-managed-settings-silent-override), we
saw how remote settings completely obliterate local root policies due to a
first-wins tier resolution bug.

Now, let us examine what happens when Claude Code tries to fetch those remote
settings over the network.

If the network request fails, Claude Code gives up after twenty seconds and lets
the user run in an unrestricted session for up to a full hour. No policy, no
checks, and no reconnection listener.

## The startup loader and the background poller

When Claude Code launches, it handles organization-level remote settings in two
phases:

1. **Synchronous local load:** It reads the cached remote settings from
   `$CLAUDE_CONFIG_DIR/remote-settings.json`.
2. **Asynchronous remote fetch:** It attempts to fetch the newest policy from the
   Anthropic API in the background.

If that background fetch fails (for example, if the machine is offline or the
domain is unreachable), the runtime initiates a retry loop:

```javascript
// Runtime retry constants extracted from Claude Code
// z0S: max retries (5)
// j0S: timeout per request (10s)
// G0S: background polling interval (3600000ms = 1 hour)
```

The client retries up to five times with exponential backoff (~0.6s, 1.1s, 2.2s,
4.8s, 9.9s). Adding the network timeouts, the final retry fires and gives up
roughly 18 to 20 seconds after launch.

When all five attempts fail, what does Claude Code do?

It logs a debug message: `Using stale cache after fetch failure (unknown_error)`
and continues the session. Startup is never blocked.

The next scheduled attempt to refresh policies is delegated to a background
poller:

```javascript
function oFo(e, t, r) {
  let n = setInterval(e, t);
  if (r.unref) n.unref?.();
}
function pGf(e, t) {
  let n = oFo(() => void J0S(e, t), G0S, { unref: !0 }); // G0S = 1 hour
}
```

Notice what is missing here: there is **no network reconnect listener**.

The timer `oFo` is a rigid `setInterval` set to 3,600,000 milliseconds. If you
reconnect your Ethernet cable one second after the retry loop finishes, the
runtime does not notice. It will not attempt to fetch your organization's
security policy again until the full one-hour timer expires.

## The 20-second bypass recipe

Any user with an existing authenticated session and an onboarded repository can
bypass remote security policies at will.

Here is the exact sequence:

1. Create a dummy or empty cache file in the user config directory:
   ```bash
   $ echo '{}' > ~/.claude/remote-settings.json
   ```
2. Disable networking (toggle airplane mode, disable Wi-Fi, or pull the cable).
3. Launch Claude Code in your project directory:
   ```bash
   $ claude --debug --print 'Reply OK'
   ```
4. Wait 20 seconds for the initial retries to exhaust. We can inspect the debug
   logs to see the failure cascade:
   ```text
   2026-08-24T10:43:48.573Z [DEBUG] Remote settings: Retry 1/5 after 520ms
   2026-08-24T10:43:49.097Z [DEBUG] Remote settings: Retry 2/5 after 1226ms
   2026-08-24T10:43:50.328Z [DEBUG] Remote settings: Retry 3/5 after 2272ms
   2026-08-24T10:43:52.637Z [DEBUG] Remote settings: Retry 4/5 after 4624ms
   2026-08-24T10:43:57.266Z [DEBUG] Remote settings: Retry 5/5 after 8268ms
   2026-08-24T10:44:05.539Z [DEBUG] Remote settings: Using stale cache after fetch failure (unknown_error)
   ```
5. Turn networking back on.

Your session is now fully connected to the internet and communicating with
Anthropic's LLM backend, but the client runtime believes it has no active remote
policy. Any command or hook that the organization intended to enforce is
completely absent.

Need more than an hour? Disconnect 30 seconds before the 60-minute mark, let the
poller fail its 5 retries, and reconnect. The policy blackout resets for another
hour.

## Why fail-open is unacceptable for security policies

This flaw is classified under **CWE-636: Not Failing Securely ("Failing Open")**
and **CWE-693: Protection Mechanism Failure**.

When an organization configures remote managed settings, it is usually to
enforce compliance boundaries:
- Restricting which external Model Context Protocol (MCP) servers the agent can
  connect to.
- Enforcing pre-execution approval for shell scripts.
- Preventing the agent from touching sensitive production credentials.

By allowing the agent to run in an unmanaged state whenever network connectivity
glitches at boot, the security guarantee evaporates. A malicious insider or a
compromised developer workstation does not need root privileges to disable these
controls. They only need to toggle Wi-Fi for 20 seconds.

## How it should be fixed

Security software cannot assume good faith from local network drops.

1. **Fail closed for managed accounts:** If an account belongs to an
   organization with managed settings, offline startup should either restrict
   the agent to safe local operations or refuse tool execution until policy
   verification succeeds.
2. **Dynamic reconnect detection:** The client should listen for OS network
   state transitions (e.g., via `NetworkInformation` or socket events) and
   trigger an immediate policy refresh the second internet connectivity is
   restored.
3. **Graceful fallback to local policies:** When combined with a proper policy
   merge engine, a remote fetch failure should fall back to enforcing the
   immutable local root file (`/etc/claude-code/managed-settings.json`), not an
   empty state.

In [Part 3](/posts/20260826-claude-code-cache-tampering-total-bypass), we will
combine the findings from Parts 1 and 2 to achieve the ultimate exploit:
forging policy in user space to completely override root security settings.

---

Previous: [Claude Code Security Part 1: How Cosmetic Remote Settings Kill Root Policies](/posts/20260824-claude-code-managed-settings-silent-override.md)  
Next: [Claude Code Security Part 3: Forging Remote Settings in User Space](/posts/20260826-claude-code-cache-tampering-total-bypass.md)
