Zum Hauptinhalt springen
LIVE
CVSS 6.9CVE-2026-138105 | A vulnerability has been found in ssssssss-team magic-api 2.2.2. The affected element is an unknown function of the file /magic/web/datasource/jdbc/test of the component Datasource JDBC Test Endpoint. Such manipulation of the argument driverClassName leads to code injection. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. The project was informed of the problem early through an issue report but has not respoCVSS 6.9CVE-2026-138104 | A flaw has been found in ssssssss-team magic-api up to 2.2.2. Impacted is the function push of the file magic-api/src/main/java/org/ssssssss/magicapi/core/web/MagicWorkbenchController.java of the component Workbench Push Interface. This manipulation of the argument magic-push-target causes server-side request forgery. The attack can be initiated remotely. The exploit has been published and may be used. The project was informed of the problem early through anCVSS 6.9CVE-2026-138103 | A vulnerability was detected in ssssssss-team magic-api up to 2.2.2. This issue affects the function saveFile of the file MagicResourceController.java of the component magic-api-core resource save API. The manipulation results in code injection. It is possible to launch the attack remotely. The exploit is now public and may be used. The project was informed of the problem early through an issue report but has not responded yet.CVSS 9.4CVE-2026-138102 | A security vulnerability has been detected in D-Link DIR-620S 4.0.2. This vulnerability affects unknown code of the file /usr/sbin/anweb of the component Diagnostic Handler. The manipulation of the argument I leads to os command injection. It is possible to initiate the attack remotely. The exploit has been disclosed publicly and may be used.CVSS 5.3CVE-2026-138101 | A weakness has been identified in MassGen up to 0.1.97. This affects the function _generate_subagent_yaml_config of the file massgen/subagent/manager.py of the component Subagent Delegation System. Executing a manipulation can lead to improper authorization. The attack may be performed from remote. The exploit has been made available to the public and could be used for attacks. The project was informed of the problem early through an issue report but has notCVSS 6.9CVE-2026-138100 | A security flaw has been discovered in MassGen up to 0.1.97. Affected by this issue is the function __init__ of the file massgen/filesystem_manager/_filesystem_manager.py. Performing a manipulation results in protection mechanism failure. The attack is possible to be carried out remotely. The exploit has been released to the public and may be used for attacks. The project was informed of the problem early through an issue report but has not responded yet.CVSS 8.7CVE-2026-138099 | A vulnerability was identified in Tenda AC10U 1.18.6. Affected by this vulnerability is the function readUsb of the component ATE Service. Such manipulation leads to out-of-bounds write. The attack can be executed remotely. The exploit is publicly available and might be used.CVSS 6.9CVE-2026-138098 | A vulnerability was determined in weison-tech yii2-cms up to 1.0.2. Affected is an unknown function of the file protected/core/config/common.php of the component RBAC Authorization. This manipulation causes improper authorization. Remote exploitation of the attack is possible.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Webhook Idempotency: Handling Duplicate Events

The Silent Killer: Why Webhook Idempotency Matters You deploy a webhook handler that charges a customer $50 on every payment.completed event. The payment…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 7 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung




The Silent Killer: Why Webhook Idempotency Matters



You deploy a webhook handler that charges a customer $50 on every payment.completed event. The payment provider retries the webhook once due to a temporary network timeout. Your handler processes it twice. Now your customer is charged $100, and you're fielding an angry support ticket.



This is the core problem with webhook idempotency: duplicate events are inevitable. Network failures, timeouts, provider retries, and even your own restarts can cause the same event to be delivered multiple times. Without webhook idempotency duplicate events handling, you risk corrupting data, double-charging users, or creating orphaned records. The solution isn't to prevent duplicates—it's to make your handler idempotent, so processing the same event twice produces the same result as processing it once.






Prerequisites




  • A webhook provider account (Stripe, GitHub, Shopify, or similar) with webhook delivery logs

  • Familiarity with HTTP POST requests and JSON payloads

  • A backend runtime: Node.js, Python, or similar

  • A database or cache layer (PostgreSQL, Redis) to track processed event IDs

  • Basic understanding of HTTP status codes and retry semantics






Implementing Idempotent Webhook Handling



Webhook idempotent handling relies on three principles:





  1. Unique event identifiers — every webhook payload includes a stable, unique ID


  2. Deduplication storage — track which event IDs you've already processed


  3. Idempotent operations — structure your business logic so re-execution is safe






