Verify the VAPI webhook, so a forged transcript is refused - #5
Merged
Merged
Conversation
The bridge took any POST. A customer's webhook is a public URL, so anyone who learned it could post a transcript that was never said and have it become a real call, a real analysis and a real finding in their organization. A forged end-of-call-report could also end a real call's session early. VAPI already sends server.secret back in X-Vapi-Secret on every request. A `secret` argument now turns that into a check: pass the request headers to handle, and a request without it raises WebhookVerificationError before a turn is appended or a session is created. hmac.compare_digest for the compare. The header is read case-insensitively, since Starlette hands over a case-insensitive mapping and a plain dict is also a reasonable thing for a caller to pass. Verification is off when no secret is configured, so an existing integration keeps working, and the README and module docstring both say what that costs. Mirrors deeptrust-ai/deeptrust-typescript#3, so the two SDKs refuse the same request for the same reason. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Devin Review found 1 potential issue.
1 bug not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| dt: DeepTrust, | ||
| *, | ||
| api_key: str, | ||
| secret: str | None = None, |
Contributor
sahajgandhi-deeptrust
approved these changes
Sep 15, 2026
buildbyjithu
changed the base branch from
devin/1789240942-vapi-bridge
to
main
September 15, 2026 18:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes ENG-3544 for Python. Stacked on #4, which adds the bridge this verifies. Mirrors deeptrust-ai/deeptrust-typescript#3.
Summary
The bridge took any POST. A customer's webhook is a public URL, so anyone who learned it could post a
transcriptevent for a call that never happened, or words never said in one that did, and have it become a real call, a real analysis and a real finding in their DeepTrust organization. A forgedend-of-call-reportcould also end a real call's session early.VAPI already sends
server.secretback inX-Vapi-Secreton every request. This turns that into a check.A request that does not carry it raises
WebhookVerificationErrorbefore a turn is appended or a session is created.Choices
hmac.compare_digestfor the compare, so a caller cannot learn the secret one character at a time from how long the refusal took.Testing
just checkclean: ruff, ruff format, mypy, 42 tests passing, 5 of them new.The new ones cover a request without the secret refused with nothing recorded (no analyze call, no session), a wrong secret refused, the right secret accepted and returning an analysis, no configured secret keeping existing behaviour, and the header read case-insensitively.
Parity note
The TypeScript version hand-rolls its constant-time compare because that module has to run on Node, Bun, Deno and the edge, where
crypto.timingSafeEqualis Node-only. Python hashmac.compare_digestin the standard library, so this uses it. Same behaviour, same refusal, same header.🤖 Generated with Claude Code