Codex CLI 0.172.0 on WSL 2: denied /run/WSL remains listable and write-eligible inside a tmpfs mask

Đang mở
#64,198 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
34/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
linux, rust
Lĩnh vực
cli, security

Hướng nghiên cứu

Start by reproducing the reported behavior with the supplied codex sandbox command and inspect how filesystem deny rules are resolved and applied to /run/WSL. The report says the reproduction is derived from a verified fixture and has not been rerun independently; the effective configuration is also unverified. Done means listing the masked directory fails and the effective-ID write/search check returns false while host interoperability resources remain inaccessible.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

app bug CLI sandbox windows-os
What version of the Codex App are you using (From “About Codex” dialog)?

codex-cli 0.172.0, standalone Linux x86-64 musl build

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows host, WSL 2 Linux x86-64, CPython 3.12.3, unprivileged Linux user.

What issue are you seeing?

A named permission profile explicitly denies /run/WSL.

Under Codex CLI 0.172.0, the sandbox masked the host directory with a separate, empty tmpfs. However, the mask remained listable and the effective-ID write/search check returned true.

The full isolation fixture stopped with exit code 1 and reported:

RuntimeError: Isolation failure: Windows interop socket directory unexpectedly succeeded

The actual host interoperability resources were hidden. However, the listable and write-eligible mask does not satisfy the expected behavior of an explicit deny rule.

Actual file creation was not tested. I contacted OpenAI Support, and they indicated that this behavior is not documented as expected.

What steps can reproduce the bug?

This reduced reproduction is derived from the verified full fixture and has not been rerun independently.

Use a disposable WSL workspace with empty scratch/ and exports/ directories.

The fixture reads metadata, attempts a directory listing and checks access using the process's effective IDs. It creates no files and opens no interop sockets.

Save the following sanitized permission profile as repro-profile.toml. The command substitutes the resolved executable path for <CODEX_BIN>.

[permissions.gql-audit.filesystem]
":root" = "deny"
":minimal" = "read"
"/init" = "deny"
"/mnt" = "deny"
"/run/WSL" = "deny"
"/run/user" = "deny"
"<CODEX_BIN>" = "read"

[permissions.gql-audit.filesystem.":workspace_roots"]
"." = "read"
"scratch" = "write"
"exports" = "write"

[permissions.gql-audit.network]
enabled = false

Run from the disposable workspace:

/usr/bin/python3 -I -S -B - <<'PY'
import json
import shutil
import subprocess
import tomllib
from pathlib import Path

workspace = Path.cwd()
binary = shutil.which("codex")
if not binary:
    raise SystemExit("Codex CLI not found")
codex = Path(binary).resolve(strict=True)

profile = tomllib.loads(
    (workspace / "repro-profile.toml").read_text()
)["permissions"]["gql-audit"]
profile["filesystem"].pop("<CODEX_BIN>")
profile["filesystem"][str(codex)] = "read"

def inline_toml(value):
    if isinstance(value, dict):
        return "{ " + ", ".join(
            f"{json.dumps(key)} = {inline_toml(item)}"
            for key, item in value.items()
        ) + " }"
    return json.dumps(value)

fixture = r"""
import json, os, stat
from pathlib import Path

path = Path("/run/WSL")
result = {}
try:
    info = path.stat()
    result.update(device=info.st_dev, inode=info.st_ino,
                  mode=f"{stat.S_IMODE(info.st_mode):04o}")
except OSError as error:
    result["stat_errno"] = error.errno

try:
    result["entry_count"] = len(os.listdir(path))
    result["listable"] = True
except OSError as error:
    result.update(listable=False, list_errno=error.errno)

result["write_and_search_allowed"] = os.access(
    path, os.W_OK | os.X_OK, effective_ids=True
)
result["mountinfo"] = [
    line for line in Path("/proc/self/mountinfo").read_text().splitlines()
    if line.split(" - ", 1)[0].split()[4] == str(path)
]
print(json.dumps(result, indent=2))
raise SystemExit(1 if result["listable"] or result["write_and_search_allowed"] else 0)
"""

raise SystemExit(subprocess.run([
    str(codex), "sandbox",
    "--config", "permissions.gql-audit=" + inline_toml(profile),
    "--permission-profile", "gql-audit",
    "--include-managed-config", "--cd", str(workspace), "--",
    "/usr/bin/env", "-i", "PATH=/usr/bin:/bin",
    f"TMPDIR={workspace / 'scratch'}",
    "/usr/bin/python3", "-E", "-S", "-B", "-c", fixture,
], cwd=workspace, stdin=subprocess.DEVNULL).returncode)
PY
What is the expected behavior?

With the explicit deny rule active, listing /run/WSL should fail, and the effective-ID write/search check should return false.

The host's WSL interoperability resources should remain inaccessible.

OpenAI Support indicated that explicit deny rules are intended to prevent both reads, including directory listing, and writes, and that the observed listable, write-eligible tmpfs behavior is not documented as expected.

I am seeking a supported resolution that preserves sandbox protections and managed security requirements.

Additional information
Verified diagnostic evidence
Diagnostic | Result -- | -- Host /run/WSL | Device 63, inode 8, eight sockets and one symlink Sandbox /run/WSL | Device 103, inode 1, zero entries Sandbox mount | Separate read-write tmpfs Mount propagation tags | [] Directory mode | 0755 Directory listing | Succeeded Effective write/search eligibility | true Actual file creation | Not tested Full fixture exit code | 1

Other isolation checks confirmed separate mount and network namespaces, loopback-only interfaces and routes, denial of a harmless outside Unix socket, Windows drive listing, staged input writes, and reads of /init and cmd.exe.

The exported diagnostic SHA-256 hashes matched. No real host interoperability sockets were contacted.

Configuration uncertainty

The launcher explicitly requested gql-audit with --include-managed-config. It supplied neither --sandbox nor a legacy configuration override.

The generated project template contains neither sandbox_mode nor sandbox_workspace_write.

Read-only grep checks returned no matches for these keys or default_permissions in the WSL user and staged project configurations.

However, the complete system and managed configuration stack and the permission profile actually resolved by the noninteractive sandbox helper remain unverified.

Attempting to obtain interactive /status and /debug-config output triggered a project trust prompt. No trust settings were changed.

Request for engineering assistance
  • Is this a denied-directory mask implementation issue or a configuration-resolution issue?

  • Is there a supported configuration or stable release that enforces directory-listing and write denial?

  • What supported read-only diagnostic can confirm the effective permissions and managed policy used by this exact noninteractive codex sandbox invocation?

I do not want to disable sandboxing, weaken security requirements or use unrestricted execution as a workaround.

Ngôn ngữ chính
Rust
Star
136k
Fork
21.6k
Merge trung bình
1 phút
Pull request đã merge (30 ngày)
997

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/codex

Tất cả issue của openai/codex

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.