Back to skill

Security audit

Sugar Finance Bot

Security checks for vulnerabilities and agentic risk

Overview

This skill is a narrow landed-cost calculator with no evidence of hidden access, persistence, or data exfiltration.

Install only if a simple local landed-cost calculator is sufficient. Treat outputs as dependent on the caller-provided shipment data, and avoid feeding untrusted or malformed shipment objects unless validation is added for zero, negative, missing, or non-numeric quantities and costs.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Note
Location
tool.py:41
Finding

Unvalidated Shipment Quantities Allow Division-by-Zero Failures

Content
View full analysis

Vulnerability Details

File Location: tool.py, lines 41-42
Vulnerability Type: Improper input validation leading to an unhandled exception
Risk Level: Low

Vulnerable Code

python
"cost_per_kg": total / product.get("net_weight_kg", 1),
"cost_per_unit": total / product.get("quantity_units", 1)

Technical Analysis

The calculation uses a fallback value of 1 only when net_weight_kg or quantity_units is absent. If either field is explicitly set to zero, Python raises an unhandled ZeroDivisionError. Non-numeric values can similarly cause TypeError.

Because calculate_landed_cost accepts a caller-supplied dictionary without validating its structure or values, malformed or adversarial shipment data can interrupt tool execution.

Attack Path

  1. An attacker or untrusted upstream source constructs a shipment object with product.net_weight_kg or product.quantity_units set to 0.
  2. The object is passed to calculate_landed_cost.
  3. The function calculates the total cost and attempts to divide it by the zero value.
  4. Python raises an uncaught ZeroDivisionError.
  5. The current calculation or dependent Agent workflow terminates unless the caller independently handles the exception.

Example triggering input:

python
shipment = {
    "shipment_id": "TEST-001",
    "product": {
        "quantity_units": 0,
        "net_weight_kg": 0
    },
    "costs": {
        "product_cost": 100
    }
}

calculate_landed_cost(shipment)

Impact Assessment

Exploitation does not grant additional privileges, expose data, or enable code execution. Its impact is limited to availability: an attacker able to influence shipment input can reliably cause the calculation to fail. Repeated malicious inputs could disrupt workflows that depend on this function, although the reviewed code does not establish a persistent or system-wide denial-of-service condition.

Remediation
View remediation

Remediation Suggestions

Validate the complete shipment structure before performing arithmetic:

  1. Require shipment, product, and costs to have the expected mapping types.
  2. Require net_weight_kg and quantity_units to be finite numeric values greater than zero.
  3. Require all cost fields to be finite, non-negative numeric values.
  4. Reject booleans, which Python otherwise treats as integers.
  5. Return a controlled validation error rather than exposing an unhandled arithmetic exception.
  6. Add tests for zero, negative, missing, non-numeric, infinite, and NaN values.

Example hardened approach:

python
import math

def require_positive_number(value, field_name):
    if isinstance(value, bool) or not isinstance(value, (int, float)):
        raise ValueError(f"{field_name} must be numeric")
    if not math.isfinite(value) or value <= 0:
        raise ValueError(f"{field_name} must be finite and greater than zero")
    return value

net_weight = require_positive_number(
    product.get("net_weight_kg"), "net_weight_kg"
)
quantity = require_positive_number(
    product.get("quantity_units"), "quantity_units"
)

return {
    "shipment_id": shipment.get("shipment_id"),
    "landed_cost": total,
    "cost_per_kg": total / net_weight,
    "cost_per_unit": total / quantity,
}
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep

Static analysis

No suspicious patterns detected.