Skip to content

Create app bug fix and tests#426

Merged
eguerrant merged 3 commits into
mainfrom
create_app_bug
Apr 28, 2026
Merged

Create app bug fix and tests#426
eguerrant merged 3 commits into
mainfrom
create_app_bug

Conversation

@eguerrant
Copy link
Copy Markdown
Contributor

@eguerrant eguerrant commented Apr 27, 2026

If an attacker can pre-create a group named App--Owners, it to be silently adopted as the owner group when the target app is later created, granting any existing group owners ownership of that app.

Added fix and tests.

  • Groups with the app group owner name pattern will only be used as the owner group during app creation if the group has no owners
  • Banned the use of the reserved 'app group prefix'-name-'app owner group suffix' name pattern in group creation and group requests
  • Banned the reserved app group prefix from being used with vanilla groups (both new groups/group requests and changing group type)

@eguerrant eguerrant marked this pull request as ready for review April 28, 2026 00:14
Comment thread api/views/resources/app.py
Comment thread api/views/resources/group.py
@eguerrant eguerrant merged commit 5a8e85f into main Apr 28, 2026
6 checks passed
@eguerrant eguerrant deleted the create_app_bug branch April 28, 2026 21:49
somethingnew2-0 added a commit that referenced this pull request Apr 29, 2026
Two PRs merged to main against the (now-replaced) Flask backend; the
operation-layer changes auto-merged during the rebase, this commit
ports the matching view-layer changes to the FastAPI routers and
fixes the upstream-added tests for the new harness.

PR #427 (App group rebind bug)
- api/routers/groups.py PUT /api/groups/{id}: refuse to rebind an
  AppGroup to a different `app_id` unless the caller is an Access
  admin or owns the target app. Apply the rebind when the type isn't
  also changing — type-change rebinds keep going through
  ModifyGroupType. The Flask version relied on
  `schema.load(request.json, instance=group, partial=True)` to apply
  app_id; the FastAPI router updates it explicitly.

PR #426 (Create app + reserved-prefix group bug fixes)
- api/routers/apps.py POST /api/apps: 409 if an owner group with the
  target name already exists *with owners* — otherwise CreateApp would
  silently absorb a squatted owner group.
- api/routers/groups.py POST /api/groups: 400 on reserved prefixes
  that don't match the group type (`App-` for non-AppGroup, `Role-`
  for non-RoleGroup, the `-Owners` suffix on a directly-created
  AppGroup).
- api/routers/groups.py PUT /api/groups/{id}: same prefix check, but
  resolved against the *final* group type so a legitimate
  OktaGroup→AppGroup/RoleGroup conversion still works. Wrap
  ModifyGroupType in try/except for ValueError → 400.

Test ports
- Rewrote Flask-era signatures (`app: Flask`, `client: FlaskClient`,
  `db: SQLAlchemy`) to the FastAPI harness (`FastAPI`, `TestClient`,
  `Any`). Added the missing `url_for` fixture to the upstream-added
  tests, swapped `rep.get_json()` → `rep.json()`, and replaced one
  `app.config["CURRENT_OKTA_USER_EMAIL"]` access with `settings.…`.

Verified: `pytest tests/` 283/283, `ruff check`/`format`, `mypy .`
all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants