Skip to content

Enforce access rules for organisations, invites, members, and references - #169

Merged
otigges merged 2 commits into
mainfrom
fix-access-control
Oct 6, 2026
Merged

otigges merged 2 commits into
mainfrom
fix-access-control

Conversation

@otigges

@otigges otigges commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes gaps in the access rules that an internal review found. Each rule now has a regression test.

  • Organisation delete: removes an unchecked delete event on the organisations page and the context function behind it. Deleting an organisation goes only through Organisations.delete_org_by_id!/2, which checks the :delete_organisation right.
  • Mitigations: risk_id is no longer cast from parameters, so a mitigation stays in its risk.
  • Threats: create_threat/3 and update_threat/3 check that the system and the asset belong to the threat's organisation.
  • Invites: invites are listed and accepted only for users with a confirmed email address. delete_invite/1 is replaced by reject_invite/2 (only the invitee) and revoke_invite/2 (needs the right :invite_new_members).
  • Members: removing a member is checked with the membership rights (:delete_member). Before, the check used the platform RBAC module and always failed.

Changes in behaviour

  • A user with an unconfirmed email address does not see invitations on /organisations. The page shows a notice with a link to send the confirmation email again. Registration through an invite link is unchanged.
  • The members page shows an error message when a member cannot be removed or an invite cannot be revoked.
  • A threat can no longer be linked to a system of another organisation, also not by a user who is a member of both.

Also in this branch

  • docs/audit/ is ignored by git, and docs/README.md says so.

Tests

mix test: 154 tests, 0 failures (139 before, 15 new). Run with Elixir 1.20.4 and PostgreSQL 18.

Not included

The four new user messages are not added to priv/gettext. An extraction would also change many unrelated entries, because the files are out of date. The English text is shown as fallback.

🤖 Generated with Claude Code

otigges and others added 2 commits October 6, 2026 20:53
docs/audit/ is ignored by git. The repository is public, and audit
reports can describe weaknesses that are not fixed yet.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Remove the unchecked organisation delete event and context function.
  Deleting an organisation goes through delete_org_by_id!/2 only.
- Do not cast risk_id of a mitigation from parameters.
- Check that the system and the asset of a threat belong to the
  threat's organisation.
- List and accept invites only for users with a confirmed email address.
- Replace delete_invite/1 by reject_invite/2 (invitee) and
  revoke_invite/2 (right :invite_new_members).
- Check :delete_member with the membership rights when a member is
  removed, and handle a refusal in the members page.

Adds regression tests for each rule.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@otigges
otigges merged commit 7812950 into main Oct 6, 2026
2 checks passed
@otigges
otigges deleted the fix-access-control branch October 6, 2026 19:12
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