Dynamic attribute access via getattr()
Low
- Category
- Dangerous Code Execution
- Content
vt_symbols = [s for s in vt_symbols if s not in _bad] p(f" [warn] 已过滤{len(_bad)}个不支持的标的,剩余{len(vt_symbols)}个") mod = importlib.import_module(args.strategy) if hasattr(mod, args.cls): strategy_cls = getattr(mod, args.cls) else: # 大小写模糊匹配(agent常把Ma写成MA) low = args.cls.lower(); hit = [n for n in dir(mod) if n.lower() == low] if hit: p(f" [warn] 类名修正: {args.cls} -> {hit[0]}"); strategy_cls = getattr(mod, hit[0])- Confidence
- 86% confidence
- Finding
- The runner imports a module from user-supplied CLI input and then fetches a class by user-supplied name, enabling execution of arbitrary local Python code when the imported strategy module is loaded. In a quant backtesting tool this may be intentional functionality, but it still expands the trust boundary significantly and is dangerous if untrusted users can supply strategy paths or module names.
