Skip to content

[Codex Security] Working demo seeds expose a public admin login in managed tenants - #11

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

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

Conversation

@knowlet

@knowlet knowlet commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Managed provisioning now separates starter content from published demo credentials.

  • The managed callback seeds connector, alert, and case data without creating or moving the demo user.
  • The credential helper refuses noncanonical tenants before database access, closing equivalent internal caller paths.
  • A guarded migration revokes and neutralizes previously seeded non-demo administrators while preserving the canonical demo tenant.
  • Invite-pending customer administration and populated managed dashboards remain supported.

Static Verification Checks

  • Managed credential separation (Passed) — provisioner._default_demo_seeder calls only data seeders, establishing managed provisioning cannot create or relocate published credentials.

  • Credential helper isolation (Passed) — seed_demo._ensure_user rejects noncanonical tenant IDs before database access, establishing alternate callers cannot relocate the wildcard user.

  • Existing account retirement (Passed) — 161_retire_managed_demo_admin.sql deactivates and revokes the exact non-demo principal, establishing deployed vulnerable accounts lose access.

  • Legitimate provisioning preserved (Passed) — test_managed_seed_has_no_published_demo_login asserts pending administration, 30 alerts, and 28 cases, establishing legitimate onboarding remains intact.

  • Regression control coverage (Passed) — auth-escalation-live.yml restores both vulnerable layers and requires failure, establishing coverage detects the original provisioning-to-login path.

  • Static scope verification (Passed) — Final diff inspection replaced runtime commands, establishing source-level attack-path closure without runtime execution.

  • Finding: acf_2411ae535766903574dd203e0f3a41f5

  • Patch: arp_19b3a81d397e890f754d44ce855efb89

  • Base commit: 505d29ea7bb8b8404972fc32577609c43ce98724

  • Patch SHA-256: f8ca5e40f1f89f3b6730b261205028cae8c73c4267a8ecab5b8893854d9636f7

Summary by Sourcery

Separate managed starter-data provisioning from published demo credentials and retire vulnerable seeded administrators.

Bug Fixes:

  • Prevent managed tenant provisioning from creating or relocating the published demo administrator and close equivalent credential-seeding paths.
  • Retire previously seeded non-demo demo administrators by revoking access, neutralizing credentials, and invalidating sessions while preserving the canonical demo tenant.

Enhancements:

  • Preserve invite-pending tenant administration and managed starter alerts and cases during provisioning.

CI:

  • Add regression controls that fail if managed provisioning is reconnected to the published demo credential path.

Tests:

  • Add coverage for noncanonical tenant credential rejection, legacy administrator retirement, and end-to-end managed provisioning without demo login access.

Summary by cubic

Managed provisioning used to call the demo seeder's user helper, creating a deterministic admin with published credentials in every new tenant. Managed tenants now receive only starter alerts, cases, and connectors — the helper refuses non-demo tenants before touching the database, and a migration retires demo admins already seeded into managed tenants.

  • Migration - 161_retire_managed_demo_admin.sql targets users by id, email, and admin role in any tenant other than the canonical demo tenant, deactivating the account, downgrading it to viewer, and revoking its sessions; deliberately re-seeding the demo tenant still restores the full identity.

Written for commit 6a749e6. Summary will update on new commits.

View guided diff Turn on auto-fix

@coderabbitai

coderabbitai Bot commented Nov 17, 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 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Schema and migrations

Retire previously seeded demo administrator accounts in managed tenants while leaving the canonical demo tenant untouched.

  • services/api/migrations/161_retire_managed_demo_admin.sql L1-26

Implementation

Keep managed starter-data seeding separate from the published demo identity, and prevent the shared credential helper from operating on noncanonical tenants.

  • services/api/app/scripts/seed_demo.py L1634-1642
  • services/api/app/services/tenant_provision/provisioner.py L571-576

Tests

Verify the tenant guard runs before database access and that managed provisioning preserves starter data and pending administration without enabling demo login.

  • services/api/tests/test_demo_seed.py L44, L165-177
  • tests/isolation/test_auth_escalation_live.py L208-226, L430-555

Add a negative control that restores the vulnerable managed credential path and requires the isolation suite to detect it.

  • .github/workflows/auth-escalation-live.yml L217-275

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