T09 · Insecure Skill Coding Practices
- Location
SKILL.md:14- Finding
Untrusted Local Backend Controls Payment Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 14–29 and 59–65
Vulnerability Type: Unvalidated payment instructions from an unauthenticated local service
Risk Level: HighVulnerable Code Snippet
markdown 1. Resolve the current buyer DID from `stablepay_runtime_status`. 2. Call the merchant backend premium endpoint: - `GET http://127.0.0.1:8787/execute?agent_did=<buyer_did>` 3. Treat the merchant backend as the source of truth. 4. If the backend returns `200`, return the protected result. 5. If the backend returns `402 Payment Required`: - Parse the x402 response from `accepts[0]`: - `skill_did` → from `accepts[0].extra.skillDid` - `price` → from `accepts[0].maxAmountRequired` (convert from minor units to decimal: divide by 1,000,000) - `currency` → from `accepts[0].extra.currency` - `facilitator_url` → from `accepts[0].extra.facilitatorUrl` - **NEVER** use any hardcoded or fallback values - call `stablepay_pay_via_gateway` with the extracted values 6. If payment succeeds, retry the same `/execute` request once.markdown ## Payment rules When payment is required: 1. Use `stablepay_pay_via_gateway`. 2. Use the requirement returned by the backend when present. 3. Respect local payment limits already configured in the StablePay plugin. 4. Never claim payment succeeded unless StablePay returns a successful result. 5. Retry the premium action only once after a successful payment.Technical Analysis
The skill treats a plaintext HTTP service on
127.0.0.1:8787as authoritative and passes payment parameters supplied by that service tostablepay_pay_via_gateway. The documented workflow does not require authentication of the local merchant service, verification of the merchant identity, an allowlist forskillDidorfacilitatorUrl, validation of the expected currency and exact price, or explicit user confirmation immediately before payment.Loopback addressing prevents direct remote ...[truncated 2076 chars]
- Remediation
View remediation
Remediation Suggestions
- Authenticate the merchant backend using a cryptographically verified identity rather than trusting any process bound to a loopback port.
- Require signed x402 payment requirements and verify the signature against a pinned merchant public key or other trusted identity.
- Pin or allowlist the expected
skillDid, currency, facilitator origin, merchant identity, and product identifier. - Define an expected exact price or a narrowly bounded price policy; reject any requirement outside that policy even when it remains below global StablePay limits.
- Require explicit user confirmation immediately before payment, displaying the verified recipient, product, amount, currency, and facilitator.
- Permit only approved HTTPS facilitator URLs and reject plaintext, malformed, unexpected, or dynamically redirected destinations.
- Bind the payment proof to the intended merchant, buyer DID, endpoint, product, amount, currency, and a fresh nonce to prevent substitution and replay.
- Validate the complete 402 response schema, including field types, unit conversion, numeric bounds, and the presence of exactly one supported payment requirement.
- Fail closed if backend authentication or payment-requirement verification cannot be completed.
- Where practical, use an authenticated local transport such as a protected Unix-domain socket or mutual authentication in addition to application-level signature verification.
