Webhook signature failures for 11 minutes, twice a day: it was the clock
A merchant's webhooks failed signature checks for about 11 minutes, twice a day. The HMAC secret hadn't changed. The handler rejected any event whose timestamp differed from now by more than 5 minutes, a standard replay guard. The cause was the host clock. The VM paused during live migration and resumed roughly 6 minutes behind until chrony stepped it back. Every webhook in that window looked…
Webhook signature failures occurred for 11 minutes, twice a day, due to a clock issue. The HMAC secret remained unchanged. A standard replay guard rejected any event whose timestamp differed from the current time by more than 5 minutes. The problem arose when a virtual machine paused during live migration and resumed approximately 6 minutes behind.
This caused every webhook in the affected window to be rejected as if it came from the future, resulting in 400 errors. Some retries succeeded after the clock was corrected, while others exceeded their retry budget, causing orders to remain pending until a nightly reconciliation caught them.
To address the issue, the solution involved logging the computed skew on every rejection. Previously, the log only indicated "invalid signature," making the pattern difficult to detect until a day had passed. The tolerance for replay was expanded to 10 minutes. Additionally, alerts were set up to trigger when the skew on accepted webhooks exceeded 60 seconds.
The system now returns a 503 error response instead of a 400 for timestamp failures. This change aims to reduce the number of retries from senders when encountering 4xx errors. The root cause was determined to be the host clock, and measures were taken to prevent similar issues in the future.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to