Back to skill

Security audit

Ad Budget Governor

Security checks for vulnerabilities and agentic risk

Overview

The skill is coherent and not malicious, but its advertised financial safety control has implementation flaws that can let ad spend exceed the configured cap.

Install only if you treat this as sample code and harden it before relying on it for real ad spend. Validate all monetary inputs, fail closed on malformed or unexpectedly missing ledgers, and use an atomic reservation or transaction mechanism before allowing live platform purchases.

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 (4)

T09 · Insecure Skill Coding Practices

Error
Location
ad_budget_governor.py:135
Finding

Non-finite and negative numeric values bypass budget enforcement

Content
View full analysis
tuple[bool, Optional[str]]: """Gate for any spend action on any platform. Call BEFORE spending.""" status = get_status() if status["ledger_read_error"]: return False, ( "Spend ledger unreadable — true spend cannot be verified. " "Failing closed: blocking this spend until the ledger is repaired." ) if status["cap_usd"] <= 0: return False, "No budget cap has been set yet. Call set_cap() first." if status["at_cap"]: return False, ( f"Rolling {_ROLLING_WINDOW_DAYS}-day cap reached " f"(${status['spent_usd']:.2f} / ${status['cap_usd']:.2f})." ) if amount_usd > status["remaining_usd"]: return False, ( f"This spend (${amount_usd:.2f}) would exceed the rolling cap. " f"Remaining: ${status['remaining_usd']:.2f} of ${status['cap_usd']:.2f}." ) return True, None ``` ### Technical Analysis The governor converts requested amounts, ledger amounts, and persisted cap values with `float()` but does not verify that the resulting values are finite or within an acceptable range. Python floating-point values can represent `NaN`, positive infinity, and negative infinity. Comparisons involving `NaN` generally evaluate to false. For example, when `amount_usd` is `float("nan")`, the expression: ```python amount_usd > status["remaining_usd"] ``` is false, allowing execution to reach `return True, None`. A negative requested amount similarly passes whenever the remaining budget is non-negative because it is not greater than the remaining balance. ...[truncated 1484 chars]
Remediation
View remediation
float: try: parsed = float(value) except (TypeError, ValueError) as exc: raise ValueError("Monetary value must be numeric") from exc if not math.isfinite(parsed): raise ValueError("Monetary value must be finite") if parsed < 0 or (parsed == 0 and not allow_zero): raise ValueError("Monetary value must be positive") return parsed ``` 2. Require requested spend amounts and ledger spend amounts to be finite and strictly positive. 3. Require caps to be finite and non-negative. 4. Treat invalid ledger or state values as verification failures and block spending rather than continuing with a partial total. 5. Consider using `decimal.Decimal` for currency calculations to avoid binary floating-point rounding behavior. 6. Configure JSON parsing to reject non-standard constants: ```python def reject_constant(value: str): raise ValueError(f"Invalid JSON numeric constant: {value}") records = json.loads( ledger_path.read_text(), parse_constant=reject_constant, ) ``` 7. Add tests for `NaN`, positive and negative infinity, negative amounts, zero, extremely large values, and malformed numeric strings. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
ad_budget_governor.py:95
Finding

Missing configured ledgers are silently treated as zero spend

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
ad_budget_governor.py:135
Finding

Non-atomic budget checks allow concurrent spending to exceed the cap

Content
View full analysis
tuple[bool, Optional[str]]: """Gate for any spend action on any platform. Call BEFORE spending.""" status = get_status() if status["ledger_read_error"]: return False, ( "Spend ledger unreadable — true spend cannot be verified. " "Failing closed: blocking this spend until the ledger is repaired." ) if status["cap_usd"] <= 0: return False, "No budget cap has been set yet. Call set_cap() first." if status["at_cap"]: return False, ( f"Rolling {_ROLLING_WINDOW_DAYS}-day cap reached " f"(${status['spent_usd']:.2f} / ${status['cap_usd']:.2f})." ) if amount_usd > status["remaining_usd"]: return False, ( f"This spend (${amount_usd:.2f}) would exceed the rolling cap. " f"Remaining: ${status['remaining_usd']:.2f} of ${status['cap_usd']:.2f}." ) return True, None ``` ### Technical Analysis The budget check reads current ledger state and returns an authorization decision without reserving the approved amount. There is no process lock, transaction, reservation record, or compare-and-swap operation tying the check to the subsequent platform purchase. Multiple workers can therefore read the same remaining balance before any worker records its purchase. Each request independently passes the check, even though their combined amount exceeds the cap. This is a classic time-of-check to time-of-use race. The design is particularly exposed because its stated purpose is coordinating spending across multiple advertising platforms, where concurrent requests are foreseeable. ### Attack Path Assume that the rolling cap has $100 remaining: 1. Worker A calls `check_rolling_bu ...[truncated 974 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
ad_budget_governor.py:99
Finding

Malformed ledger records cause uncaught exceptions instead of fail-closed results

Content
View full analysis
= cutoff: total += float(r.get("amount_usd", 0) or 0) ``` ### Technical Analysis Only file reading and JSON parsing are protected by the fail-closed exception handler. The code does not verify that the decoded JSON root is a list or that every entry is an object. Examples of syntactically valid but structurally invalid JSON include: ```json {"timestamp": "2026-06-22T14:00:00Z", "amount_usd": 12.50} ``` and: ```json [null] ``` For a dictionary root, iteration produces string keys; for a list containing `null`, iteration produces `None`. The subsequent `r.get(...)` call raises `AttributeError`. Invalid `amount_usd` values can also raise `TypeError`, `ValueError`, or `OverflowError` outside the protected block. Instead of returning `had_read_error=True` and allowing `check_rolling_budget()` to issue a controlled denial, these inputs can propagate an exception to the caller. ### Attack Path 1. Obtain the ability to modify or generate a configured ledger. 2. Write syntactically valid JSON with an unexpected structure, such as `[null]`. 3. Invoke `get_status()` or `check_rolling_budget()`. 4. JSON parsing succeeds, so the protected error branch is not entered. 5. The iteration reaches `r.get(...)`, where `r` is `None`. 6. An uncaught exception terminates the budget check instead of returning a documented fail-closed decision. Whether this results in spen ...[truncated 616 chars]
Remediation
View remediation
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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
Findings (1)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill explicitly instructs users to copy and run a Python module that reads multiple ledger files and likely updates cap state, yet the manifest declares no tool scope such as permissions or allowed-tools. That mismatch weakens least-privilege controls and transparency: an agent or reviewer cannot tell from the manifest that file read/write access is required, increasing the chance the skill is granted broader filesystem access than intended.

Content

No source excerpt is available for this finding.