Back to skill

Security audit

Merso Integration

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Merso payment-integration guide, but its webhook verification example can accept unsigned payment events.

Review and correct the webhook security guidance before using this skill for production payments: reject missing signatures, handle malformed signatures safely, use a dedicated webhook secret if available, and independently verify payment state before granting or revoking goods.

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

Error
Location
references/api.md:134
Finding

Webhook Authentication Fails Open When the Signature Header Is Missing

Content
View full analysis
{ const sig = req.headers['x-merso-signature']; if (sig && !verifyMersoWebhook(req.body, sig, process.env.MERSO_API_KEY)) { return res.status(401).json({ error: 'Invalid signature' }); } // process event }); ``` ### Technical Analysis The authentication condition rejects a request only when the `X-Merso-Signature` header is present and invalid: ```js if (sig && !verifyMersoWebhook(...)) ``` When the header is absent, `sig` is falsy, the verification function is never called, and execution proceeds to payment-event processing. Authentication therefore fails open. The documented integration flow grants an item or license after receiving a successful payment webhook. If an implementation follows this example without an additional authoritative payment verification step, an unauthenticated remote party could submit a forged `payment.succeeded` event. The comparison function has a related availability weakness. Node.js `crypto.timingSafeEqual` requires both buffers to have equal lengths. A malformed signature of an unexpected length can throw an exception. Without controlled error handling, repeated malformed requests could produce server errors and contribute to denial of service. ### Attack Path 1. The attacker discovers or predicts the publicly accessible payment webhook endpoint. 2. The attacker obtains or guesses a valid-looking pa ...[truncated 1554 chars]
Remediation
View remediation
{ const sig = req.headers['x-merso-signature']; if (typeof sig !== 'string') { return res.status(401).json({ error: 'Missing signature' }); } let valid = false; try { valid = verifyMersoWebhook( req.body, sig, process.env.MERSO_WEBHOOK_SECRET ); } catch { valid = false; } if (!valid) { return res.status(401).json({ error: 'Invalid signature' }); } // Validate and process the authenticated event. } ); ``` 2. **Validate signature encoding and length before comparison.** ```js const crypto = require('crypto'); function verifyMersoWebhook(rawBody, signatureHeader, secret) { if ( !Buffer.isBuffer(rawBody) || typeof signatureHeader !== 'string' || typeof secret !== 'string' || !/^[a-fA-F0-9]{64}$/.test(signatureHeader) ) { return false; } const expected = crypto .createHmac('sha256', secret) .update(rawBody) .digest(); const supplied = Buffer.from(signatureHeader, 'hex'); return supplied.length === expected.length && crypto.timingSafeEqual(expected, supplied); } ``` 3. **Use the provider’s formally documented webhook-signature protocol.** Confirm the signature header, signing secret, digest encoding, signed payload format, timestamp handling, and replay-prevention requirements with Merso. Prefer a dedicated webhook secret rather than reusing the general API key. 4. **Verify payment state independently before changing entitlements.** For every success or refund event, query the authenticated `GET /verify-payment-intent/:id` endpoint and require the authoritative response to match the webhook. 5. **Bind each event to a local pending payment reco ...[truncated 1118 chars]
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