Step 1: Extract and Validate the Event ID



Every webhook provider includes a unique event identifier in the payload. Stripe uses id, GitHub uses delivery, Shopify uses X-Shopify-Webhook-Id. Always extract this first.




// Express.js example
const express = require('express');
const app = express();

app.post('/webhook/stripe', express.json(), async (req, res) => {
// Extract the event ID — this is your deduplication key
const eventId = req.body.id;

if (!eventId) {
return res.status(400).json({ error: 'Missing event ID' });
}

console.log(`Processing event: ${eventId}`);

try {
// Check if we've already processed this event
const alreadyProcessed = await checkEventProcessed(eventId);

if (alreadyProcessed) {
console.log(`Event ${eventId} already processed, skipping`);
return res.status(200).json({ status: 'already_processed' });
}

// Process the event
await handleStripeEvent(req.body);

// Mark as processed
await markEventProcessed(eventId);

res.status(200).json({ status: 'processed' });
} catch (error) {
console.error(`Error processing event ${eventId}:`, error);
res.status(500).json({ error: 'Internal server error' });
}
});









Step 2: Store Processed Event IDs



Use a database or cache to track which events you've already handled. For high-volume webhooks, Redis is ideal; for lower volume, a simple database table works.



PostgreSQL approach:




CREATE TABLE webhook_events (
id SERIAL PRIMARY KEY,
event_id VARCHAR(255) UNIQUE NOT NULL,
event_type VARCHAR(100) NOT NULL,
processed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
payload JSONB,
INDEX idx_event_id (event_id)
);






Redis approach (Node.js):




const redis = require('redis');
const client = redis.createClient();

async function checkEventProcessed(eventId) {
const key = `webhook:${eventId}`;
const exists = await client.exists(key);
return exists === 1;
}

async function markEventProcessed(eventId) {
const key = `webhook:${eventId}`;
// Set with 24-hour expiration to avoid unbounded memory growth
await client.setEx(key, 86400, 'processed');
}









Step 3: Make Your Business Logic Idempotent



Even with deduplication, structure your operations to be idempotent. Avoid operations that fail if repeated:



Bad (not idempotent):




async function handlePaymentCompleted(event) {
// This creates a duplicate charge if called twice
const charge = await stripe.charges.create({
amount: event.data.amount,
currency: event.data.currency,
});

await db.orders.update(event.data.order_id, {
status: 'paid',
charge_id: charge.id,
});
}






Good (idempotent):




async function handlePaymentCompleted(event) {
const orderId = event.data.order_id;

// Check if order is already marked as paid
const order = await db.orders.findById(orderId);
if (order.status === 'paid') {
console.log(`Order ${orderId} already paid, skipping charge`);
return;
}

// Use idempotency keys if the provider supports them
const charge = await stripe.charges.create(
{
amount: event.data.amount,
currency: event.data.currency,
},
{
idempotencyKey: `order-${orderId}-${event.data.created}`,
}
);

await db.orders.update(orderId, {
status: 'paid',
charge_id: charge.id,
});
}









Step 4: Return 200 Immediately, Process Asynchronously



Always return HTTP 200 to the webhook provider before your business logic completes. This prevents provider retries while you're still processing:




app.post('/webhook/stripe', express.json(), async (req, res) => {
const eventId = req.body.id;

// Return 200 immediately
res.status(200).json({ received: true });

// Process asynchronously
setImmediate(async () => {
try {
const alreadyProcessed = await checkEventProcessed(eventId);
if (!alreadyProcessed) {
await handleStripeEvent(req.body);
await markEventProcessed(eventId);
}
} catch (error) {
console.error(`Async error processing ${eventId}:`, error);
// Log to monitoring system for manual review
}
});
});









Common Errors and Fixes






Error 1: "Duplicate Key Violation" in Your Event Table



Error message:




ERROR: duplicate key value violates unique constraint "webhook_events_event_id_key"






Root cause: A race condition where two requests for the same event ID hit your database simultaneously, both pass the deduplication check, and both try to insert.



Fix: Use database-level locking or atomic operations:




