Skip to content

Enforce RBAC on audit timeline, templates, YARA bundle, graph match, tasks, exports, and ACL deletion - #1491

Merged
tomchop merged 2 commits into
mainfrom
fix/security-batch-2-endpoint-rbac
Nov 21, 2026
Merged

tomchop merged 2 commits into
mainfrom
fix/security-batch-2-endpoint-rbac

Conversation

@tomchop

@tomchop tomchop commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Enforces missing per-object, ownership, and role-based authorization checks across API routes and background export queries:

  • RBAC relationship deletion: Require Role.OWNER on relationship.target in DELETE /api/v2/rbac/{id} (core/web/apiv2/rbac.py).
  • Audit timeline: Require Permission.READ on the target object in GET /api/v2/audit/timeline/{id:path} (core/web/apiv2/audit.py).
  • Template rendering: Pass user=httpreq.state.user to Observable.filter() for search_query and require Permission.READ on each observable_ids entry in POST /api/v2/templates/render (core/web/apiv2/templates.py).
  • YARA bundle: Decorate POST /api/v2/indicators/yara/bundle with @rbac.permission_on_ids(roles.Permission.READ) and check Permission.READ on dependencies resolved inside Yara.generate_yara_bundle() / rule_with_dependencies() (core/web/apiv2/indicators.py, core/schemas/indicators/yara.py).
  • Regex indicator matching: Add user filtering to Indicator.search() (using exact type__in filter) and pass httpreq.state.user from POST /api/v2/graph/match (core/schemas/indicator.py, core/web/apiv2/graph.py).
  • Tasks & worker control: Require global WRITE on POST /api/v2/tasks/{task_name}/run and admin (GetCurrentUserWithPermissions(admin=True)) on POST /api/v2/tasks/{task_name}/toggle and POST /api/v2/system/restartworker/{worker_name} regardless of whether RBAC is enabled (core/web/apiv2/tasks.py, core/web/apiv2/system.py).
  • Exports: Record server-set owner on ExportTask, filter tagged_observables_export() through the owner's readable ACLs (failing closed if the owner is disabled/deleted), require global WRITE to create/patch/delete exports, reject duplicate names or colliding normalized file_names on create and rename (409), and restrict export run/patch/delete/content download to the export owner or an admin (core/schemas/task.py, core/database_arango.py, core/web/apiv2/tasks.py).

Upgrade notes

  • Pre-existing exports under RBAC: Existing ExportTask records have owner=None; with RBAC enabled, only admins can run, edit, delete, or download them (and they continue exporting without per-user ACL filtering).
  • Task toggle & worker restart: POST /api/v2/tasks/{task_name}/toggle and POST /api/v2/system/restartworker/{worker_name} now require an admin account even when RBAC is disabled (matching user-management endpoints).

Verification

  • pytest tests/apiv2/{rbac,tasks,templates,timeline,indicators,graph,system}.py tests/schemas/{rbac,yararule}.py — all passing
  • ruff check ., ruff format . --check, and ty check --exit-zero-on-warning — clean

…tasks, exports, and ACL deletion

- Require OWNER on relationship.target in DELETE /api/v2/rbac/{id}
- Require READ on target in GET /api/v2/audit/timeline/{id}
- Enforce Observable READ in POST /api/v2/templates/render (search_query and observable_ids)
- Enforce Indicator READ on IDs and resolved dependencies in POST /api/v2/indicators/yara/bundle
- Filter regex indicators by caller ACL in POST /api/v2/graph/match
- Require global WRITE for task run and admin for task toggle / worker restart
- Track export owner, filter export queries by owner ACLs, and restrict export management and download to owner or admin
@tomchop
tomchop merged commit 4dea25c into main Nov 21, 2026
5 checks passed
@tomchop
tomchop deleted the fix/security-batch-2-endpoint-rbac branch November 21, 2026 18:39
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