Roles cause aggregation sort memory limit error on large dataset

With flexible sync roles enabled I receive the following error when including $sort in an aggregation pipeline. This error does not appear when the role is removed or a function is ran as system. My collection is 500k documents.

QueryExceededMemoryLimitNoDiskUseAllowed: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting.

The aggregation pipeline

const agg = [
  {
    '$sort': {
      '_id': -1
    }
  }, {
    '$limit': 10
  }
];

let result = await collection.aggregate(agg)

Flexible sync role. The role checks user data to ensure a company field in custom_date matches the company field on the document. Both are ObjectId

{
  "rules": {
    "Invoices": [
      {
        "name": "CompanyMember",
        "applyWhen": {},
        "read": {
          "company": "%%user.custom_data.company"
        },
        "write": {
          "company": "%%user.custom_data.company"
        }
      }
    ]
  },
  "defaultRoles": [
    {
      "name": "read-write",
      "applyWhen": {},
      "read": true,
      "write": false
    }
  ]
}

Is this a bug, or am I making a mistake in my pipeline or flexible sync roles?