Details
Suggested Fix
Make every single-row resource lookup take the workspace predicate. Treat foreign-workspace rows as 404, not 200, so the endpoint does not even confirm that the target ID exists.
--- a/src/praisonai-platform/praisonai_platform/services/agent_service.py
+++ b/src/praisonai-platform/praisonai_platform/services/agent_service.py
@@ -50,9 +50,12 @@ class AgentService:
await self._session.flush()
return agent
- async def get(self, agent_id: str) -> Optional[Agent]:
- """Get agent by ID."""
- return await self._session.get(Agent, agent_id)
+ async def get(self, workspace_id: str, agent_id: str) -> Optional[Agent]:
+ """Get agent by ID, scoped to a workspace."""
+ stmt = select(Agent).where(
+ Agent.id == agent_id, Agent.workspace_id == workspace_id
+ )
+ return (await self._session.execute(stmt)).scalar_one_or_none()
async def list_for_workspace(
self,
@@ -71,6 +74,7 @@ class AgentService:
async def update(
self,
+ workspace_id: str,
agent_id: str,
name: Optional[str] = None,
...
) -> Optional[Agent]:
- agent = await self.get(agent_id)
+ agent = await self.get(workspace_id, agent_id)
if agent is None:
return None
...
- async def delete(self, agent_id: str) -> bool:
+ async def delete(self, workspace_id: str, agent_id: str) -> bool:
- agent = await self.get(agent_id)
+ agent = await self.get(workspace_id, agent_id)
if agent is None:
return False
The route handlers in routes/agents.py then need to pass workspace_id into every svc.get/update/delete call. Repeat the pattern for IssueService, ProjectService, CommentService, and LabelService, which exhibit the same single-key lookup; those should be filed and fixed as separate advisories so each gets its own CVE.