T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/infant_sleep_monitoring_analysis.py:49- Finding
Workspace-Wide Fallback Identity Causes Cross-User Access to Infant Monitoring Reports
- Content
View full analysis
Vulnerability Details
File Location:
scripts/infant_sleep_monitoring_analysis.py:49-50;skills/smyx_common/scripts/util.py:462-466, 585-593;skills/smyx_common/scripts/dao.py:475-495;skills/smyx_analysis/scripts/api_service.py:29-37
Vulnerability Type: Broken user isolation through shared fallback credentials
Risk Level: HighComplete Code Snippets
scripts/infant_sleep_monitoring_analysis.py:49-50python # Initialize the internal user identity without requiring user input. OpenIdUtil.resolve_current_open_id( args.open_id, use_current=bool(args.open_id) )skills/smyx_common/scripts/util.py:462-466python if not resolved_open_id: resolved_open_id = cls.get_api_key_file_open_id() if not resolved_open_id: resolved_open_id = cls.get_or_create_default_open_id()skills/smyx_common/scripts/dao.py:475-495python def get_first_default_user( self, prefix: str = "User_", username_length: int = 11 ) -> Optional[User]: session = self.get_session() try: return session.query(self.__model__).filter( self.__model__.username.like(f"{prefix}%"), func.length(self.__model__.username) == username_length, or_( self.__model__.del_flag == 0, self.__model__.del_flag.is_(None) ) ).order_by( self.__model__.create_time.asc(), self.__model__.id.asc() ).first() finally: session.close()skills/smyx_common/scripts/util.py:585-593python found_user = user_dao.get_by_username(current__user_name) if found_user: ApiEnum.TOKEN = found_user.token ApiEnum.OPEN_TOKEN = found_user.open_token current__user_name = found_user.username if not ApiEnum.TOKEN or not ApiEnum.OPEN_TOKEN: new_current_user = _get_or_create_user(current__user_name) if new_cu ...[truncated 3145 chars]- Remediation
View remediation
Remediation Suggestions
- Require a trusted, authenticated per-caller identity from the hosting platform for every upload and historical-report operation.
- Reject analysis and
--listrequests when no trusted identity is available instead of creating or reusing a workspace-wide fallback user. - Do not treat a caller-provided CLI value as authoritative identity. Derive the principal from authenticated platform context and verify its tenant membership.
- Partition local credential records by authenticated principal, tenant, and Agent context. Never select the earliest generic
User_*record as a global fallback. - Scope server-side report queries to the authenticated user and tenant, and enforce authorization on every report-detail or export-link endpoint.
- Store tokens in a protected credential store with restrictive access controls rather than in a broadly shared workspace database.
- Invalidate and rotate existing shared fallback tokens. Migrate existing reports to verified owners where possible.
- Add multi-user isolation tests proving that one caller cannot list, retrieve, or export another caller's reports.
