Summary

Unleash: A project member can reorder activation strategies belonging to any other project / environment (cross-project integrity write), bypassing project RBAC and the audit log

Advisory details

Summary

Unleash scopes write permissions per project and per environment: a user with the UPDATE_FEATURE_STRATEGY permission on project A is supposed to be able to mutate activation strategies only within project A. The endpoint POST /api/admin/projects/:projectId/features/:featureName/environments/:environment/strategies/set-sort-order violates this. The RBAC middleware authorizes the request against the :projectId taken from the URL, but the handler then writes the strategy IDs supplied in the request body directly to the database by primary key, without ever verifying that those strategy IDs actually belong to the URL's project / feature / environment. A low-privilege member of any one project can therefore reorder the activation strategies of features in any other project and environment — including projects they have no role on at all — by putting their own project in the URL (to satisfy RBAC) and the victim project's strategy IDs in the body.

The sibling write paths in the same service (updateStrategy, patchStrategy, deleteStrategy) all call validateUpdatedProperties(), which rejects a strategy whose stored projectId/featureName does not match the URL context. The set-sort-order handler is the one sibling that omits this check — an asymmetric, incomplete enforcement. Activation-strategy ordering is security-relevant: the first matching strategy determines a flag's rollout/variant outcome, so an attacker can flip which strategy "wins" for another team's feature flag in production. As a secondary effect, the operation that mutates the victim's strategies is recorded (if at all) under the attacker's project/feature context, so the tampering does not appear in the victim project's audit trail.

Affected code (v8.0.0)

The route is registered with the project-scoped permission UPDATE_FEATURE_STRATEGY (correct), and the handler forwards the URL params as the "context" plus the raw request body:

src/lib/features/feature-toggle/feature-toggle-controller.ts

{
    method: 'post',
    path: `${PATH_STRATEGIES}/set-sort-order`,
    handler: this.setStrategiesSortOrder,
    permission: UPDATE_FEATURE_STRATEGY,
    // ...
}

async setStrategiesSortOrder(req, res): Promise<void> {
    const { featureName, projectId, environment } = req.params;
    await this.transactionalFeatureToggleService.transactional((service) =>
        service.updateStrategiesSortOrder(
            { featureName, environment, projectId },   // URL context only
            req.body,                                   // attacker-controlled [{id, sortOrder}]
            req.audit,
        ),
    );
    res.status(200).send();
}

The service writes each body-supplied id directly. It reads the URL-context strategies only to build the audit-event payload (existingOrder/newOrder); it never validates that the IDs in sortOrders belong to that context:

src/lib/features/feature-toggle/feature-toggle-service.ts

async unprotectedUpdateStrategiesSortOrder(context, sortOrders, auditUser): Promise<Saved<any>> {
    const { featureName, environment, projectId: project } = context;
    const existingOrder = (await this.getStrategiesForEnvironment(project, featureName, environment))
        .sort(sortStrategies).map((s) => s.id);
    // ...
    await Promise.all(
        sortOrders.map(({ id, sortOrder }) =>
            this.featureStrategiesStore.updateSortOrder(id, sortOrder),   // NO project/feature/env check
        ),
    );
    // ...event built from the URL context, not from the strategies actually mutated...
}

The store updates by primary key with no scoping predicate:

src/lib/features/feature-toggle/feature-toggle-strategies-store.ts

async updateSortOrder(id: string, sortOrder: number): Promise<void> {
    await this.db<IFeatureStrategiesTable>(T.featureStrategies)
        .where({ id })
        .update({ sort_order: sortOrder });
}

Contrast the sibling mutators, which DO bind the target strategy to the URL context (validateUpdatedProperties throws InvalidOperationError when existingStrategy.projectId !== projectId or existingStrategy.featureName !== featureName):

// unprotectedUpdateStrategy / patchStrategy / deleteStrategy:
const existingStrategy = await this.featureStrategiesStore.get(id);
this.validateUpdatedProperties(context, existingStrategy);   // <-- the check set-sort-order is missing

Attacker model / precondition

The attacker is an authenticated Unleash user who holds the UPDATE_FEATURE_STRATEGY permission on at least one project — i.e. any standard project member/editor, the second-lowest privilege tier. They do not need any role on the victim project. The precondition is a multi-project instance: project creation and per-project roles are Pro/Enterprise features, so this is the normal Unleash Pro/Enterprise deployment shape (the OSS edition pins everything to the single default project, which removes the cross-project dimension but the same missing-binding defect still allows reordering strategies of any feature/environment within default). The attacker must know (or enumerate) the target strategy UUIDs; strategy IDs are surfaced through several admin/read endpoints and are guessable in scope by a user who can read project listings. Change Requests do not mitigate it: the stopWhenChangeRequestsEnabled gate is evaluated against the attacker's own URL project, not the victim's, and Change Requests are off by default. The integrity impact is bounded to the sort_order column (the attacker cannot change parameters, constraints, or segments via this endpoint), which is why this is rated Medium rather than High.

Impact

A project member can silently alter the activation-strategy evaluation order of feature flags in projects and environments they have no authorization over. Because Unleash evaluates strategies in order and the first enabling strategy decides a flag's served value/variant, reordering can change a production flag's rollout behaviour for another team — e.g. promoting a permissive flexibleRollout/default strategy ahead of a restrictive userWithId/constraint-gated one, effectively turning a flag on (or changing which variant is served) for users the owning team intended to exclude. This is a cross-tenant integrity / authorization-bypass write. It additionally undermines accountability: the mutation is attributed to the attacker's URL context rather than the victim feature, so the change is absent from the victim project's audit/event history (in the lab the successful cross-project write produced no feature-strategy-update event for the victim feature at all), hampering detection and forensics.

Proof of Concept (complete — runs on 127.0.0.1 only)

Lab only. Everything binds to 127.0.0.1; no hosted instance is touched. Requires Docker.

1. Start PostgreSQL and Unleash v8.0.0

docker network create unleash-poc

docker run -d --name unleash-pg --network unleash-poc \
  -e POSTGRES_DB=unleash -e POSTGRES_USER=unleash -e POSTGRES_PASSWORD=unleash \
  postgres:16-alpine
sleep 8

docker run -d --name unleash-srv --network unleash-poc -p 127.0.0.1:4242:4242 \
  -e DATABASE_HOST=unleash-pg -e DATABASE_NAME=unleash \
  -e DATABASE_USERNAME=unleash -e DATABASE_PASSWORD=unleash -e DATABASE_SSL=false \
  -e INIT_ADMIN_API_TOKENS='*:*.unleash-insecure-admin-api-token' \
  unleashorg/unleash-server:8.0.0
sleep 25
curl -s http://127.0.0.1:4242/health    # {"health":"GOOD"}

2. Simulate a Pro/Enterprise (multi-project) deployment

Per-project roles and >1 project are Pro/Enterprise features; the official OSS image hard-pins requests to the default project via an unrelated edition gate (resolveIsOss). To reproduce the cross-project dimension on the public image, lift only that edition gate (this does NOT touch the vulnerable set-sort-order code path). On a real Pro/Enterprise instance this step is unnecessary — multiple projec

References