Skip to main content
Menu
Advisories

Unauthorized document deletion

GHSA-579H-4CFP-FH53Published Updated GitHub

Description

Impact

An unauthenticated caller could delete or modify a document in any table by ID. Convex IDs can't be guessed, but are often available within apps that query data.

Patches

Upgrading to v0.0.96 closes the attack vector with no further changes required.

Workarounds

If unable to upgrade, replace the store export in convex/auth.ts with a wrapper that checks IDs before calling the library. This requires convex 1.17 or later.

// convex/auth.ts
import { convexAuth } from "@convex-dev/auth/server";
import { v } from "convex/values";
import { internal } from "./_generated/api";
import { internalMutation } from "./_generated/server";

export const { auth, signIn, signOut, store: authStore, isAuthenticated } =
  convexAuth({
    // your existing config
  });

export const store = internalMutation({
  args: { args: v.any() },
  handler: async (ctx, { args }): Promise<any> => {
    if (args.type === "refreshSession") {
      const [refreshTokenId, sessionId] = args.refreshToken.split("|");
      if (
        ctx.db.normalizeId("authRefreshTokens", refreshTokenId) === null ||
        ctx.db.normalizeId("authSessions", sessionId) === null
      ) {
        return null;
      }
    }
    if (
      args.type === "verifierSignature" &&
      ctx.db.normalizeId("authVerifiers", args.verifier) === null
    ) {
      throw new Error("Invalid verifier");
    }
    return await ctx.runMutation(internal.auth.authStore, { args });
  },
});

After upgrading to v0.0.96, delete the wrapper and export the library's store under the name store.

Affected versions

References

GitHub · convex/convex-auth