// PostgreSQL with advisory lock
async function processWebhookAtomic(eventId, handler) {
const lockId = hashEventId(eventId); // Convert to numeric hash

const client = await db.connect();
try {
await client.query('SELECT pg_advisory_lock($1)', [lockId]);

const alreadyProcessed = await client.query(
'SELECT 1 FROM webhook_events WHERE event_id = $1',
[eventId]
);

if (alreadyProcessed.rows.length > 0) {
return { status: 'already_processed' };
}

await handler();

await client.query(
'INSERT INTO webhook_events (event_id, processed_at) VALUES ($1, NOW())',
[eventId]
);

return { status: 'processed' };
} finally {
await client.query('SELECT pg_advisory_unlock($1)', [lockId]);
client.release();
}
}









Error 2: "Event Processed Twice" Despite Deduplication



Symptom: You see duplicate charges or records even with deduplication in place.



Root cause: Your deduplication check happens after you've already made an external API call, or you're not using the event ID correctly.



Fix: Check deduplication before any side effects:




// WRONG: Check happens after Stripe call
const charge = await stripe.charges.create({ ... });
const alreadyProcessed = await checkEventProcessed(eventId);

// CORRECT: Check first
const alreadyProcessed = await checkEventProcessed(eventId);
if (alreadyProcessed) return;
const charge = await stripe.charges.create({ ... });






Also verify you're extracting the event ID correctly for your provider:




// Stripe: event.id
// GitHub: headers['x-github-delivery']
// Shopify: headers['x-shopify-webhook-id']
const eventId = req.body.id || req.headers['x-github-delivery'];









Frequently Asked Questions



Q: How long should I store processed event IDs?



A: At minimum, store them for the provider's maximum retry window (typically 24–72 hours). For audit purposes, keep them longer. Redis with 30-day expiration is reasonable; database retention depends on your compliance requirements. Stripe events are immutable and include a timestamp, so you can safely delete old records after 90 days.



Q: What if my database is down when a webhook arrives?



A: Return 5xx status immediately so the provider retries. Use a local queue (file, in-memory buffer, or local SQLite) as a fallback to capture the event, then process it when the database recovers. For development and testing, Anonymily's webhook inspector captures webhooks in the cloud even when localhost is down, letting you replay them once your handler is ready.



Q: Can I use just timestamps instead of event IDs for deduplication?



A: No. Multiple events can have the same timestamp (millisecond precision), and timestamps don't guarantee uniqueness across retries. Always use the provider's event ID. If a provider doesn't include one, generate a hash of the payload content, but this is fragile if the provider modifies the payload between retries.






Testing Your Idempotency



During local development, test duplicate delivery manually. Use Test Webhooks Locally Without ngrok to capture real webhook payloads, then replay them to verify your handler processes them only once.



Start by running npx @anonymilyhq/cli listen 3000 to get a stable endpoint URL. Trigger the same webhook twice from your provider's dashboard, and confirm your deduplication logic prevents double-processing. For Stripe, GitHub, or Shopify testing, the Pro tier offers provider-signed synthetic events so you can test without manual triggers.



Webhook idempotency isn't optional—it's the difference between a reliable integration and a production incident. Build it in from the start.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Topluluk tartışması ve yorumlar

🌐 Ana sohbete katıl

Tartışmayı başlat: Social Chat yayın akışı veya yukarıdaki ekleme formuyla uzman katkısı gönder.

Siber Tehdit İstihbaratı ve Adli Bilişim

ATT&CK Gezgini · IoC Radarı ve Graf

CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
2 Knoten · 1 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Community Rating & Social Proof
⭐ Okuyucu Puanı
–
Ø / 5.0
Hiçbir okuyucu henüz yorum yok
Bu makale yararlı mıydı?
0
Değerlendirmenizi gönderin
Detaylı değerlendirme (isteğe bağlı)
İçerik ve Kalite
Kaynak ve Güvenilirlik
Güncellik
Security Briefing Ücretsiz · Tek tıkla abonelikten çıkma

Zeka Digest - ücretsiz

Günlük en önemli güvenlik haberi · herhangi bir zamanda alınabilir

İlgili Story Cluster & Kaynaklar (vector AI)

