T09 · Insecure Skill Coding Practices
- Location
index.js:26- Finding
Payment Enforcement Is Completely Bypassed
- Content
View full analysis
{ ``` ```js app.get('/api/geocode', requirePayment, async (req, res) => { ``` ```js app.get('/api/weather', requirePayment, async (req, res) => { ``` ### Technical Analysis Both implementations read a possible payment header but never inspect or validate its value. They unconditionally invoke `next()`, including when neither payment header exists. Consequently, the application never calls its payment-required helper and never returns the advertised HTTP 402 response. A secure x402 implementation must validate the payment proof cryptographically and confirm the expected network, asset, amount, recipient, expiration, and replay status. Merely checking for a header would also be insufficient because an attacker could supply an arbitrary string. ### Attack Path 1. An attacker sends a request without an `x-payment` or `payment-signature` header: ```http GET /api/geocode?q=London HTTP/1.1 Host: target.example ``` 2. `requirePayment` reads two undefined header values. 3. The middleware unconditionally calls `next()`. 4. The endpoi ...[truncated 684 chars]- Remediation
View remediation
