A permission set picks up Modify All Data. A connected app's IP restrictions are relaxed. A validation rule that blocked bad discounts is gone. Nobody on the team remembers doing it, and the change could have come from an admin, a consultant, a package upgrade, an integration user or an AI coding agent that ran a deploy with someone's saved CLI login.
The first place to look is Setup Audit Trail. It answers "who changed Setup, and when" for most configuration changes, but it has a short memory and some blind spots. This post covers what it records, how to query it, what it misses, and a review routine that catches risky changes while they are still recent.
What Setup Audit Trail records
Setup Audit Trail logs changes made in the Setup area of your org: users, roles, profiles, permission sets, sharing, security settings, connected apps, Apex, flows and much more. In Setup, Quick Find, View Setup Audit Trail shows the 20 most recent changes. The Download link exports the full history for the past 180 days as a CSV. After 180 days the entries are deleted.
The same data is available through the API as the SetupAuditTrail object, which is far more useful than the 20-row page. Each row carries:
| Field | What it tells you |
|---|---|
CreatedDate |
When the change happened (UTC) |
CreatedBy |
The user the change is attributed to |
DelegateUser |
The admin or support user who made the change while logged in as someone else |
ResponsibleNamespacePrefix |
The managed package namespace, when a package made the change |
Section |
The Setup area, such as Manage Users or Security Controls |
Action |
A short code for the kind of change |
Display |
The human-readable description, often with old and new values |
Reading it needs the View Setup and Configuration permission, which most admins and many integration users already have.
Querying the last 30 days
Export the trail with the Salesforce CLI so you can filter it properly:
sf data query --target-org prod --result-format csv --query "
SELECT CreatedDate, CreatedBy.Username, DelegateUser,
ResponsibleNamespacePrefix, Section, Action, Display
FROM SetupAuditTrail
WHERE CreatedDate = LAST_N_DAYS:30
ORDER BY CreatedDate DESC" > setup-audit-30d.csvThen sort by Section and read the Display column. Most investigations end here: the row names the user, the time and the before and after value.
Who "the user" really is
The CreatedBy column is only as useful as your identity hygiene. Four patterns make attribution harder than it looks:
- Login-As. When an admin logs in as another user and changes Setup, the row is attributed to the user they impersonated, and the admin appears in
DelegateUser. Always read both columns. - Managed packages. Changes made by package code show a namespace in
ResponsibleNamespacePrefix. A package upgrade that edits its own components is expected; a package changing something outside its namespace is worth a ticket. - System users. Some changes are attributed to the Automated Process user or another system user. Salesforce has a knowledge article on these entries; they usually trace back to platform automation, not a person.
- Shared logins. A deploy from CI, a script run by a consultant, and a metadata change made by an AI coding agent all show up as whichever user authenticated the
sfCLI. If three integrations and one developer share one login, the trail cannot tell them apart.
The fix for the fourth is structural, not a query. Give each integration its own user, give CI its own deploy user, and do not let an AI coding agent deploy to production with an administrator's personal CLI session. Then the CreatedBy column means something.
What it does not record
Setup Audit Trail is about configuration. Several questions that come up in the same investigation need a different source:
| Question | Where the answer lives |
|---|---|
| Who changed a field on a record? | Field history tracking on that object |
| Who logged in, from where, through which app? | Login History (six months) |
| Who read or exported data through reports or the API? | Event Monitoring log files |
| What happened more than 180 days ago? | Only your own exported copies |
| Who changed a profile's user permissions through a change set? | Not captured, per this Salesforce article |
Two of these matter most in practice. First, the 180-day limit means a quarterly or annual audit cannot rely on the org alone: you need exports. Second, a change set or metadata deploy can change a profile's user permissions without a matching audit row, so compare profile metadata between releases as well as reading the trail.
The trail also survives token revocation. In its Gainsight advisory, Salesforce noted that revoking the app's OAuth tokens did not delete Setup Audit Trail entries or other logs, so revoking first and investigating second is safe.
A weekly review that catches the risky changes
You do not need to read every row. Filter for the changes that alter who can do what, and check each against a ticket or a release:
- Privilege: permission set and permission set group assignments, profile edits, new permission sets, and anything that grants Modify All Data, View All Data, Author Apex, Customize Application or Manage Users.
- Identity and sessions: MFA settings, login IP ranges removed from a profile, session settings, password policies and SSO configuration.
- Integrations: connected app and external client app policy edits (permitted users, IP relaxation, refresh token policy), new remote site settings, named credentials and auth providers.
- Code and automation in production: Apex classes and triggers created or changed, flows activated, sharing rules and org-wide default changes.
- Timing and actor: Setup changes outside your change window, and any Setup change by an integration user, which should almost never happen.
Export the CSV every week and keep it with your change records. Twenty-six weekly files cover a year with overlap, and they are the evidence an auditor asks for when they test change management.
Running the same review with Vulkro for Salesforce
vulkro-sf org audit-trail reads the Setup Audit Trail over its full 180-day window through your own sf CLI login, read-only:
vulkro-sf org audit-trail --target-org prod
vulkro-sf org audit-trail --target-org prod --format ocsf > audit-trail.ocsf.jsonlIt reports SF-AUDIT-TRAIL-001 (High) for a privilege-escalation change in the last 30 days, such as a permission set assignment, a profile edit or a connected app edit, naming the actor and the description. SF-AUDIT-TRAIL-002 (Medium) flags Setup changes outside 06:00 to 22:00 UTC. SF-DEPLOY-AUDIT-001 reports a trail whose history is shorter than it should be, and SF-DEPLOY-AUDIT-002 flags a recent Apex, flow or remote site change with no paired change set or approval row. The OCSF output feeds a SIEM.
vulkro-sf org threat-detection reads the same trail alongside the event logs and flags specific Setup changes to investigate: Modify All Data or View All Data granted (SF-THREAT-008), login IP ranges removed (SF-THREAT-009), MFA weakened (SF-THREAT-010), a connected app policy relaxed (SF-THREAT-011) and a user made a System Administrator (SF-THREAT-012). A detection is a reason to look, not proof of a breach.
FAQ
How long does Salesforce keep Setup Audit Trail history?
180 days. The Setup page shows the 20 most recent changes, and the Download link or the SetupAuditTrail object gives you the full 180 days. Anything older is deleted, so export it on a schedule if you need a longer record.
Does Setup Audit Trail show changes to record data?
No. It covers Setup and configuration changes. Changes to field values on records are recorded by field history tracking on that object, and data access is recorded by Event Monitoring.
Can I tell when a managed package changed my org?
Usually. Changes made by package code carry the package namespace in the ResponsibleNamespacePrefix field (labelled Source Namespace Prefix). Changes an admin makes to package components through Setup are attributed to that admin.
See the org audit-trail reference and the Salesforce platform teams use case, or start a 14-day trial. Related: Salesforce Event Monitoring for security investigations and field history on the User object.