Short answer
Debug logging that prints whole request bodies, user objects or headers copies emails, phone numbers, access tokens and sometimes passwords into your log storage, where more people can read them for longer than you think. Returning raw errors to the browser leaks internal details the same way. Log a request id, the user id and field names instead of values, keep tokens and passwords out entirely, and send the browser a generic message with that id.
Ask an AI about this page:ChatGPTClaude
On this page
Personal data in logs means your code writes things like email addresses, phone numbers, access tokens or passwords into log output. It usually starts as debugging: console.log(body) in a sign-up function, console.log(user) after login, or printing every request header. Its twin is returning raw errors to the browser, which can include database details and the user’s own input. It is rated medium: nothing is public by default, but logs are read by more people and tools, and kept longer, than the database they came from, and a logged token is a working key until it expires.
Why it matters
OWASP’s Logging Cheat Sheet lists what should usually not be recorded directly in logs, but removed, masked, hashed or encrypted instead. The list includes session identifiers, access tokens, passwords, sensitive personal data, database connection strings and encryption keys. Ordinary personal data such as names, phone numbers and email addresses is on a second list: it “may also need to be treated in some special manner”, for example by pseudonymizing it.
Supabase already keeps bodies out of its logs: its Edge Function logging docs say request and response bodies are not logged or retained. Your own console.log calls are a different story; their output appears in the dashboard’s Logs, and the docs ask you to take care not to log sensitive data. The same docs show how to print all request headers while debugging. That output includes the authorization header, so leaving that debug line in place writes every caller’s access token to your logs.
The typical AI-generated function does both mistakes at once:
Deno.serve(async (req) => {
const body = await req.json();
console.log("signup", body); // email, name, phone, maybe a password
try {
// ... insert the profile
} catch (err) {
// Sends internal details to the browser.
return Response.json({ error: String(err), input: body }, { status: 500 });
}
});The second half is the error handling problem OWASP describes: unexpected errors should give the user a generic response, with the details logged on the server for investigation, not returned to the user.
How to find it in your app
Search your functions and API code for logging of whole objects, headers and errors sent to clients:
grep -rnE "console\.(log|info|warn|error|debug)\((.*)(body|user|session|headers|req\)|request\)|password|token|email)" supabase/functions src app 2>/dev/null
grep -rn "Object.fromEntries(req.headers)\|JSON.stringify(req" supabase/functions src app 2>/dev/null
grep -rnE "(error|message): *(String\(err|err\.message|error\.message|e\.message)" supabase/functions src/app app/api 2>/dev/nullThen look at real output. In the Supabase dashboard, open Edge Functions → your function → Logs and read a few recent entries. Anything that identifies a person or authenticates a request (email, phone, Bearer eyJ…, sb_secret_…) is the defect. Do the same in any error tracker or analytics tool you use. On the frontend, check whether session replay or error tracking records form fields.
How to fix it
Log what you need to debug, not who the person is. Give each request an id, log the user id and the names of the fields you received, and return the id to the browser so support can find the entry:
import { withSupabase } from "npm:@supabase/server@1";
export default {
fetch: withSupabase({ auth: "user" }, async (req, ctx) => {
const requestId = crypto.randomUUID();
try {
const body = await req.json();
// Log what you need to debug, not who the person is.
console.log(JSON.stringify({ requestId, userId: ctx.userClaims!.id, fields: Object.keys(body ?? {}) }));
// ... the actual work
return Response.json({ ok: true });
} catch (err) {
console.error(JSON.stringify({ requestId, error: err instanceof Error ? err.name : "unknown" }));
// The browser gets a generic message and an id you can look up in the logs.
return Response.json({ error: "Something went wrong", requestId }, { status: 500 });
}
}),
};A few rules make this stick:
- Never log passwords, access or refresh tokens, API keys, full headers or payment data, even temporarily. Delete header-dump debug lines before you deploy.
- Prefer ids over values. If you need to correlate by email, log a hash or the user id instead of the address.
- Keep error details on the server. If you log
err.message, make sure it can’t contain user input; database errors often quote the value that failed. - Check third-party tools. Configure error trackers and session replay to mask form fields, which OWASP lists explicitly.
Review every console.log, console.info, console.warn and console.error in supabase/functions and in server-side API code, plus logging or error tracking calls in the frontend. Remove or rewrite any that print request bodies, user or session objects, request headers, tokens, API keys, passwords, email addresses or phone numbers. Log a request id (crypto.randomUUID()), the user id and the names of the fields instead.
Wherever an error is returned to the client with err.message, String(err) or the request input, return status 500 with a JSON body containing error: “Something went wrong” and the requestId and log the error name and request id on the server instead. Keep expected validation errors (400) with short, fixed messages. List every file you changed.
Check that the fix works
- Sign up or submit a form on your own app with a test account and a recognizable value, such as
logcheck@your-app.example. - Open the function’s Logs in the Supabase dashboard. Search for
logcheckand forBearer. Neither may appear; you should see the request id, the user id and field names. - Trigger an error on purpose (for example, submit the same unique value twice). The browser must get
Something went wrongand a request id, with no database message and no echo of your input. - Find that request id in the logs. The entry must be there, so you can still debug.
Frequently asked questions
Can I log the user’s email address at all?
OWASP’s Logging Cheat Sheet doesn’t forbid names, phone numbers or email addresses, but says they may need special treatment, such as pseudonymization, when the person’s identity isn’t needed. The user id is usually enough to find what you need.
Does Supabase log my request bodies?
No. Supabase’s Edge Function logging docs say request and response bodies are not logged or retained. What ends up in the logs is what your own code prints with console.log, console.warn and console.error, plus uncaught exceptions.
What do I do about logs that already contain this data?
Fix the code first so no new entries appear. Then check how long your log provider keeps entries and who can read them. If access tokens were logged, they expire; if passwords or secret keys were logged, have those passwords changed and rotate the keys.
Sources
- 1.Logging Cheat Sheet — OWASP Cheat Sheet Series
- 2.Error Handling Cheat Sheet — OWASP Cheat Sheet Series
- 3.Logging (Edge Functions) — Supabase Docs
- 4.CWE-532: Insertion of Sensitive Information into Log File — MITRE
- 5.CWE-209: Generation of Error Message Containing Sensitive Information — MITRE