Bologu

Secure your Claude Code, Codex and Cursor settings: stop clicking "allow all"

Updated · by the Bologu team

Claude Code, Codex and Cursor ask before running every command, which gets tiring. So many people click “allow all” or switch on a mode that never asks, and commit that settings file to the repo as well. The result: the AI can run any command on your machine, including commands it read on a web page, in a package’s README or in an issue a stranger wrote. This guide lists the dangerous settings and what to use instead.

Why it matters

  • Prompt injection: hidden text in a web page, file or issue can tell an agent to run a command. If the agent doesn’t have to ask you, it runs right away.
  • Your machine holds valuable things: .env files, cloud keys, GitHub tokens and browser sessions all live on the same machine the agent works on.
  • Malware goes after AI settings: this year’s npm malware hid in Claude and VS Code folders. Letting the agent do anything opens the door wider.
  • Files in the repo affect everyone: a committed .claude/settings.json or .codex/config.toml applies to everyone who clones the repo, CI included.

The dangerous settings

Claude Code   "defaultMode": "bypassPermissions"   --dangerously-skip-permissions
              "allow": ["Bash"]  or  "Bash(*)"
Codex         approval_policy = "never"   sandbox_mode = "danger-full-access"
              --dangerously-bypass-approvals-and-sandbox   --yolo
Cursor        Run Mode: "Run Everything"
MCP           "command": "npx", "args": ["some-mcp-server"]   ← no version pinned

All of these mean “run any command without asking”. Use them only on a throwaway machine or container with no real keys and no important data.

Safer settings

Claude Code

Allow only the commands the project really uses, block secret files, and turn off the mode that skips permission prompts. Claude Code checks deny rules first, then ask, then allow, so a deny rule always beats an allow rule.

// .claude/settings.json
{
  "permissions": {
    "defaultMode": "default",
    "allow": ["Bash(npm run test *)", "Bash(npm run lint)", "Bash(git status)", "Bash(git diff *)"],
    "deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"],
    "disableBypassPermissionsMode": "disable"
  }
}

Codex

Ask when needed, and write only inside the project folder. The workspace-write mode keeps network access off by default; don’t turn it on unless you need it.

# .codex/config.toml
approval_policy = "on-request"
sandbox_mode = "workspace-write"

[sandbox_workspace_write]
network_access = false

Cursor

Go to Settings → Agents → Approvals & Execution and choose Allowlist or Auto-review instead of Run Everything. If you use a permissions.json file, list only the commands you need:

// ~/.cursor/permissions.json
{
  "terminalAllowlist": ["npm run test", "npm run lint", "git status", "git diff"],
  "mcpAllowlist": ["github:search_code"]
}

Don’t rely on a block list alone: blocking curl or rm one by one always leaves a way around. Think “allow only what you know” instead.

Agents in CI and GitHub Actions

  • Don’t run workflow agents with settings that skip permissions; give them only the tools that job needs.
  • Set the workflow’s permissions: as low as possible (for example contents: read) and don’t pass secrets a step doesn’t use.
  • Never run an agent on pull_request_target with the PR’s code checked out: anyone can open a PR with hidden instructions.

MCP servers

  • Pin an exact version, such as [email protected], not latest or no version. If the package gets hijacked, a new version won’t be pulled in automatically.
  • Pass tokens through environment variables; never write real values into .mcp.json.
  • Install only servers you actually use and whose maintainer you know.

A prompt for your AI

Review the AI agent settings in this repo: .claude/settings.json, .claude/settings.local.json,
.codex/config.toml, .cursor/, .vscode/settings.json, .mcp.json and every workflow in .github/workflows.
1. List every place that lets an agent run commands or edit files without asking
   (bypassPermissions, a bare "Bash" or "Bash(*)", approval_policy "never", danger-full-access,
   --dangerously-skip-permissions, --yolo, autoApprove, "Run Everything").
2. Replace each with a short allowlist of the exact commands this project needs (test, lint, build).
3. Add deny rules so agents cannot read .env files or secrets.
4. Pin every MCP server to an exact version.
Show me the diff before changing anything. Do not print any secret values.

Let Bologu check it

The GitHub code scan reads the AI settings files committed to your repo and the workflows in .github/workflows, and warns you about settings that let agents run commands without asking, unrestricted agents in CI, and MCP servers without a pinned version. Bologu can’t see files that live only on your machine (such as ~/.claude/settings.json), so check those yourself with this guide.

Sources