Skip to content

[Codex Security] Production provisioning restores a known-password platform admin - #12

Closed
knowlet wants to merge 1 commit into
mainfrom
codex-security/arp_34fea74ea824ae1ac3079bffd493078e
Closed

knowlet wants to merge 1 commit into
mainfrom
codex-security/arp_34fea74ea824ae1ac3079bffd493078e

Conversation

@knowlet

@knowlet knowlet commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Provisioning now seeds starter SOC data without creating or reassigning the deterministic demo administrator.

  • _default_demo_seeder no longer imports or calls _ensure_user, removing the provisioning path to the published demo credentials.
  • Default HTTP provisioning cannot select another seeder, so seed_demo=true no longer creates an active wildcard-role account for the new tenant.
  • New tenants still receive the inactive, invite-pending administrator associated with the waitlist email.
  • Connector, alert, and case seeding remains intact for operators who request starter content.
  • Regression coverage traps future demo-identity calls while asserting both legitimate data-seeding helpers remain reachable.

Static Verification Checks

  • Default identity sink removed (Passed) — services/api/app/services/tenant_provision/provisioner.py _default_demo_seeder imports only data seeders, establishing the known-password identity sink is unreachable from default provisioning.

  • HTTP callers cannot bypass (Passed) — provision_from_waitlist and provision_tenant expose no caller-controlled seeder, establishing HTTP inputs cannot restore the removed identity path.

  • Invite onboarding remains intact (Passed) — provisioner.py still creates an inactive invite-pending tenant administrator, establishing normal onboarding retains its intended identity flow.

  • Starter content remains seeded (Passed) — test_default_demo_seeder_never_creates_demo_identity asserts both data helpers run and the identity trap remains untouched, establishing starter content is preserved.

  • Final diff boundary review (Passed) — Static inspection of git diff found identity removal and preserved data calls, establishing closure without runtime execution.

  • Finding: acf_131850631d40f60981dc8e262995f8c8

  • Patch: arp_34fea74ea824ae1ac3079bffd493078e

  • Base commit: 2a0d550165b9f82108a3fe1c487c44aa96ed1b24

  • Patch SHA-256: 65f55fe7a50c3e08c9e58b8e5700a1d47a7d72e7e2b4c1d254a5ef0a3108f73c

Summary by Sourcery

Remove the known-password demo identity from default tenant provisioning while retaining starter SOC data and invite-based administrator onboarding.

Bug Fixes:

  • Prevent tenant provisioning from creating the deterministic demo administrator with published credentials.

Enhancements:

  • Preserve starter connector, alert, and case seeding while relying on the tenant's normal invite-pending administrator flow.

Tests:

  • Add regression coverage ensuring default provisioning invokes starter-data seeders without calling the demo identity helper.

Summary by cubic

Prevents production provisioning from creating the deterministic demo administrator with published credentials.

  • _default_demo_seeder no longer calls _ensure_user; it seeds connectors, alerts, and cases only.
  • New tenants keep the inactive, invite-pending administrator, and HTTP provisioning offers no way to restore the demo identity path.
  • Adds a regression test that fails if provisioning ever recreates the known-password demo user.

Written for commit e8e06aa. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai

sourcery-ai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Remove the demo identity helper from the default provisioning seeder while keeping connector, alert, and case seeding, preventing provisioning from creating the known-password administrator.

  • services/api/app/services/tenant_provision/provisioner.py L563-568 (+3 small edits)

Tests

Add regression coverage that traps calls to the demo identity helper and verifies both starter-data seeders still run.

  • services/api/tests/test_tenant_provision.py L49, L563-598

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

knowlet added a commit that referenced this pull request Nov 19, 2026
…emo admin (beenuar#1966)

## Summary

Default managed-tenant provisioning no longer creates or relocates the
published demo administrator. On beenuar/AiSOC main at `5f64fb73`
(v23.5.1), `_default_demo_seeder` still imports and calls
`seed_demo._ensure_user`, which upserts the deterministic user
`demo@example.com` with password `aisoc-demo`, role `admin`, and
`is_active=True` (and moves an existing row into the newly provisioned
tenant). Because `provision_from_waitlist` defaults to `seed_demo=True`
and the HTTP provision endpoint (`POST /v1/admin/tenants/provision`)
exposes no seeder field, a normal promote takes that path and publishes
a known-password admin into managed tenants. This branch removes that
path.

## Type of change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Documentation update
- [ ] Refactor / tech debt
- [ ] CI / infra change

## Related issues

Addresses the same provisioning path reported in knowlet/AiSOC #11 and
#12.

## Changes

- `services/api/app/services/tenant_provision/provisioner.py` —
`_default_demo_seeder` now seeds connectors, alerts, and cases only; it
no longer imports or calls `_ensure_user`, so default provisioning never
publishes the demo admin.
- `services/api/app/scripts/seed_demo.py` — `_ensure_user` refuses any
tenant other than the canonical demo tenant before it reads or writes
the deterministic user, so the known-password identity can only ever
land in the canonical demo tenant.
- `services/api/app/.../migrations/163_retire_managed_demo_admin.sql` —
retires already-seeded non-demo administrators and leaves the canonical
demo tenant alone. Numbered 163 because `161_disposition_source.sql` is
already on current beenuar main.
- New tenants still receive the inactive, invite-pending administrator
tied to the waitlist email (`hashed_password="!invite-pending"`,
`role="tenant_admin"`, `is_active=False`) — unchanged.
- Tests: `services/api/tests/test_tenant_provision.py`,
`services/api/tests/test_demo_seed.py`, and
`tests/isolation/test_auth_escalation_live.py`.

## Testing

- [x] Unit tests added / updated
- [ ] Integration tests pass locally
- [x] Manually tested (describe steps below)

<details>
<summary>Manual test steps</summary>

1. `python -m pytest services/api/tests/test_tenant_provision.py
services/api/tests/test_demo_seed.py` — 4 passed
(`test_default_demo_seeder_never_creates_demo_identity`,
`test_demo_credentials_refuse_a_non_demo_tenant`,
`test_demo_seeder_called_when_enabled`,
`test_demo_seeder_failure_does_not_break_provisioning`).
2. `ruff check` — All checks passed; `ruff format --check` — already
formatted.

</details>

## Screenshots (if UI changes)

N/A — no UI changes.

## Checklist

- [x] My code follows the style guidelines of this project (`ruff`,
`eslint`, `gofmt`)
- [x] I have performed a self-review of my own code
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally
- [ ] I have updated documentation as needed (README, CHANGELOG,
CONTRIBUTING)
- [x] My changes do not introduce new linter warnings
- [x] I have checked for sensitive data / credentials in my diff

## Eval harness (required for substrate / playbook / detection changes)

- [x] Not applicable — this PR does not touch substrate, playbooks,
detections, or eval inputs
- [ ] No axis regressed
- [ ] An axis regressed; rationale and follow-up are described in the
Summary above

---------

Signed-off-by: knowlet <knowlet@pm.me>
@knowlet knowlet closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant