Verhindere, dass Raum-Endpunkte verraten, welche Raum-IDs es gibt, und sichere sie mit einem Test gegen Außenstehende ab.
Unbekannte und fremde Räume antworten bei Mitglieder-, Einladungs-, Eigentümer- und Freigabe-Aktionen gleich mit 403. Der neue Test prüft alle Raum-Endpunkte als Außenstehender, Leser und Mitglied. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac3c3d81fe
commit
e47f50d513
2 files changed
+47
-5
No files matched your search
@@ -46,8 +46,11 @@ def _created(path: str, payload: dict) -> JSONResponse:
|
||||
|
||||
|
||||
def _require_owner(conn, account_id: UUID, room_id: UUID) -> dict:
|
||||
room = _room(conn, room_id)
|
||||
if room["owner_id"] != account_id:
|
||||
# An unknown room and a room owned by someone else answer alike: no way to probe ids.
|
||||
room = conn.execute(
|
||||
"SELECT * FROM data_rooms WHERE id = %s AND kind = 'organization'", (room_id,)
|
||||
).fetchone()
|
||||
if room is None or room["owner_id"] != account_id:
|
||||
raise forbidden("Das darf nur der Eigentümer des Datenraums.")
|
||||
return room
|
||||
|
||||
@@ -287,7 +290,6 @@ def transfer_owner(
|
||||
@router.get("/api/v1/rooms/{room_id}/exposure")
|
||||
def exposure(room_id: UUID, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||
"""Own cases and matters: shared with this room (`room`) or filed here but not shared (`private`)."""
|
||||
_room(conn, room_id)
|
||||
if room_role(conn, principal.account_id, room_id) is None:
|
||||
raise forbidden()
|
||||
result: dict = {}
|
||||
@@ -318,7 +320,6 @@ def set_my_content(
|
||||
conn: Connection = Depends(get_conn),
|
||||
):
|
||||
"""`room`: share every own entry filed in this room with it. `private`: end all own shares to it."""
|
||||
_room(conn, room_id)
|
||||
role = room_role(conn, principal.account_id, room_id)
|
||||
if role is None:
|
||||
raise forbidden()
|
||||
@@ -475,8 +476,8 @@ def invite(
|
||||
principal: Principal = Depends(get_principal),
|
||||
conn: Connection = Depends(get_conn),
|
||||
):
|
||||
require_room_manager(conn, principal.account_id, body.room_id)
|
||||
room = _room(conn, body.room_id)
|
||||
require_room_manager(conn, principal.account_id, room["id"])
|
||||
email = normalize_email(body.email)
|
||||
if account_by_email(conn, email):
|
||||
raise unprocessable("Es gibt bereits ein Konto. Füge die Person als Mitglied hinzu.")
|
||||
|
||||
Reference in new issue
Block a user