-
Notifications
You must be signed in to change notification settings - Fork 272
[dev] [tofikwest] tofik/custom-domain-issue #2329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Check failure
Code scanning / CodeQL
Server-side request forgery Critical
Copilot Autofix
AI 1 day ago
General approach: ensure that any user-controlled value used in the URL of an outgoing request is either (1) strictly validated against a whitelist pattern and rejected if invalid, and/or (2) safely encoded so it cannot change the structure of the URL (e.g., cannot inject extra
/,?,#, etc.). For domains, the safest is to validate them against a DNS-hostname regex and then, when building a URL path segment, encode them withencodeURIComponentor use axios’url/paramsin a way that treats them as data, not structure.Best fix here: reuse the existing
validateDomainlogic forcheckDnsRecords(already present and called at line 903) to guarantee thatdomainis a syntactically valid DNS hostname, and then also encode thedomainwhen embedding it in the Vercel URL path. This means:checkDnsRecords; defensive coding at the sink is cheap and robust.`/v9/projects/${process.env.TRUST_PORTAL_PROJECT_ID}/domains/${domain}/verify`this.validateDomain(domain)again right before building the URL. This ensures that even ifcheckDnsRecordsis ever reused or refactored, the sink remains safe.Concretely, within
apps/api/src/trust-portal/trust-portal.service.ts, in thecheckDnsRecordsmethod near lines 1023–1038:const safeDomain = encodeURIComponent(domain);inside theif (process.env.TRUST_PORTAL_PROJECT_ID && process.env.VERCEL_TEAM_ID)block, before callingthis.vercelApi.post.safeDomaininstead ofdomainin the URL template string.this.validateDomain(domain);at the start of thatifblock as a belt-and-suspenders validation (cheap and uses existing code).No new imports or external libraries are needed;
encodeURIComponentis built-in.