惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Register - Security
The Register - Security
P
Privacy International News Feed
月光博客
月光博客
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
V
Visual Studio Blog
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Google DeepMind News
Google DeepMind News
罗磊的独立博客
Vercel News
Vercel News
Last Week in AI
Last Week in AI
A
About on SuperTechFans
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
T
Tailwind CSS Blog
GbyAI
GbyAI
S
Schneier on Security
L
LINUX DO - 热门话题
C
CERT Recently Published Vulnerability Notes
AWS News Blog
AWS News Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Hacker News
The Hacker News
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
C
Cybersecurity and Infrastructure Security Agency CISA
I
Intezer
V2EX - 技术
V2EX - 技术
The GitHub Blog
The GitHub Blog
Scott Helme
Scott Helme
V
V2EX
IT之家
IT之家
S
SegmentFault 最新的问题
爱范儿
爱范儿
L
LangChain Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
S
Security Affairs
Security Latest
Security Latest
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
S
Secure Thoughts
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Verify Nylas webhook signatures to trust your data
Qasim · 2026-06-24 · via DEV Community

A webhook endpoint is a public URL sitting on the internet, and anything on the internet can send it a POST. If your app acts on whatever lands there, an attacker who guesses the URL can forge events: fake an inbound email, trigger a workflow, or feed your system garbage. The fix is to confirm two things before you trust a request, that you own the endpoint and that Nylas actually sent the payload, and both are built into how webhooks work.

This post covers verifying webhooks from two angles: the HTTP mechanics your endpoint implements, and the nylas CLI for testing a signature without standing up a server. I work on the CLI, so the terminal commands below are the ones I reach for when I'm debugging a signature mismatch.

Two layers of webhook trust

There are two separate checks, and they happen at different times. The first is a one-time endpoint challenge: when you register or activate a webhook, Nylas sends your URL a request with a challenge value you echo back, proving you control the endpoint. The second runs on every notification afterward: each delivery carries a cryptographic signature you verify against a shared secret, proving the payload is genuine and wasn't tampered with.

You need both because they defend against different things. The challenge stops you from accidentally registering an endpoint you don't own and confirms the URL is live. The signature stops anyone else from posting forged events to that URL once it's known. Skip the signature check and your public endpoint will trust any POST that reaches it, which is the most common webhook security mistake.

Pass the endpoint challenge

The first time you set up a webhook or flip one to active, Nylas sends a GET request to your endpoint with a challenge query parameter. Your endpoint has to return the exact value of that challenge in the body of a 200 OK response, within 10 seconds, or the webhook won't verify. It's a quick handshake that proves the URL is yours and reachable.

// Express: echo the challenge back to verify the endpoint
app.get("/webhooks/nylas", (req, res) => {
  res.status(200).send(req.query.challenge);
});

The response body must be the challenge value and nothing else, so don't wrap it in JSON or add whitespace your framework might inject. Once your endpoint passes the challenge, the webhook becomes active and starts receiving notifications. This step only runs at setup and on reactivation, so it's a handler you write once and rarely think about again, but the webhook won't deliver anything until it succeeds.

One caveat catches people on hosted tooling: some low-code or no-code endpoints don't surface the challenge query parameter to your logic at all, so you can't echo it back and the handshake can't complete automatically. If you hit that, you'll need to reach out to support rather than fight the platform, since the verification is gated on returning that exact value.

Get your webhook secret

After your endpoint passes the challenge, Nylas generates a webhook_secret for it. This secret is the signing key behind every signature you'll verify, and it's the value both sides share: the service signs each notification with it, and your endpoint uses the same secret to recompute and compare. Treat it like any other credential, stored server-side and never exposed in client code.

The secret is tied to the specific webhook, so each webhook destination has its own. You read it when you create the webhook, and you keep it somewhere your verification code can reach at request time. Because it's the only thing standing between your endpoint and forged traffic, a leaked webhook_secret is a reason to rotate, which is a one-command operation covered below.

Verify the signature on every notification

Every webhook notification includes an X-Nylas-Signature header (lowercase x-nylas-signature in some stacks), and that header is a hex-encoded HMAC-SHA256 signature of the request body, computed with your webhook_secret as the key. To verify a notification, recompute the same HMAC over the body you received and check that it matches the header. A match means the payload is genuine and unmodified; a mismatch means you drop the request.

const crypto = require("crypto");

function isGenuine(rawBody, signature, secret) {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest();
  const received = Buffer.from(signature, "hex");
  // Guard the length first: timingSafeEqual throws on a size mismatch.
  return (
    received.length === expected.length &&
    crypto.timingSafeEqual(received, expected)
  );
}

Most Nylas SDKs ship a webhook-verification helper that wraps this HMAC for you, so in application code you typically call that helper rather than hand-rolling the crypto. Knowing the mechanism still matters, because when a helper rejects a request it's almost always one of the body-handling problems below, not the helper itself.

