Skip to content

fix: Restrict subscription PUT/DELETE to owner/admin (BOLA) (#182) - #206

Closed
AndriiPasternak31 wants to merge 2 commits into
Abilityai:mainfrom
AndriiPasternak31:AndriiPasternak31/fix-subscription-bola
Closed

AndriiPasternak31 wants to merge 2 commits into
Abilityai:mainfrom
AndriiPasternak31:AndriiPasternak31/fix-subscription-bola

Conversation

@AndriiPasternak31

Copy link
Copy Markdown
Contributor

Summary

  • Pentest finding 3.2.5 (CVSS 4.8 Medium): PUT/DELETE /api/subscriptions/agents/{name} used can_user_access_agent (owners + shared users + admins) instead of can_user_share_agent (owners + admins only)
  • Shared users could hot-swap Claude subscription credentials or clear them entirely, enabling billing abuse and DoS
  • Fix: swap can_user_access_agent → can_user_share_agent on lines 184 and 246 of subscriptions.py

Changes

  • src/backend/routers/subscriptions.py — 2-line predicate swap + comment updates
  • tests/unit/test_subscription_auth.py — New unit tests with mocked non-admin user verifying 403 on both PUT and DELETE
  • docs/memory/changelog.md — Changelog entry

Test Plan

  • New unit tests pass: cd tests/unit && python3 -m pytest test_subscription_auth.py -v (4/4 passed)
  • Existing integration tests unaffected: cd tests && python -m pytest test_subscriptions.py -v
  • Manual: verify shared user gets 403 on PUT/DELETE subscription endpoints

CSO Audit Notes

Full authorization predicate audit across all routers found 1 additional variant:

  • agent_ssh.py:56 — SSH credential generation also uses can_user_access_agent (separate issue recommended)

Closes #182

Generated with Claude Code

AndriiPasternak31 and others added 2 commits March 27, 2026 02:03
…ityai#182)

Pentest finding 3.2.5 (CVSS 4.8): PUT/DELETE /api/subscriptions/agents/{name}
used can_user_access_agent (allows shared users) instead of can_user_share_agent
(owner/admin only). Shared users could hot-swap or clear agent credentials.

- Replace can_user_access_agent with can_user_share_agent at lines 184, 246
- Add unit tests with mocked non-admin user verifying 403 on both endpoints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update code snippet in subscription-management.md to reflect the
can_user_share_agent fix from issue Abilityai#182.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vybe

vybe commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Closing as duplicate — the fix was already merged to main via commits a2c4012 and 46bc23a. Issue #182 is closed.

The unit tests in this PR (test_subscription_auth.py) are valuable and not present in the existing merge — consider submitting them as a separate PR if test coverage for this fix is desired.

Also, the CSO audit note about agent_ssh.py:56 using can_user_access_agent is worth tracking as a separate issue.

@vybe vybe closed this Mar 27, 2026
@AndriiPasternak31
AndriiPasternak31 deleted the AndriiPasternak31/fix-subscription-bola branch April 25, 2026 17:59
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.

SEC: Agent Subscription Management by Shared Users (BOLA)

2 participants