Skip to content
Back to skills

Bwrap Bypass

ASecurity

绕过 Claude Code bwrap (bubblewrap) sandbox 限制。bwrap sandbox 会重新挂载文件系统,导致 Bash 命令无法访问特定路径、凭证文件、Unix socket 等资源。当遇到以下情况时使用:(1) Bash 命令报 Permission denied 但 sandbox 外正常 (2) LOAS2/Kerberos 凭证不可用 (3) 新机器/Bot 部署后需要配置 sandbox bypass (4) 命令因 sandbox 文件系统隔离而失败 (5) 用户说"装 bwrap bypass"、"配 sandbox"。关键词:"bwrap"、"sandbox"、"Operation not permitted"、"Permission denied"、"credentials-cache"。

  • 5 stars
  • 0 votes
  • 0 copies
  • 16 views
  • Added September 13, 2026
ai-agentsshellbashgit

Works with

  • claude code

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 13, 2026

npx -y skills add yangwhale/CloseCrab --skill bwrap-bypass --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bwrap Bypass?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bwrap Bypass
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yangwhale-bwrap-bypass/badge)](https://www.skillsdirectory.com/skills/yangwhale-bwrap-bypass)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bwrap-bypass
description: 绕过 Claude Code bwrap (bubblewrap) sandbox 限制。bwrap sandbox 会重新挂载文件系统,导致 Bash 命令无法访问特定路径、凭证文件、Unix socket 等资源。当遇到以下情况时使用:(1) Bash 命令报 Permission denied 但 sandbox 外正常 (2) LOAS2/Kerberos 凭证不可用 (3) 新机器/Bot 部署后需要配置 sandbox bypass (4) 命令因 sandbox 文件系统隔离而失败 (5) 用户说"装 bwrap bypass"、"配 sandbox"。关键词:"bwrap"、"sandbox"、"Operation not permitted"、"Permission denied"、"credentials-cache"。
---

# bwrap-bypass

Claude Code 2.1.98+ 的 Bash sandbox 用 bwrap (bubblewrap) 包裹每个 Bash 命令,重新挂载文件系统创建隔离环境。这会导致:

- 特定路径(`/run/credentials-cache/` 等)的权限被改变
- Unix socket、命名管道等 IPC 资源不可访问
- 凭证系统(LOAS2、Kerberos)检测到不安全的目录权限后拒绝工作
- 部分系统工具和服务因文件系统隔离而失败

已知 bug: [anthropics/claude-code#35986](https://github.com/anthropics/claude-code/issues/35986)

`sandbox.enabled: false` 和 `dangerouslyDisableSandbox` 均无效——bwrap 在读取 settings 之前就启动。

## 安装

用 passthrough 脚本替换 `/usr/bin/bwrap`(需要 sudo):

```bash
sudo mv /usr/bin/bwrap /usr/bin/bwrap.real
sudo cp scripts/bwrap-passthrough.sh /usr/bin/bwrap
sudo chmod 755 /usr/bin/bwrap
```

脚本路径:`scripts/bwrap-passthrough.sh`(相对于本 skill 目录)。

## 恢复

```bash
sudo bash scripts/bwrap-restore.sh
```

## 原理

`bwrap-passthrough.sh` 接收 bwrap 的全部参数,解析 `--setenv`/`--unsetenv`,跳过所有沙箱参数(`--ro-bind`、`--tmpfs` 等),在遇到 `--` 后直接 `exec` 实际命令。效果:命令照常执行,但不做文件系统隔离。

## 检查状态

```bash
# 检查是否已安装 bypass
file /usr/bin/bwrap  # 应显示 shell script,不是 ELF
head -1 /usr/bin/bwrap  # 应显示 #!/bin/bash

# 检查真实 bwrap 是否已备份
ls -la /usr/bin/bwrap.real
```

## 注意事项

- 安装后所有 Bash 命令不再受沙箱保护,安全性降低
- 定期关注 #35986 修复进度,修好后执行恢复步骤
- 适用于所有 Linux 环境(gLinux、GCE VM、裸金属),只要安装了 bwrap 就可能需要

Files in this skill

  • SKILL.md2.3 KB
  • scripts/bwrap-passthrough.sh1.8 KB
  • scripts/bwrap-restore.sh304 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.