Two details make or break this. First, sign the exact raw body you received, before any JSON parsing or reserialization, because even a reordered key or changed whitespace produces a different HMAC and the check fails. Second, compare with a constant-time function like timingSafeEqual rather than ===, so the comparison itself doesn't leak timing information an attacker could exploit. Guard the buffer lengths first, since timingSafeEqual throws on a size mismatch, which a malformed or truncated signature would otherwise trigger. Get the raw body and the constant-time compare right and the rest is a one-line HMAC.

Handle the compressed-body gotcha

Here's the detail that costs people an afternoon: Nylas can send webhook payloads compressed, and the HMAC-SHA256 signature is computed over the compressed bytes. You have to verify the signature against the raw, still-compressed request body, and only decompress after the check passes. Decompress first and the bytes you hash no longer match what was signed, so verification fails even when the request is completely genuine.

This trips up frameworks that helpfully decompress or parse the body before your handler sees it. The fix is to capture the raw request body as bytes, run the signature check on those exact bytes, and do your JSON parsing or decompression as a separate step afterward. If your verification is failing on requests you're sure are real, the body being transformed before you hash it is the first thing to check, and the compressed-bytes ordering is the usual culprit.

Test a signature with the CLI

Debugging a signature mismatch against live traffic is painful, so the CLI lets you check the math in isolation. nylas webhook verify takes a payload, a secret, and a signature, and tells you whether they match, with no server or live webhook involved. It's how I confirm whether the problem is my secret, my body handling, or something else before touching the endpoint.

nylas webhook verify \
  --payload-file ./payload.json \
  --secret <WEBHOOK_SECRET> \
  --signature <X_NYLAS_SIGNATURE>

You can pass the body inline with --payload instead of --payload-file for a quick check. Feeding it a captured payload, the real secret, and the X-Nylas-Signature value from a delivery isolates the verification step: if the CLI says it matches but your endpoint rejects the same request, the difference is in how your server reads the body, which points straight at the raw-body or compression issue.

Rotate the secret when you need to

A signing secret is a credential, and credentials sometimes need replacing, after a suspected leak, an employee offboarding, or routine hygiene. Rotating regenerates the webhook_secret for a webhook, and from that point Nylas signs with the new value. nylas webhook rotate-secret does it by webhook ID:

nylas webhook rotate-secret <webhook-id>

Plan the cutover, since notifications signed with the old secret stop verifying the moment you rotate. Update your endpoint's stored secret to the new value as part of the same change, and for a zero-downtime rotation, accept either the old or new secret for a short window while the switch propagates. Treating rotation as a deliberate step rather than an emergency is what keeps it from dropping events.

Common reasons a signature won't verify

Most verification failures aren't attacks; they're the body being changed before you hash it. When a real notification won't validate, work through a short list. Your framework may have parsed and re-serialized the JSON before your handler ran, changing the bytes. You may be decompressing the body before checking the signature instead of after. You may be using a stale secret because the webhook was rotated and your stored value wasn't updated. Or you captured the body as a parsed object rather than the raw string or bytes.

Each of these produces the same symptom, a mismatch on a request you know is genuine, which is why the raw body is the first thing to confirm. This is exactly where nylas webhook verify earns its place: feed it the captured payload, the secret, and the signature, and if they match in the CLI but fail at your endpoint, the problem is in how your server reads the request, not the secret or the signature itself. That single test splits the search space in half.

Act on a verified notification

Once a notification passes the signature check, you can trust its contents and route on them. A webhook body is a structured event with a type, like message.created or event.updated, and a data object holding the resource that changed, so your handler switches on type to decide what to do. Verifying first means that dispatch only ever runs on genuine events, never on something an attacker posted.

Acknowledge quickly and process asynchronously. Your endpoint should return a 200 fast, because a slow response can trigger retries and duplicate deliveries, so the durable pattern is to verify the signature, enqueue the event, return 200, and do the real work in a background worker. That keeps the verification path tight and the heavy lifting off the request that has to answer in seconds, and it means a burst of notifications can't back up your endpoint into timing out and looking unreachable.

Things to keep in mind

A short list of practices keeps webhook verification airtight.

  • Verify the signature on every notification. A public endpoint that skips the check trusts any POST that reaches it, which is the core webhook risk.
  • Hash the exact raw body. Sign the bytes you received before parsing; reserialized JSON produces a different HMAC and fails the check.
  • Verify before decompressing. The signature is over the compressed bytes, so check it first and decompress after.
  • Compare in constant time. Use a function like timingSafeEqual, not ===, so the comparison doesn't leak timing data.
  • Store the webhook_secret server-side. It's the key to your signatures; rotate it with nylas webhook rotate-secret if it's ever exposed.
  • Return 200 fast, work later. Verify, enqueue, and acknowledge quickly; a slow endpoint triggers retries and duplicate deliveries.

Wrapping up

Two checks make a webhook endpoint trustworthy: echo the challenge once to prove you own the URL, then verify the X-Nylas-Signature HMAC-SHA256 on every delivery to prove each payload is genuine. The traps are all about the body, hash the exact raw bytes, verify before decompressing, and compare in constant time. When a signature won't validate, nylas webhook verify lets you check the math off to the side, and nylas webhook rotate-secret handles the secret when it needs to change.

Where to go next: