Overview
The Snowflake integration lets Cotool agents query security data in your Snowflake account, and collects Snowflake’s own login, query, and access history into Cotool. It provides:- Data discovery: browse databases, schemas, tables, and views, search for tables by name, and inspect a table’s columns, clustering key, size, comments, and sample rows.
- Read-only SQL: run Snowflake SQL for investigations, alert triage, threat hunting, and code detections. Results include typed columns and a
truncatedflag when more rows matched than were returned. - Log ingest: collect
LOGIN_HISTORY,QUERY_HISTORY, andACCESS_HISTORYfromSNOWFLAKE.ACCOUNT_USAGEfor search and detections. See Log ingest.
Before you start
You will need:- A role with
USERADMIN(orSECURITYADMIN) to create a user and role, and the owner of the databases holding your security data to grant read access. - A warehouse Cotool can use. We recommend a dedicated X-Small warehouse with auto-suspend and auto-resume:
- Every Cotool query runs on that warehouse and consumes credits. A dedicated warehouse keeps Cotool’s cost separate from your other workloads.
- Discovery uses
SHOWandDESCRIBE, which do not need a running warehouse. Queries and sample rows do.
Set up Snowflake
1
Create a key pair
Generate an RSA key pair on your machine. The private key goes into Cotool; the public key goes on the Snowflake user.To encrypt the private key, drop
-nocrypt and enter the passphrase in Cotool as well.2
Create a role, a warehouse, and a service user
Snowflake blocks single-factor password sign-in for
TYPE = SERVICE users. Password authentication remains available in Cotool for human users, but Snowflake is phasing it out; use key-pair authentication.3
Grant read access to your security data
Skip this step for ingest-only access.Do not grant ownership,
INSERT, UPDATE, DELETE, or ALL PRIVILEGES. Cotool only needs to read.4
Grant access to Snowflake's audit views
Log ingest reads Prefer these database roles over
SNOWFLAKE.ACCOUNT_USAGE, and agents can query these views too. Grant the database roles for the streams you will turn on:GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE, which works but exposes every view in the SNOWFLAKE database.Connect in Cotool
- In Cotool, go to Platform > Integrations > Snowflake and click Connect.
- Enter the values you collected:
- Click Connect. Cotool signs in and confirms the warehouse before saving. If the check fails, the error explains which part to fix (see Troubleshooting).
Network access
If a Snowflake network policy restricts access, allow Cotool’s egress IP addresses, listed on the Snowflake connect form in Cotool (Platform > Integrations > Snowflake > Connect). Cotool cannot reach accounts that only accept PrivateLink connections. A blocked connection fails with “IP … is not allowed to access Snowflake”.How Cotool queries Snowflake
- Discovery is incremental. Agents list databases, then schemas, then tables and views, and describe only the tables they need. Discovery uses
SHOWandDESCRIBE, which read metadata and do not resume the warehouse. Sampling rows does use the warehouse. - Queries are read-only and single-statement. Cotool accepts only
SELECT,WITH,SHOW,DESCRIBE, andEXPLAIN, and Snowflake rejects more than one statement per call. The role’s grants remain the real boundary. - Results are capped. Queries return 500 rows by default and at most 10,000. When more rows match, the response says
truncated: true, and the agent narrows or aggregates the query. - Queries time out and are cancelled. Each statement has a timeout (300 seconds by default, at most 30 minutes), enforced by Snowflake and by Cotool, so abandoned queries do not keep running on your warehouse.
- Queries are attributable. Cotool’s statements appear in Query History under the service user with the query tag
cotool-agent, so you can audit and cost them. - Values are exact. Timestamps come back as UTC ISO-8601. Numbers beyond 2^53 and decimals come back as strings, so IDs and amounts keep full precision.
- Cluster large log tables on an event date or timestamp column. Cotool shows agents the clustering key and tells them to filter on it first.
- Add table and column comments describing each source (for example, “Okta System Log events”). Agents see comments during discovery and use them to pick the right table.
- Use one table per log source rather than one mixed table, so agents do not have to filter by source type.
Environment map
After you connect, and weekly after that, Cotool maps the account’s tables and views: each one’s columns, clustering key, row count, a few sample rows, and a summary of what it holds (for example, which log source it is). Agents start from this map instead of rediscovering the account, and detection planning uses it to know which log sources you have. View it on the Snowflake integration page in Cotool.- The map covers the tables and views the role can see, up to 300. It skips the
SNOWFLAKEandSNOWFLAKE_SAMPLE_DATAdatabases, Native App databases, andINFORMATION_SCHEMA; agents can still query those directly, and already know theSNOWFLAKE.ACCOUNT_USAGEviews. - Listing and describing tables does not resume the warehouse. Sampling runs one
SELECT * ... LIMIT 3per table, so mapping briefly resumes it. If sampling keeps failing, Cotool maps the remaining tables without sample rows. - Tables created between runs are not in the map until the next run, but agents can still find them with discovery.
Log ingest
Cotool can collect three of Snowflake’sACCOUNT_USAGE views using the same connection. Each stream is off until you turn it on in the integration’s Log Ingest settings (see Connect log sources).
- Access history requires Snowflake Enterprise Edition or higher.
- Cotool polls each stream every 15 minutes, and stays behind real time by that stream’s publication delay so it reads only windows Snowflake has finished publishing. Events and detections on a stream therefore run up to that delay behind. An hourly pass re-reads older windows to pick up rows published even later. Duplicate rows are removed.
- Every poll runs on the connected warehouse and appears in Query History with the query tag
cotool-log-ingest. - Query history stores each query’s full text. That text can include secrets written into statements, for example credentials in
CREATE STAGEorALTER USER.
Ingest-only access
To collect logs without giving agents access to your own data, give the role only:USAGEon the warehouse (step 2).- The database roles for your streams (step 4).
IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE.
With this role:
- Log ingest works for every stream whose database role is granted.
- Agents cannot read your databases. The role has no grants on them, so Snowflake hides them from discovery and rejects queries against them.
- The environment map is empty. The only database the role can see is
SNOWFLAKE, which the map skips. Mapping still runs on connect and weekly, but it only lists metadata, so it does not resume the warehouse and samples no rows. - Agents can still query the audit views. The Snowflake query and discovery tools stay available, and can read the
SNOWFLAKE.ACCOUNT_USAGEviews the granted database roles cover, including query text inQUERY_HISTORY. Most of this is the same data log ingest collects.