T09 · Insecure Skill Coding Practices
- Location
sara_core/engine.py:225- Finding
Missing Safety Prerequisites Are Treated as Safe
- Content
View full analysis
Vulnerability Details
File Location:
sara_core/engine.py, lines 225-244
Vulnerability Type: Fail-open safety validation
Risk Level: HighVulnerable Code:
python for rule in self.rules: if rule.before in normalized_tools and rule.after in normalized_tools: before_idx = normalized_tools.index(rule.before) after_idx = normalized_tools.index(rule.after) if before_idx > after_idx: violations.append( { "type": "order_violation", "severity": rule.severity, "message": f"Run '{rule.before}' before '{rule.after}'. {rule.reason}", "before": rule.before, "after": rule.after, } ) return violationsTechnical Analysis
The auditor evaluates a rule only when both the protected action and its prerequisite are present. It does not generate a violation when a high-risk action is present but the corresponding prerequisite is entirely absent.
As a result, plans containing only actions such as
delete,publish, orread_private_dataare considered safe because there is no prerequisite action whose position can be compared. This contradicts the documented hard requirements for backup, preview, permission, and checks.The validation therefore fails open in precisely the cases where a caller omits a required safeguard.
Attack Path
- A caller constructs a plan containing a protected action, such as
["delete"]. - The action is normalized to
delete. - The
backup -> deleterule is skipped becausebackupis not present. - No violation is added.
audit_trajectoryreturnsis_safe: trueandrisk_level: low.- An agent relying on the audit result may proceed without creating a backup.
The same path applies to plans that omit checks, permission acquisition, or previews.
Impa
...[truncated 477 chars]
- A caller constructs a plan containing a protected action, such as
- Remediation
View remediation
Remediation Suggestions
Treat a protected action with a missing prerequisite as a violation rather than as a safe plan.
For each rule:
- Detect whether
rule.afteris present. - If
rule.beforeis absent, emit amissing_prerequisiteviolation. - If both are present, verify that an appropriate prerequisite occurrence precedes each protected occurrence.
- Fail closed when validation cannot determine whether prerequisites are satisfied.
- Add automated tests for
["delete"],["publish"],["read_private_data"], and other missing-prerequisite cases. - Test repeated actions, including plans where the first protected action occurs before the first prerequisite.
- Detect whether
