- Location
- server/index.js:24
- Finding
- Public Verification Endpoint Can Be Abused to Exhaust Server and Upstream Resources<![CDATA[
## Vulnerability Details
**File Location**: `server/index.js:24-89`, `lib/verify.js:14-42`
**Vulnerability Type**: Missing rate limits, strict validation, and outbound request timeout
**Risk Level**: Medium
### Vulnerable Code
```javascript
// server/index.js:24-89
app.post('/api/verify', async (req, res) => {
try {
const { address, message, signature, publicKey, userId, timestamp } = req.body;
// Validate request
if (!address || !message || !signature) {
return res.status(400).json({
success: false,
error: 'Missing required fields: address, message, signature'
});
}
// Validate timestamp (challenge must be recent)
if (!validateChallengeTimestamp(timestamp)) {
return res.status(400).json({
success: false,
error: 'Challenge expired. Please generate a new one.'
});
}
console.log(`🔐 Verifying signature for ${address}...`);
// Verify signature with MintGarden API
const result = await verifySignature(address, message, signature, publicKey);
if (result.verified) {
pendingVerifications.set(userId, {
address,
verified: true,
timestamp: Date.now()
});
return res.json({
success: true,
verified: true,
address,
userId,
message: 'Wallet ownership verified successfully!'
});
} else {
return res.status(400).json({
success: false,
verified: false,
error: result.error || 'Signature verification failed'
});
}
} catch (error) {
console.error('❌ Verification endpoint error:', error);
res.status(500).json({
success: false,
error: error.message || 'Internal server error'
});
}
});
```
```javascript
// lib/verify.js:14-42
async function verifySignature(address, message, signature, publicKey) {
try {
const response = await fetch(`${MINTGARDEN_API}/address/verify_signature`, {
method: 'POST',
...[truncated 2406 chars]
- Remediation
- <![CDATA[
## Remediation Suggestions
1. Apply rate limits per IP, authenticated user, Telegram identity, and wallet address.
2. Require a valid server-issued challenge before making any upstream verification request.
3. Enforce a strict JSON schema, including expected types, formats, and maximum lengths for every field.
4. Validate Chia addresses and signature/public-key encodings locally before contacting MintGarden.
5. Add an outbound timeout using `AbortController` or an equivalent mechanism.
6. Limit concurrent MintGarden requests and use bounded queues or circuit breakers.
7. Return generic client-facing errors while logging sanitized internal diagnostics.
8. Add monitoring for request spikes, timeout rates, upstream throttling, and repeated invalid proofs.
9. Configure explicit body limits appropriate for the small verification payload.
10. Consider authenticated service-to-service verification through the Telegram bot rather than exposing a broadly callable public endpoint.
]]>