Repository navigation
Fix transport api recipient.go - #174
Open
lamtrinhdev wants to merge 2 commits into
Open
lamtrinhdev wants to merge 2 commits into
lamtrinhdev wants to merge 2 commits into
Conversation
Added isOwnDomain function to check for exact domain matches in a case-insensitive manner.
Contributor
Author
|
Dear @jurajhilje , I have a small fix, when you have time, please help me to review it. Thanks, |
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.
PR type
What kind of change does this PR introduce?
Description
Both the recipient and alias handlers checked service domains with
strings.Contains(h.Cfg.Domains, domain), which matches substrings, notdomains. Two visible consequences:
DOMAINS=ivpn.net, adding a recipient likefoo@vpn.netfails with "Selected domain is invalid." becausevpn.nethappens to be a substring of
ivpn.net.strings.Containsis case-sensitive, sofoo@IVPN.NETslippedpast the recipient check, and in
resolveDomainany alias domain thatmerely contained a service domain as a substring was accepted
(e.g.
foo@ivpn.net.attacker.com).Fix
Added a small
isOwnDomainhelper that splits theDOMAINSconfig on commasand compares with
strings.EqualFold(plus TrimSpace, so stray whitespace inthe env var doesn't break matching). Both call sites now use it:
PostRecipientblocks recipients only on exact service-domain matchesresolveDomainaccepts built-in alias domains only on exact matchesAlso switched the recipient handler to use the last
@-separated segmentinstead of index
[1], so a malformeda@b@c.comchecks the actual domainrather than
b.