Security best practices for CoCo CLI¶
Essential security practices for CoCo CLI include using secure authentication methods, protecting configuration files, managing roles and access appropriately, handling conversation history securely, ensuring MCP server integrity, and following production safety protocols.
Important
In managed environments, your organization may deploy a system-level managed settings file that enforces policy (for example, restricting tool access, limiting allowed accounts, or disabling bypass capabilities). For details, see Managed settings (organization policy).
Credentials¶
- [Recommended] Use browser-based authentication when possible.
The default authentication method for CoCo CLI is browser-based authentication. Use
authenticator = "externalbrowser"in yourconnections.tomlfile to set this option manually.- Use programmatic access tokens (PATs), when trying to scope access to a specific role.
Generate dedicated PATs in Snowsight (see Using programmatic access tokens for authentication). Set expiration ≤ 90 days, use descriptive names, and rotate regularly.
- Protect configuration files
Use mode
600for configuration files and700for directories to restrict access to only your user.- Never commit credentials
Add sensitive configuration files to
.gitignore.Use environment variables to hold credentials and tokens, and incorporate them in your configuration files using
${VARIABLE_NAME}syntax.
Roles & access¶
- Use appropriate roles per environment
For example, use a read-only role in production and a more expansive role in development.
Never use
ACCOUNTADMINfor routine operations. Grant least privileges.
Conversation history¶
Conversations are stored in ~/.snowflake/cortex/conversations/. Use cortex --private when starting CoCo to disable session saving for sensitive work.
To remove a conversation that was already saved, run cortex conversations delete <session_id>. To find the session ID, run cortex conversations list.
Important
The /clear command only clears the screen. It doesn’t delete the current conversation from ~/.snowflake/cortex/conversations/.
Use mode 700 to restrict access to conversation history to only your user.
MCP security¶
- Only install trusted MCP servers
Verify the source and integrity of MCP servers before adding them. Use the following commands to get a list of servers and remove any untrusted ones:
- Never hardcode MCP credentials
Use environment variables. First, set in your shell:
Then reference them in your MCP configuration:
Production safety¶
- Enable planning mode
Use the
/plancommand to review intended actions before execution.
If your personal access token is compromised¶
Revoke the PAT in Snowsight immediately! Then generate a new token and start using it instead. Remember, don’t use the token in configuration files; use environment variables instead.
Review the query history to identify any suspicious activity. Use INFORMATION_SCHEMA.QUERY_HISTORY_BY_USER for real-time results (no special privileges required to view your own history):
Account administrators can also query SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY for a full account-wide view, but that view has up to 45 minutes of latency.
Managed settings (enterprise policy)¶
In some organizations, administrators deploy managed settings that enforce policy for CoCo CLI. Managed settings can constrain or override user-level configuration (including permission prompts and bypass behavior).
For more information, see Managed settings (organization policy).
Permissions¶
CoCo has four operational modes:
| Mode | Indicator | Slash commands | Description |
|---|---|---|---|
| Confirm actions | Blue ⏵⏵ | Default mode | Prompts for permission before potentially dangerous actions. |
| Plan | Orange ⏸ | /plan, /plan-off | Presents a plan before taking any action. |
| Auto (Preview) | Orange ↻ | Not applicable (cycle with Shift-Tab) | Runs routine actions without a prompt and prompts only for risky actions. See Auto mode (Preview). |
| Bypass | Red >> | /bypass, /bypass-off | All tool calls are approved. |
Press Shift-Tab in CoCo CLI to cycle among these modes.
Warning
The Bypass mode disables all confirmation prompts. Use it only in trusted environments.
Auto mode (Preview)¶
Auto mode runs routine actions without a prompt and checks each remaining action against what you asked for. You see a prompt only when an action looks risky or doesn’t match your intent. You get most of the speed of bypass mode with much of the safety of default approvals. Auto mode is opt-in currently and isn’t the default mode.
Each action that CoCo proposes passes through these checks before it runs:
- Routine actions run without a prompt. Reading files, editing files in your workspace, and running read-only SQL
(such as
SELECT,SHOW, andDESCRIBE) are approved automatically. - An LLM classifier reviews everything else. The classifier checks each action against your requests and earlier actions in the session.
Auto mode fails safe. If the classifier errors or times out, CoCo shows the normal approval prompt.
Auto mode adds checks. It doesn’t replace your existing controls:
- Deny and ask rules, and administrator-managed settings, still apply.
- Snowflake role-based access control (RBAC) still applies to every query.
Note the following limitations:
- Auto mode isn’t a security boundary. It reduces risk, but its decisions are probabilistic, and the classifier can make mistakes. Don’t use it as your only control for sensitive environments.
- Local code isn’t sandboxed in CoCo CLI and CoCo Desktop. Scripts and Python that run on your machine aren’t confined. If you need confined execution, use CoCo in Snowsight, which runs in a sandboxed environment.
Snowflake recommends the following setup:
- Turn on AI_GUARDRAILS for production or sensitive environments. Auto mode checks what the agent does. AI_GUARDRAILS checks what the agent reads, such as tool outputs that might contain prompt-injected instructions. Auto mode doesn’t turn on AI_GUARDRAILS. Only account administrators can enable it.
- Use managed settings to set policy. Administrators can block bypass mode with the
permissions.dangerouslyAllowAllsetting. Auto mode never relaxes managed settings. See Managed settings.
Auto mode is in preview, and its behavior will change based on your feedback. Send us cases where:
- CoCo prompted you too often for routine work.
- CoCo blocked an action that you wanted it to run.
- CoCo ran an action that you expected it to block.
To send feedback, contact your Snowflake account team, who will relay it to Product and Engineering.
To turn on Auto mode in CoCo CLI, start CoCo with cortex, and then press Shift-Tab to cycle among the approval
modes until Auto is selected.
Permission types¶
The following permission levels apply to CoCo tool calls:
| Type | Description |
|---|---|
| EXECUTE_COMMAND | Run bash/shell commands |
| FILE_READ | Read file contents |
| FILE_WRITE | Create/modify files |
| FILE_EDIT | Edit existing files |
| WEB_ACCESS | Web search/fetch operations |
Trust model¶
Support for this feature is experimental and may be subject to change. CoCo makes an attempt to classify commands and operations by risk, as shown in the following table:
| Level | Examples | Behavior |
|---|---|---|
| SAFE | ls, cat, echo, grep | Auto-approved |
| LOW | Create new files (e.g., touch file.txt) | Usually auto-approved |
| MEDIUM | Edit files (e.g., nano file.txt), moderate bash | Prompts in Confirm mode |
| HIGH | rm, curl, wget, sudo | Always prompts |
| CRITICAL | rm -rf, destructive ops | Extra confirmation |
SQL queries¶
SQL is categorized by operation type:
| Category | Operations | Behavior |
|---|---|---|
| READ_ONLY | SELECT, SHOW, DESCRIBE | Auto-approved |
| WRITE | INSERT, UPDATE, DELETE, CREATE | Prompts |
| USE_ROLE | USE ROLE, USE WAREHOUSE | Prompts |
Sandbox¶
CoCo CLI supports sandboxing to isolate command execution. For full details on configuring and using the sandbox, see Sandbox.
Hook integration¶
You can customize permission policy using hooks. Add hook configuration to ~/.snowflake/cortex/settings.json
to apply it to all projects, or to .cortex/settings.json in a project directory to apply it to that project only.
The following example is a pre-execution hook that auto-approves bash commands:
This hook might return a JSON response like the following to auto-approve bash commands.
Permission prompts and caching¶
When CoCo requires your permission to proceed with an operation, it prompts you with details about the request. You can choose to approve or deny the request. You can also opt to remember your choice for future similar requests:
- “Always allow (this session)” remembers until you exit CoCo CLI.
- “Always allow (persist)” remembers indefinitely.
These responses are cached and scoped to the project directory, the tool type, or the command pattern as appropriate.
Persistent permissions are stored in ~/.snowflake/cortex/permissions.json. The following is an example cache:
Delete this file to reset all persistent permissions. To reset permissions for a specific project, delete the corresponding entry.
To reset the session cache, use the /new command, which begins a new session, or exit and re-start CoCo CLI.
Configuration¶
Set the environment variables described below to control permission behavior:
| Variable | Description |
|---|---|
CORTEX_PERMISSION_CACHE_TTL_SECONDS | Sets the default timeout for session permission cache (in seconds). |
COCO_DANGEROUS_MODE_REQUIRE_SQL_WRITE_PERMISSION=true | If set to 1, always prompt for SQL write operations, even in bypass mode |
Security Checklist¶
- Use PATs with at most a 90 day expiration
- Set file permissions to 600/700
- Never commit credentials to git
- Use least privilege roles
- Never use ACCOUNTADMIN for routine work
- Enable planning mode for production and reserve bypass mode for trusted environments
- Only install trusted MCP servers
- Store credentials in environment variables
- Use hooks to enforce policies by automating custom security checks
- Periodically audit permissions