fix: require Segment identify webhook secret#33
Open
BunsDev wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the inbound Segment identify webhook path to prevent unauthenticated requests from mutating user metadata, specifically when the integration lacks an incomingSecret.
Changes:
- Require a non-empty
incomingSecretfor inbound Segment identify handling and return401when missing. - Always enforce
x-signatureHMAC-SHA1 validation (usingtimingSafeEqual) before JSON parsing / trusting payload fields. - Add unit tests covering missing-secret rejection and valid signed acceptance for
segmentUserSync.handleIdentify.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/web/src/lib/server/integrations/segment/user-sync.ts | Enforces mandatory incomingSecret and signature verification for inbound identify requests. |
| apps/web/src/lib/server/integrations/segment/tests/user-sync.test.ts | Adds regression tests for the inbound identify signature/secret requirements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ffe197e to
4d3ea8d
Compare
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.
Motivation
identifywebhooks from mutating user metadata when an integration has noincomingSecretconfigured, which allowed attackers to overwrite attributes by supplying forged identifies.Description
incomingSecretinsegmentUserSync.handleIdentifyand return401when missing to block unsigned requests before parsing the body.x-signatureHMAC-SHA1 header usingcreateHmacandtimingSafeEqualbefore trusting payload fields.apps/web/src/lib/server/integrations/segment/__tests__/user-sync.test.ts.Testing
bunx prettier --writeand verifiedgit diff --checksucceeded.apps/web/src/lib/server/integrations/segment/__tests__/user-sync.test.ts, but runningvitestin this environment was blocked due to registry/dependency resolution errors (npm returned403) so tests could not be executed here.fix: require Segment identify webhook secretand recommend running CI (bun run test) to execute the new tests in the normal developer environment or CI where dependencies are available.Codex Task