oliver-zehentleitner / maity

hub: GET /avatars/public/{digest} for an agent checks that one agent, not the owner's whole listed_agents; picture rows read once

Sign in to report

tsk-nstm4qq579wc Open

Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: slow path on a public route.

What is wrong

  • routes/avatars.py:74-86 -> avatars.public (hub/src/maity_hub/avatars.py:427-447) -> is_public (avatars.py:396-421). For an agent, is_public builds public_people.listed_agents(conn, owner) (public_people.py:100-138) only to test whether this one agent is in it. listed_agents runs public_agents.served (served check, profile hold read, memberships with public_projects.served per public project), latest_session and public_urls for every agent of the owner.
  • A public page shows many pictures, each its own GET, so cost grows with agents x projects per page view.
  • public() reads the picture rows twice for the same owner: _rows at avatars.py:442, then stored() calls _rows again (:308).
  • Not on tsk-m49x61yesmb6 (its item 3 covers only the people/contacts pages).

Proposal

  • Factor the per-agent rule out of listed_agents into public_people.lists_agent(conn, owner, agent); listed_agents loops over it, is_public calls it once, so the rule stays in one place.
  • Pass the Picture already read into stored().

Effort / risk: S. Low-medium (§6.10 public-picture rule); test_avatars covers the public cases.