fix(core): enforce https on custom proxy/cdnproxy urls#1300
Open
sunitaprajapati89 wants to merge 1 commit into
Open
fix(core): enforce https on custom proxy/cdnproxy urls#1300sunitaprajapati89 wants to merge 1 commit into
sunitaprajapati89 wants to merge 1 commit into
Conversation
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.
Task:
Enforce HTTPS on custom proxy/cdnProxy URLs (write key sent over cleartext) ·
packages/core/src/util.ts:261-288(getURL/validateURL), consumed atSegmentDestination.ts:388andanalytics.ts:383.getURL()only upgrades tohttps://when the host has no scheme. An explicithttp://proxy/cdnProxy is preserved, andvalidateURL's regex allowshttps?://.uploadEvents()then POSTs{ batch, sentAt, writeKey }— write key and all event PII — in cleartext to that host, exposed to on-path attackers. Default hosts are https, so this only bites with a misconfigured custom proxy, but the SDK permits the downgrade silently.http://proxy/cdnProxy unless an explicitallowInsecureProxyopt-in is set. At minimum log a loud warning. Document that the write key + PII travel in the body.What changes are done:
-
[packages/core/src/util.ts]— getURL now throws on http:// unless allowInsecure=true is passed; logs a console.warn when the opt-in is used-
[packages/core/src/types.ts]— added allowInsecureProxy?: boolean to Config with a doc comment explaining the risk-
[packages/core/src/analytics.ts]— passes this.config.allowInsecureProxy to getURL for the CDN proxy path-
[packages/core/src/plugins/SegmentDestination.ts]— passes config?.allowInsecureProxy to getURL for the upload proxy path-
[packages/core/src/tests/util.test.ts]— two new tests covering the rejection and opt-in paths