Audit logs
| Also known as | Audit trail |
|---|---|
| Each entry records | Time, actor, source address, action, target, result |
| OWASP Top 10 | A09:2025 Security Logging and Alerting Failures |
| Kept by | Hosting providers for their own dashboards and APIs; the application for actions inside it |
A Supabase project writes an entry each time someone signs in, changes a password or removes a two-factor authentication method from an account. The entry for the last of these carries a timestamp, the user ID, the action name factor_deleted and, for this kind of event, the IP address it came from.1 Read next to the entries around it, such a line can show that whoever controlled the account turned off its second factor minutes before a user_updated_password entry for the same user.
An audit log, or audit trail, is the full series of such entries: a dated record of which person or program did what to which object, kept so that events can be reconstructed afterwards. The error output a developer reads while fixing code is a separate log. An audit log blocks no attack. It is read afterwards, in an investigation, for example when an attacker has been signed in as a real user.2
Contents of an entry
Every entry answers four questions: when the event happened, where in the system, who caused it and what was done.3 The "who" part is the source address together with an identity, such as the primary key of the user's row or a username. The "what" part names the action, its target and its outcome, for instance the role that was granted and the account that received it.
The events worth recording (the subject of Security logging and alerting) are the rare and consequential ones. Users created or deleted, permissions changed, tokens issued or revoked, configuration edited, and everything an administrator does all belong in the record.3 So do sign-ins, failed ones included: repeated failures on one account, or a burst of attempts, are early signs of password guessing and Credential stuffing.3 Logging changes to ordinary data is optional.
Passwords, session identifiers, access tokens and sensitive personal data stay out of the entries, or go in masked or hashed.3 A log that holds them gives every reader of the log a way into the accounts it describes; Personal data in logs covers that problem.
Logs kept by providers
Hosted services keep audit logs of actions taken in their own dashboards and APIs, separate from anything the application writes.
| Log | What it records | Retention and access |
|---|---|---|
| Supabase Auth audit logs | Sign-ups, sign-ins, sign-outs, password changes and resets, email verification, token refresh, two-factor changes1 | Dashboard; optionally the table auth.audit_log_entries |
| Supabase Platform Audit Logs | Dashboard and Platform API actions by organization members: new projects, invitations, Edge Function changes, settings4 | Team and Enterprise plans; retention depends on the plan; can be streamed out with Audit Log Drains |
| GitHub organization audit log | Actions affecting the organization, with actor, affected user, repository and country5 | 180 days, three months shown by default; organization owners only |
| Vercel Audit Logs | Activity of team members6 | Enterprise plans; owner and security roles; CSV export of the last 90 days |
| AWS CloudTrail event history | Management events from the console, the command line and the SDKs7 | On by default; 90 days per Region; longer needs a trail or an event data store |
In the Supabase Auth log, the IP address field is filled only for some events, such as two-factor, passkey and recovery-code actions. For most sign-ins, sign-outs and token events it is empty, and the address of a session has to be read from the ip column of auth.sessions. The auth.audit_log_entries table, which can be queried with SQL, exists only after Write audit logs to the database is switched on under Authentication, Audit Logs.1
A fixed window of 90 or 180 days means that an intrusion discovered later has left no entries at the provider, unless they were copied elsewhere first. Supabase and Vercel can stream entries out through Audit Log Drains46, and in AWS a trail keeps a record beyond the 90 days.7 The playbooks Responding to an administrator account takeover and Responding to unauthorised changes to a website show where each of these logs sits during an incident, and Securing a GitHub repository notes that bypassing push protection leaves an entry.
An application's own audit table
The Supabase Auth log holds sign-ins and account changes. An invoice that a signed-in user edits, or a role an admin page grants, appears in no provider log unless the application writes the entry itself. In Postgres, one design uses a trigger, a function the database runs on every insert, update or delete. A version published by Supabase in 2022 writes each row change into one table, audit.record_version, with the operation, the time, the table, and the new and old row contents as JSON.8 It is packaged as the supa_audit extension and turned on per table:
select audit.enable_tracking('public.invoices');The table holds no column for the user who made a change, so an application that needs the actor has to add it or write its own entries for the actions that matter. Triggers make every write slower. Under roughly 1,000 writes per second the cost is usually too small to notice; busier tables are better served by logging changes outside SQL with a tool such as pgAudit.8
Protection against tampering
Someone who has broken into an account, or a rogue administrator, gains from deleting entries or from stopping the log altogether.3 A trustworthy audit log is therefore one the account it describes cannot rewrite. Measures against this include append-only tables, early copies to storage that cannot be changed, an alarm when logging stops, and a record of every read of the log itself.93
CloudTrail makes changes detectable with hashes. When log file integrity validation is on, it computes a SHA-256 hash (a fixed-length fingerprint that changes when any byte of the file changes) of each log file it delivers, and every hour it writes a digest file listing those hashes, signed with an RSA key. Each digest also carries the signature of the previous one, so the digests form a chain. Checking it shows whether a file was edited or deleted after delivery, and can confirm that no file was delivered for a given period.10
Exchange Online, 2023
In mid-June 2023 a United States federal civilian agency noticed MailItemsAccessed events in its Microsoft 365 audit logs from an application ID that did not normally read mailboxes there. Microsoft found that the attackers had used an acquired Microsoft account (MSA) consumer key to forge tokens that impersonated users, and had taken mail from a small number of accounts. The agency spotted the events by comparing them with a baseline of normal Outlook activity. CISA and the FBI, in a joint advisory on 12 July, knew of no other log that would have revealed the intrusion.11
That level of mail logging then came with Purview Audit (Premium), which needs an E5 or G5 licence.112 On 19 July 2023, a week after the advisory, Microsoft announced that Audit (Standard) customers would receive detailed mail-access logs and more than 30 other log types at no extra cost, with default retention raised from 90 to 180 days.2
Prompt for a coding agent
Add an audit log to this application. Create a table that records, for each security-relevant action, the time, the acting user ID, the source IP address, the action name, the target record and the result. Record successful and failed sign-ins, role and permission changes, creation and deletion of users and API tokens, settings changes, and every action taken from an admin page. Never store passwords, session IDs, tokens or full personal data in it. Give the application's database role only INSERT permission on this table, so entries cannot be edited or deleted. List each place where you added a log call.
See also
- Security logging and alerting
- Log injection
- Personal data in logs
- Rogue administrator account
- Secrets management
- Secret scanning
- Responding to an administrator account takeover
- Category: Incident response
References
- a b c "Auth Audit Logs". Supabase Docs. Supabase.
- a b c Microsoft (19 July 2023). "Expanding cloud logging to give customers deeper security visibility". Microsoft Security Blog.
- a b c d e f "Logging Cheat Sheet". OWASP Cheat Sheet Series.
- a b Supabase (updated 18 November 2026). "Platform Audit Logs". Supabase Docs.
- back "Reviewing the audit log for your organization". GitHub Docs. GitHub.
- a b "Audit Logs". Vercel Docs. Vercel.
- a b "Working with CloudTrail event history". AWS CloudTrail User Guide. Amazon Web Services.
- a b Rice, Oliver (8 March 2022). "Postgres Auditing in 150 lines of SQL". Supabase Blog.
- back "A09:2025 Security Logging and Alerting Failures". OWASP Top 10:2025. OWASP Foundation.
- back "Validating CloudTrail log file integrity". AWS CloudTrail User Guide. Amazon Web Services.
- a b CISA and FBI (12 July 2023, updated 14 July 2023). Cybersecurity Advisory AA23-193A, on monitoring for APT activity targeting Outlook Online. Cybersecurity and Infrastructure Security Agency.
External links
- supa_audit, Supabase on GitHub
- Logging Cheat Sheet, OWASP Cheat Sheet Series