6 Cluster
23 Kaynaklar
CVE-2026-135540 | Mozilla Firefox up to 115.45/153.7/160 JIT memory corruption (Nessus ID 388625)
VulDB Updates 44 dakika önce
22 diğer kaynaklar
VulDB Updates44 dakika önceCVE-2026-135539 | Mozilla Firefox up to 115.45/153.7/160 CSS Object Model use after free (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135542 | Mozilla Firefox up to 115.45/153.7/160 Layout buffer overflow (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135541 | Mozilla Firefox up to 115.45/153.7/160 XSLT use after free (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135544 | Mozilla Firefox up to 115.45/153.7/160 Navigation memory corruption (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135545 | Mozilla Firefox up to 153.7/160 Editor memory corruption (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135543 | Mozilla Firefox up to 115.45/153.7/160 Networking memory corruption (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135547 | Mozilla Firefox up to 115.45/153.7/160 Networking sandbox (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135549 | Mozilla Firefox up to 115.45/153.7/160 XSLT use after free (Nessus ID 388625) VulDB Updates44 dakika önceCVE-2026-135548 | Mozilla Firefox up to 115.45/153.7/160 Layout use after free (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135533 | Mozilla Firefox up to 115.45/153.7/160 Layout Tables off-by-one (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135536 | Mozilla Firefox up to 115.45/153.7/160 DOM Editor uninitialized pointer (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135535 | Mozilla Firefox up to 115.45/153.7/160 Skia input validation (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135537 | Mozilla Firefox up to 115.45/153.7/160 Layout Text/Fonts out-of-bounds (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135525 | Mozilla Firefox up to 115.45/153.7/160 WebRender use after free (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135526 | Mozilla Firefox up to 115.45/153.7/160 Networking use after free (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135527 | Mozilla Firefox up to 115.45/153.7/160 DOM/HTML use after free (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135528 | Mozilla Firefox up to 153.7/160 HTTP race condition (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135530 | Mozilla Firefox up to 115.45/153.7/160 HTTP sandbox (Nessus ID 388625) VulDB Updates1 saat önceCVE-2026-135529 | Mozilla Firefox up to 153.7/160 Text sandbox (Nessus ID 388625) VulDB Updates2 saat önceCVE-2026-135520 | Mozilla Firefox up to 115.45/153.7/160 CanvasWebGL sandbox (Nessus ID 388625) VulDB Updates2 saat önceCVE-2026-135524 | Mozilla Firefox JavaScript Engine use after free (Nessus ID 388625) VulDB Updates2 saat önceCVE-2026-135521 | Mozilla Firefox up to 115.45/153.7/160 Navigation sandbox (Nessus ID 388625)
13 Kaynaklar
Linux Overhauls Documentation For Reporting Kernel Security Bugs
Phoronix 58 dakika önce
12 diğer kaynaklar
DEV Community2 saat önceForgeOS Booted on a Real Server: Linux Kernel Below, Only Our Own Code Above VulDB Updates3 saat önceCVE-2026-72239 | Linux Kernel sev x86/virt/sev/sev.c wbinvd_on_all_cpus state issue (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72240 | Linux Kernel up to 7.1.4 mfd sm501_register_device memory leak (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72241 | Linux Kernel up to 7.1.4 uleds strchr buffer overflow (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72244 | Linux Kernel up to 6.12.100/6.18.41/7.1.4/7.2-rc2 gpu-buddy allocation of resources (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72243 | Linux Kernel up to 7.2-rc2 selinux socket_sendmsg permission (Nessus ID 364200 / WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72245 | Linux Kernel up to 7.1.4 host1x host1x_device_parse_dt release of resource (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72246 | Linux Kernel flowtable input validation (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72247 | Linux Kernel up to 7.2-rc3 nf_conncount __nf_conncount_add dir comparison (WID-SEC-2026-2852) VulDB Updates3 saat önceCVE-2026-72248 | Linux Kernel up to 7.1.4/7.2-rc2 flowtable nft_flow_dst_release buffer overflow (WID-SEC-2026-2852) LinuxAndUbuntu3 saat önceLinux AutoFDO Benchmark: Clang Kernel Optimization VulDB Updates4 saat önceCVE-2022-31607 | NVIDIA GPU Display Driver on Linux Kernel Mode Layer nvidia.ko input validation (EUVD-2022-53059 / Nessus ID 339047)
12 Kaynaklar
Why I bought a handheld over a gaming laptop on Cyber Monday
Latest from Windows Central 32 dakika önce
11 diğer kaynaklar
Benzer katkılar
🔍 Verwandte News

Auch interessante Nachrichten Webhook Idempotency: Handling Duplicate Events

Thematisch verwandte Begriffe: Webhook, Idempotency, Handling, Duplicate · 6 Treffer

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Yorumlar yüklenir..
Update to Update
Widget & konular
Widget yükleniyor…
Sonraki gönderi