OBLYTECH Logo
OBLYTECH Logo

Guest User Flow Access: Running in System Context Only When Needed

An Experience Cloud guest user flow should run in system context only when a step cannot work without it, and the guest profile should reach only the objects, fields and Apex classes the page displays. Access problems often trace back to rights granted during testing and left in place. Checking each step against the guest profile before launch catches gaps that a test run as an administrator misses.

Why guest flows need their own access review

Guest users are unauthenticated visitors to an Experience Cloud site, so the flow they trigger runs under a different set of rights from the one your team tested with. Builders usually test as a system administrator, whose access covers nearly all objects and fields. A flow can pass all of its tests in that account and still fail, or expose data, the first time an anonymous visitor reaches the same step.

The gap shows up in three places: which records the flow can read, which records it can change, and which Apex methods the page can call. Each of these comes from the guest profile and any permission sets attached to it, so the review starts there rather than on the flow canvas. How a visitor arrives at the page, whether anonymously or after signing in, changes which profile applies. The setup for that is covered in Experience Cloud login options.

Deciding when system context is justified

System context runs a flow without checking the permissions of the person who started it. That is the reason teams reach for it: a guest often cannot create a related record or read a value directly, so the flow has to act on their behalf. It is also the reason to be careful. Once a step runs in system context, the logic in that step can touch any record it names, whatever the visitor is entitled to see.

A practical test separates the steps that need it from the steps that do not. For each element that reads or writes data, ask whether a guest could already perform the same action through a standard component on the page. If they could, that element should run as the guest. Steps with no such path are the ones that justify system context, and each of those should have a written reason attached.

  1. List every data read and write in the flow, including those inside subflows.
  2. Mark each one that the page’s standard components already let a guest perform.
  3. For the remaining steps, note the specific reason, such as creating a child record on an object the guest profile cannot create.
  4. Move each system context step into its own small flow so the rest of the logic runs as the visitor.

Isolating the sensitive step in a subflow

A subflow that holds one privileged action is easier to audit than a long flow with one privileged element buried in the middle. Keep its inputs narrow, typically a record ID and a single value, and have it return a status rather than whole records. The review then covers two questions, what the subflow accepts and what it changes, instead of the entire parent flow.

Deciding which steps belong in automation at all is a separate exercise, and it should happen before anyone builds the subflow. The mapping work described in Salesforce automation workflows is the right place to settle that question first, so the guest-facing piece stays as small as possible.

Limiting permissions and Apex access for guests

The guest profile and its permission sets define what a visitor can reach. Permission sets tend to pile up during a build. Someone adds one to fix a broken page, the page is later retired, and the permission set stays behind. Review the guest profile the way you would review any other security role. List the objects, fields and Apex classes it reaches, then remove anything the live pages no longer call. Profile and permission set changes belong in the same change record as the rest of the build, and for how that fits a wider project, see configuration and customization work.

Apex deserves its own attention because an exposed method can be called with any input an outside visitor chooses to send. Treat each exposed method as a public endpoint. Do not trust a record ID passed in from the page. Inside the method, check that the record is one the visitor should be able to see, and return just the fields the calling component renders. Error handling needs the same care. A stack trace or an internal field name in an error message tells an attacker more than it helps a user.

Checks for each exposed Apex method

  • Confirm the method is reachable from the components that need it and from nowhere else.
  • Filter results to the records the visitor is allowed to see, rather than returning all matching rows.
  • Reject IDs and values that do not match the expected object type before any query runs.
  • Return a generic message on failure and write the detail to the debug log instead.

Guests who can submit content need the same scrutiny. A visitor who can post a comment or open a case is a source of input the flow must validate. Check the points where a held or removed submission leaves the flow, and compare them with the steps in the community manager moderation routine so that the people reviewing content know what the visitor sees at each stage.

Querying only the fields a page needs

Queries inside a flow or an Apex method often pull a full set of fields because it is quicker during the build. On a guest page, extra fields can reach the visitor’s browser even when the layout does not display them. Name the fields in each query and keep that list to what the component renders. A page that shows a case status and a subject line has no reason to load the case owner’s contact details.

The same discipline helps performance. Smaller result sets return faster and leave less filtering for the browser to do. A field needed for a branch of logic can be read, tested and dropped before the result is returned, so it stays inside the flow and out of the output.

Check this during the build rather than afterwards. A field added to a query for a quick test often stays there, and the next editor assumes it is needed. A short note in the flow description that lists the fields each element reads makes that drift visible, and it gives the later review something concrete to compare against.

A review sequence before a guest flow goes live

Run the checks in a fixed order so that each change is tested under the conditions a real visitor will meet. The logged-out test comes first because its result decides which of the later checks apply. Skipping it and starting with the permission review tends to produce a list of fixes that do not match the failure a visitor actually hits.

  1. Run the flow in a browser session that is not signed in, so the test runs under the guest profile.
  2. Confirm the guest profile reaches each object and field the page displays, and no others.
  3. Call each exposed Apex method with a record the visitor should not see, and check that the result is empty or a generic error.
  4. Read the error messages and debug output for internal names, IDs and stack detail.
  5. Record which steps run in system context and why, in the flow description, for the next editor.

Repeat the sequence after any change to the page layout. A new component can add a field or a method call that the earlier review did not cover, and this is where exposure tends to return. For help planning this work across a wider Salesforce org, see Salesforce implementation.

Questions about guest user flow access

Does every guest flow need system context?

No. A flow that reads records the visitor is already allowed to see can usually run as the guest. Test it logged out first. A step that fails for the guest but works for an administrator is the candidate for closer review, and that is the step where system context is worth considering.

How can I tell a permissions problem from a logic problem?

Reproduce the failure in a session with no login. If the flow works for an internal administrator and fails for the guest, access is the likely cause. If it fails in both sessions, the logic is at fault and the guest profile can be left alone while you fix it.

How often should the guest profile be reviewed?

Review it after each change to a guest page, and on a fixed schedule set by the site owner. A quarterly review is a reasonable starting point for most sites. The right interval depends on how often the site changes, so a site with frequent releases needs a shorter one.

What should a visitor see when a flow step is denied?

A short message saying the request could not be completed, with a suggestion to try again or contact the site team. Leave out record names, IDs, field API names and stack detail. The visitor does not need them, and an attacker can use them.