Fix guides

Your Convex mutations are public endpoints.

Updated 2026-10-14 · Plain English, written for founders who built with Lovable, Bolt, Cursor or similar.

In Convex, every function you export with query, mutation or action from ./_generated/server is public. Your deployment URL ships in your frontend so the client can connect, and anyone who has it can call those functions directly, with whatever arguments they choose. Your UI is not in the way. If a mutation does not check who is calling, anyone can run it.

Functions made with internalQuery, internalMutation or internalAction are different: they can only be called by your other Convex functions, the scheduler, crons, or you from the dashboard and CLI. They are not reachable from a browser.

Check your code

Search your convex/ folder for = mutation( and = action(. For each one, look at the handler. This is the unsafe pattern:

// UNSAFE: anyone can delete any todo, or post as any user
export const remove = mutation({
  args: { id: v.id("todos") },
  handler: async (ctx, { id }) => {
    await ctx.db.delete(id);
  },
});

export const send = mutation({
  args: { userId: v.id("users"), text: v.string() },
  handler: async (ctx, { userId, text }) => {
    await ctx.db.insert("messages", { userId, text });
  },
});

Neither handler reads ctx.auth. The first deletes whatever id it is given. The second trusts a userId argument, so a caller can send someone else's id and post as them.

Fix it: Convex Auth

Get the caller from the session, never from the arguments, and check they own the document before changing it:

import { mutation } from "./_generated/server";
import { v } from "convex/values";
import { getAuthUserId } from "@convex-dev/auth/server";

export const remove = mutation({
  args: { id: v.id("todos") },
  handler: async (ctx, { id }) => {
    const userId = await getAuthUserId(ctx);
    if (userId === null) throw new Error("Not signed in");

    const todo = await ctx.db.get(id);
    if (!todo || todo.userId !== userId) throw new Error("Not found");

    await ctx.db.delete(id);
  },
});

export const send = mutation({
  args: { text: v.string() },              // no userId argument
  handler: async (ctx, { text }) => {
    const userId = await getAuthUserId(ctx);
    if (userId === null) throw new Error("Not signed in");
    await ctx.db.insert("messages", { userId, text });
  },
});

Fix it: Clerk, Auth0 or another provider

With an external auth provider, ctx.auth.getUserIdentity() returns the verified identity, or null when nobody is signed in:

export const remove = mutation({
  args: { id: v.id("todos") },
  handler: async (ctx, { id }) => {
    const identity = await ctx.auth.getUserIdentity();
    if (identity === null) throw new Error("Not signed in");

    const todo = await ctx.db.get(id);
    if (!todo || todo.ownerToken !== identity.tokenIdentifier) throw new Error("Not found");

    await ctx.db.delete(id);
  },
});

Store identity.tokenIdentifier (or your own users-table id looked up from it) on each document when you create it, and compare against it later.

Get the details right

What SecureIndie checks

This check reads your code only, when you connect your repo. It flags exported public mutation and action functions in convex/ whose handlers never read ctx.auth or call a known auth helper such as getAuthUserId. Internal functions are skipped. It does not call your deployment, and it cannot tell whether an ownership check that is there is correct, so review those by hand.

After the fix

Check your app

SecureIndie looks for this mistake. The free quick check covers the basics from outside (exposed files, keys in your site's code, headers) in about a minute. Database rules, payment webhooks and AI endpoints need the full audit, which also reads your code and proves what a visitor can actually reach.

Questions

Is my Convex deployment URL a secret?

No. The client needs it to connect, so it ships in your frontend. Each function has to decide for itself who is allowed to call it.

My UI only shows the delete button to the owner. Is that enough?

No. Anyone can call the mutation directly, without your UI, with any arguments they like. The check has to happen inside the handler.

Can I pass the user id from the client?

Not as proof of who is calling. Any caller can send any id. Get the user from ctx.auth.getUserIdentity() or getAuthUserId(ctx) inside the handler instead.

Related guides

Checks covered: CVX-AUTH-001 · If you think data already leaked