The Script That Granted Everyone Everything

Medium

· Database

Incident

SEV-1

BUG-PARDOT

Priority: Critical (data exposure) · reported by trust & safety

Time to fix: 20 min

Failing checks on the shipped build

  • only in-scope users are granted

    expected 1 but got 3

  • an empty scope changes nobody

    expected 0 but got 1

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the data through the query or the repository code; compare the rows it returns with the rows the report expects.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Salesforce Pardot · 2019

Modelled on the Salesforce Pardot incident (May 2019): a database script intended to adjust permissions for one feature applied a broad grant instead, giving every user in affected orgs read and write access to all company data. Salesforce shut the service down for over 15 hours while it unwound the change.

grants.js applies a permission change and ignores the scope it was given.

Fix applyGrant so it only touches users inside the requested scope.

Code map

// Applies a permission grant to the users in scope.
exports.applyGrant = function (users, scope, permission) {
  var changed = 0;
  for (var i = 0; i < users.length; i++) {
    var u = users[i];
    if (u.permissions.indexOf(permission) === -1) {
      u.permissions.push(permission);
      changed++;
    }
  }
  return changed;
};

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

The Script That Granted Everyone Everything — Bug Hunt

Modelled on the Salesforce Pardot incident (May 2019): a database script intended to adjust permissions for one feature applied a broad grant instead,…

  • Language: JavaScript
  • Layer: Database
  • Difficulty: Medium
  • Concepts: Permissions, Scoping
  • Modelled on: Salesforce Pardot · 2019
  • Visible tests: only in-scope users are granted; an empty scope changes nobody
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (data exposure))
  • Ticket: BUG-PARDOT
  • Reported by: trust & safety
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • only in-scope users are granted — expected 1 but got 3
  • an empty scope changes nobody — expected 0 but got 1

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the data through the query or the repository code; compare the rows it returns with the rows the report expects.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Modelled on the Salesforce Pardot incident (May 2019): a database script intended to adjust permissions for one feature applied a broad grant instead, giving every user in affected orgs read and write access to all company data. Salesforce shut the service down for over 15 hours while it unwound the change.

grants.js applies a permission change and ignores the scope it was given.

Fix applyGrant so it only touches users inside the requested scope.

Bug report

BUG-PARDOT · Priority: Critical (data exposure) · Reported by: trust & safety

applyGrant(users, scope, permission) must:

  • set permission on users whose orgId is in scope.orgIds AND whose role is in scope.roles
  • leave every other user's permissions exactly as they were
  • return the number of users changed

Observed: the scope is accepted but never consulted; every user in the store is granted the permission.

Logs

[grants] applied "write:all" to 100% of users (scope requested: 1 org, role=admin)
[grants] service disabled pending remediation

The code as shipped

src/authz/grants.js (editable)

// Applies a permission grant to the users in scope.
exports.applyGrant = function (users, scope, permission) {
  var changed = 0;
  for (var i = 0; i < users.length; i++) {
    var u = users[i];
    if (u.permissions.indexOf(permission) === -1) {
      u.permissions.push(permission);
      changed++;
    }
  }
  return changed;
};

Read-only context: src/authz/POLICY.js.

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More JavaScript bug hunts.