Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Reviewer's GuideSchema and migrationsRetire previously seeded demo administrator accounts in managed tenants while leaving the canonical demo tenant untouched.
ImplementationKeep managed starter-data seeding separate from the published demo identity, and prevent the shared credential helper from operating on noncanonical tenants.
TestsVerify the tenant guard runs before database access and that managed provisioning preserves starter data and pending administration without enabling demo login.
Add a negative control that restores the vulnerable managed credential path and requires the isolation suite to detect it.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…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>
Managed provisioning now separates starter content from published demo credentials.
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_2411ae535766903574dd203e0f3a41f5Patch:
arp_19b3a81d397e890f754d44ce855efb89Base commit:
505d29ea7bb8b8404972fc32577609c43ce98724Patch SHA-256:
f8ca5e40f1f89f3b6730b261205028cae8c73c4267a8ecab5b8893854d9636f7Summary by Sourcery
Separate managed starter-data provisioning from published demo credentials and retire vulnerable seeded administrators.
Bug Fixes:
Enhancements:
CI:
Tests:
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.
161_retire_managed_demo_admin.sqltargets 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.