T09 · Insecure Skill Coding Practices
- Location
scripts/lipsync.py:90- Finding
Cost-limit exception is swallowed after paid API submission, allowing spending beyond the configured cap
- Content
View full analysis
None: """扣费,触发软预警/硬熔断.""" self.spent += cost self.records.append(CostRecord(step=step, item=item, cost=cost)) ratio = self.spent / self.cap if self.cap else 0 if ratio >= 1.0: self._persist() raise BudgetExceeded( f"累计成本 ¥{self.spent:.2f} 达到熔断上限 ¥{self.cap:.2f}({step}/{item})。\n" f"已完成步骤可从 checkpoint 续跑。" ) ``` ### Technical Analysis The paid Kling request is submitted and completed before `CostGuard.charge()` checks whether the configured cost cap has been reached. The main loop does not reserve or validate the expected cost before invoking the external API, and it never calls the available `CostGuard.preflight()` method. When `charge()` detects that the cap has been reached, it raises `BudgetExceeded`. However, `lipsync.py` catches every exception through `except Exception`. The budget exception is therefore treated as an ordinary lip-sync failure. The script copies the original video, records a fallback checkpoint, and continues processing subsequent scenes. Every later scene can submit another paid request before the sa ...[truncated 1348 chars]- Remediation
View remediation
