Skip to content

Commit ab95445

Browse files
committed
fix(privileges): route ActivityPub URIs to fediverse pseudo-user check
When a remote ActivityPub actor sends a signed request, req.uid is set to the actor's URI. Previously, non-numeric uids were treated as group names and checked against registered-users privileges, bypassing the expected permission model. Remote actors are now routed to the fediverse pseudo-user (-2) check, respecting the fediverse group's privileges on the category. This preserves the admin-controlled UX while closing the bypass. Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF
1 parent 8c43a99 commit ab95445

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/privileges/helpers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const user = require('../user');
99
const categories = require('../categories');
1010
const plugins = require('../plugins');
1111
const utils = require('../utils');
12+
const activitypub = require('../activitypub');
1213

1314
const helpers = module.exports;
1415

@@ -75,6 +76,11 @@ async function isAllowedToCids(privilege, uidOrGroupName, cids) {
7576

7677
const groupKeys = cids.map(cid => `cid:${cid}:privileges:groups:${privilege}`);
7778

79+
// Remote ActivityPub actors (URIs) are treated as the fediverse pseudo-user
80+
if (activitypub.helpers.isUri(uidOrGroupName)) {
81+
return await isSystemGroupAllowedToCids(privilege, -2, cids);
82+
}
83+
7884
// Group handling
7985
if (!utils.isNumber(uidOrGroupName) && (uidOrGroupName || '').length) {
8086
return await checkIfAllowedGroup(uidOrGroupName, groupKeys);
@@ -91,6 +97,11 @@ async function isAllowedToCids(privilege, uidOrGroupName, cids) {
9197

9298
async function isAllowedToPrivileges(privileges, uidOrGroupName, cid) {
9399
const groupKeys = privileges.map(privilege => `cid:${cid}:privileges:groups:${privilege}`);
100+
// Remote ActivityPub actors (URIs) are treated as the fediverse pseudo-user
101+
if (activitypub.helpers.isUri(uidOrGroupName)) {
102+
return await isSystemGroupAllowedToPrivileges(privileges, -2, cid);
103+
}
104+
94105
// Group handling
95106
if (isNaN(parseInt(uidOrGroupName, 10)) && (uidOrGroupName || '').length) {
96107
return await checkIfAllowedGroup(uidOrGroupName, groupKeys);

0 commit comments

Comments
 (0)