T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/smyx_pregnant_posture_fatigue_detection_analysis.py:53- Finding
Workspace-Wide Fallback Identity Can Cause Cross-User Access to Sensitive Reports
- Content
View full analysis
Vulnerability Details
File Location:
scripts/smyx_pregnant_posture_fatigue_detection_analysis.py:53-61;skills/smyx_common/scripts/util.py:423-469
Vulnerability Type: Shared fallback identity and insufficient user isolation
Risk Level: HighComplete Code Snippet
scripts/smyx_pregnant_posture_fatigue_detection_analysis.py:53-61:python try: # 初始化内部用户身份;不要求用户输入,也不在帮助信息中展示。 OpenIdUtil.resolve_current_open_id(args.open_id, use_current=bool(args.open_id)) # 检查必需参数 if args.list: open_id = ConstantEnum.CURRENT__OPEN_ID result = show_analyze_list(open_id) print(result)skills/smyx_common/scripts/util.py:423-469:python @classmethod def get_api_key_file_open_id(cls): """读取工作区 data/smyx-api-key.txt 中的内部身份值。""" api_key_path = os.path.join(cls.get_workspace_data_dir(), "smyx-api-key.txt") try: if not os.path.exists(api_key_path): return None with open(api_key_path, "r", encoding="utf-8") as f: value = f.read().strip() return value or None except Exception as e: CommonUtil.trace_exception_stack(e) return None @classmethod def get_or_create_default_open_id(cls): from .dao import UserDao, User import uuid user_dao = UserDao() user = user_dao.get_first_default_user( cls.DEFAULT_PREFIX, cls.DEFAULT_USERNAME_LENGTH ) if user and user.username: return user.username # Extremely unlikely collisions are retried. for _ in range(10): username = cls.generate_default_open_id() if user_dao.get_by_username(username): continue now = datetime.now() user = User( id=uuid.uuid4().hex, username=username, realname=username, source=ConstantEnum.APP__SOURCE, del_flag=0, ...[truncated 4339 chars]- Remediation
View remediation
Remediation Suggestions
-
Preserve trusted upstream identity values regardless of whether the hidden CLI argument is present:
python OpenIdUtil.resolve_current_open_id( args.open_id, use_current=True ) -
Define an explicit identity precedence order:
- authenticated upstream sender identity;
- explicitly supplied identity from a trusted internal caller;
- per-principal fallback identity;
- fail closed for sensitive report queries if no authenticated identity exists.
-
Do not use a single workspace-wide identity in multi-user environments. Namespace fallback identity and token storage by the authenticated Agent principal.
-
Require a trusted authenticated identity for
--list. Do not silently use a shared default account for access to historical reports. -
Pass the resolved identity explicitly through the request chain instead of relying on mutable process-global fields such as
CURRENT__OPEN_ID,TOKEN, andOPEN_TOKEN. -
Enforce ownership and tenant isolation on the server for both analysis records and report-list endpoints. Client-provided usernames or Open IDs must not be sufficient authorization.
-
Add multi-user tests covering:
- two callers sharing one workspace;
- environments that provide only
OPENCLAW_SENDER_OPEN_ID; - report creation by one caller followed by
--listfrom another; - rejection when no trusted identity is available.
-
