Skip to main content

Credential reaches the client browser

Detects direct credential flows into responses, loaders, globals, DOM, and external requests.

DetailValue
Check IDCREDENTIAL_BROWSER_LEAKAGE
SeverityHigh
How it runsDeterministic scan and agent review

app/routes/app.dashboard.tsx

import type { LoaderFunctionArgs } from "react-router";

import { authenticate } from "../shopify.server";

export const loader = async ({ request }: LoaderFunctionArgs) => {
const { session } = await authenticate.admin(request);

// A loader return value is serialized into the HTML document, so
// this hands the offline token to anything that can read the
// page.
return { shop: session.shop, accessToken: session.accessToken };
};

Keep credentials server-side and return only non-sensitive derived data.

app/routes/app.dashboard.tsx

import type { LoaderFunctionArgs } from "react-router";

import { authenticate } from "../shopify.server";

export const loader = async ({ request }: LoaderFunctionArgs) => {
const { admin, session } = await authenticate.admin(request);

// Do the privileged call on the server and return only what the
// UI renders. The same rule covers globals, DOM writes, and
// outbound requests to third parties.
const response = await admin.graphql(`{ shop { name } }`);

const { data } = await response.json();

return { shop: session.shop, name: data.shop.name };
};


Was this page helpful?