A Snowflake task or procedure runs SQL that nobody checks

VERICTO-096 High In CI (offline CLI): BLOCKED

CREATE TASK purge_logs WAREHOUSE = etl_wh SCHEDULE = '60 MINUTE' AS DELETE FROM logs; stores a DELETE without WHERE that will empty logs every hour once the task is resumed. A new task starts suspended; ALTER TASK ... RESUME or EXECUTE TASK makes it run. The body runs later, with the privileges of the task's owner role, so whatever checks the statement that created it never see the statements it runs.

How to recover the data

  • Stop it: ALTER TASK purge_logs SUSPEND; (for an alert, ALTER ALERT ... SUSPEND; for a pipe, ALTER PIPE ... SET PIPE_EXECUTION_PAUSED = TRUE).
  • See when it ran and what it did in SNOWFLAKE.ACCOUNT_USAGE.TASK_HISTORY (or the INFORMATION_SCHEMA.TASK_HISTORY() table function), which gives the query id of each run.
  • If a run changed data, use Time Travel while it is within retention: CREATE TABLE logs_restored CLONE logs BEFORE (STATEMENT => '<query_id>'); and copy the rows back.

Why it happens

Tasks, pipes, procedures and alerts are deployed like any other DDL, but their body is SQL that runs later, on a schedule or a trigger, often as a powerful owner role (procedures run with owner's rights by default). A generated cleanup task, or a body changed with ALTER TASK ... MODIFY AS, keeps running long after anyone looked at it.

How to fix it

Deploy tasks, pipes, procedures and alerts only through reviewed, versioned migrations, and review their body as carefully as any statement you would run by hand. Own them with a role that has only the privileges the body needs, and keep EXECUTE TASK and the ability to resume tasks with the deployment role.

How to stop it from happening again

VERICTO-096 · Code that runs later (Snowflake) · Severity: High · AST node: Classified > CREATE TASK

The statement the rule reports

-- task.sql
CREATE TASK purge_logs WAREHOUSE = etl_wh SCHEDULE = '60 MINUTE' AS DELETE FROM logs;

Real CLI output

$ npx @vericto/vericto-cli@2.3.0 check --offline --dialect snowflake task.sql
note: offline mode: 42 standard rules at default severities, engine 5.1.0. Custom rules, overrides, sensitive columns, allowlists and the audit trail apply online only.
✖ task.sql  BLOCKED  VERICTO-096 high
    Classified > CREATE TASK
    fix: Deploy tasks, pipes and procedures through a reviewed migration; their bodies run unchecked
1 blocked · 0 allowed · 0 flagged · 0 monitored   (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))

✖ Vericto blocked 1 statement  (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))
  ✖ task.sql  BLOCKED  VERICTO-096 high
      Classified > CREATE TASK
      fix: Deploy tasks, pipes and procedures through a reviewed migration; their bodies run unchecked

This is Vericto enforcing a rule — the exit code is intentional, not a crash.
To allow a finding on purpose, add an inline comment on the statement:
    -- vericto:ignore[VERICTO-096] <reason>   (a reason is required)

The CLI blocks it and exits with code 1, so the CI job fails before the merge.

Try it free, no account

The CLI checks your .sql files on your machine with the 42 standard rules: no sign-up, no API key, and no SQL leaves your computer. It is open source (AGPL-3.0-only).

npx @vericto/vericto-cli@2.3.0 check --offline --dialect snowflake migrations/

On every pull request

The vericto/check-sql GitHub Action (Apache-2.0) runs the same offline check on the .sql files a PR changes and annotates the findings on the PR. Save it as .github/workflows/vericto.yml:

on: pull_request
jobs:
  vericto:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with: { fetch-depth: 0 }
      - uses: vericto/check-sql@v1
        with: { offline: true, upload-sarif: false, dialect: snowflake }

At runtime, for AI agents

The SQL an AI agent writes never goes through a PR. The Vericto TCP proxy checks each statement between the application or agent and the database, and the MCP check_sql tool lets the agent check SQL before it runs it. Both use the runtime profile, which also blocks schema changes.

The AST condition in the engine

The rule is evaluated by the dialect's classifier; its full definition is in the open source engine's README (AGPL-3.0-only), at this page's commit.

Frequently asked questions