fix: Validate twingate.host and twingate.network against trusted domains#359
Open
minhtule wants to merge 2 commits into
Open
fix: Validate twingate.host and twingate.network against trusted domains#359minhtule wants to merge 2 commits into
twingate.host and twingate.network against trusted domains#359minhtule wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/mt/parser-config-helpers #359 +/- ##
=================================================================
- Coverage 86.19% 86.16% -0.04%
=================================================================
Files 40 40
Lines 2833 2848 +15
=================================================================
+ Hits 2442 2454 +12
- Misses 265 269 +4
+ Partials 126 125 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds defensive validation around the Twingate controller trust anchor by constraining both twingate.network and twingate.host to safe DNS forms and to an explicit trusted-domain allowlist (aligned with issuer selection), including after controller redirects.
Changes:
- Validate
twingate.networkas a single DNS label to prevent authority/host injection in the JWKS URL construction. - Validate
twingate.hostas a well-formed hostname and require it to match a trusted Twingate domain (case-insensitive). - When resolving the controller host via redirect, re-validate the resolved hostname and fall back to the configured host if the redirect target is untrusted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/config/config.go | Adds network/host validation (regex + trusted-domain allowlist) and re-validates redirect-resolved hostnames before accepting them. |
| internal/config/config_test.go | Extends tests to cover invalid network values, trusted/untrusted hosts (including case-insensitive suffix matching), and redirect fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cc7da4d to
94bc480
Compare
8b48cf7 to
f9631bc
Compare
twingate.host and twingate.network against trusted domains
409edde to
5bd5661
Compare
…ains - Validate twingate.network is a single DNS label and twingate.host is a well-formed hostname restricted to trusted Twingate domains; match case-insensitively. - Re-validate the resolved host after redirect, keeping the configured host if untrusted.
f9631bc to
26ecc25
Compare
clement0010
reviewed
Jul 1, 2026
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.
Related Tickets & Documents
configpackage #358; review/merge that first.Changes
twingate.networkis a single DNS label, since it is interpolated into the JWKS URL authority.twingate.hostagainst the trusted Twingate domains, matched case-insensitively, using the same allowlist as token issuer validation so an accepted host always has a known JWT issuer.