T09 · Insecure Skill Coding Practices
- Location
scripts/query_sdk_methods.py:327- Finding
Unrestricted Module Import Through the --class Argument
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This appears to be a legitimate Huawei Cloud SDK lookup helper, but one helper command can load arbitrary local Python modules from user input.
Review before installing or using in automated agent workflows. Run it only in a dedicated virtual environment with trusted Huawei SDK packages installed, avoid passing arbitrary dotted --class values from untrusted text, and prefer pinned package versions from a trusted index.
scripts/query_sdk_methods.py:327Unrestricted Module Import Through the --class Argument
SKILL.md:176Unpinned Third-Party Package Installation Instructions
The manifest description is entirely in Chinese and presents the tool as a Chinese-language helper, with no indication that users may interact in other languages or opt into Chinese output. Under the policy, language constraints should either be optional or clearly justified as region-specific.
This markdown file shows how to construct credentials using access key, secret key, and security token variables, but it provides no caution about treating these values as sensitive secrets. For markdown files, SQP-2 applies when descriptions omit warnings about behaviors that could affect privacy or system integrity; exposing or mishandling credentials is a relevant user-safety concern.
This file contains natural-language instructions, descriptions, and examples exclusively in Chinese, with no indication that users may choose another language. Under the stated policy, forcing a specific language without opt-in is a natural-language policy concern.
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
for name in dir(mod):
if not name.endswith('Client'):
continue
obj = getattr(mod, name)
# 只保留类,排除 AsyncClient(后续按需求可单独处理)
# 这里先收集所有 Client
if inspect.isclass(obj):
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
try:
mod = importlib.import_module(source_module)
if hasattr(mod, class_name):
req_class = getattr(mod, class_name)
else:
# 尝试从 model 子模块
try:
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
try:
model_mod = importlib.import_module(f"{module_to_import}.model")
if hasattr(model_mod, class_name):
req_class = getattr(model_mod, class_name)
else:
return params
except Exception:
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
return params
except Exception:
# 尝试直接请求类作为属性
req_class = getattr(mod, class_name, None)
if not req_class:
return params
except Exception:
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
for attr_name, attr_type in openapi_types.items():
# 获取属性描述(如果有 setter docstring)
# 尝试获取 getter/setter
setter = getattr(req_class, f'{attr_name}', None)
prop_type = attr_type if isinstance(attr_type, str) else str(attr_type)
# 查找 setter 的 docstring
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
# 查找 setter 的 docstring
setter_doc = ''
prop = getattr(req_class, attr_name, None)
if hasattr(prop, 'fset') and prop.fset:
setter_doc = inspect.getdoc(prop.fset) or ''
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
try:
mod = importlib.import_module(mod_name)
if hasattr(mod, class_name):
target_class = getattr(mod, class_name)
target_module_path = f"{mod_name}.{class_name}"
break
except Exception:
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
try:
mod = importlib.import_module(mod_name)
if hasattr(mod, class_name):
target_class = getattr(mod, class_name)
target_module_path = f"{mod_name}.{class_name}"
break
except Exception:
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
module_path = '.'.join(class_name.split('.')[:-1])
cls_name = class_name.split('.')[-1]
mod = importlib.import_module(module_path)
target_class = getattr(mod, cls_name, None)
if target_class:
target_module_path = class_name
except Exception:
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
try:
model_mod = importlib.import_module(f"{pkg}.{ver}.model")
if hasattr(model_mod, class_name):
target_class = getattr(model_mod, class_name)
target_module_path = f"{pkg}.{ver}.model.{class_name}"
break
except Exception:
The argparse description, epilog examples, and argument help strings are all presented solely in Chinese. This continues the same language-policy issue in the executable interface, with no opt-in or alternate locale path.
Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.
full_module_name = f"{sdk_name}.{version}"
try:
mod = importlib.import_module(full_module_name)
client_class = getattr(mod, args.client, None)
if not client_class:
print(f"❌ 在 {full_module_name} 中未找到 Client 类: {args.client}")
# 尝试列出可用的 Client