Skip to content

Commit 5dbf4a4

Browse files
authored
Enforce https if requested with protocol or in cmdline option (keybase#13613)
* Enforce https if requested with protocol or in cmdline option (keybase#13613)
1 parent 7c48263 commit 5dbf4a4

16 files changed

Lines changed: 712 additions & 17 deletions

File tree

‎go/externals/proof_checkers.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ func getStaticProofServices() []libkb.ServiceType {
1414
RedditServiceType{},
1515
TwitterServiceType{},
1616
WebServiceType{},
17+
WebServiceType{scheme: "http"},
18+
WebServiceType{scheme: "https"},
1719
}
1820
return append(services, getBuildSpecificStaticProofServices()...)
1921
}

‎go/externals/proof_service_web.go‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,17 @@ func (rc *WebChecker) CheckStatus(m libkb.MetaContext, h libkb.SigHint, pcm libk
5252
//
5353
//=============================================================================
5454

55-
type WebServiceType struct{ libkb.BaseServiceType }
55+
type WebServiceType struct {
56+
libkb.BaseServiceType
57+
scheme string
58+
}
5659

57-
func (t WebServiceType) AllStringKeys() []string { return []string{"web", "http", "https"} }
58-
func (t WebServiceType) PrimaryStringKeys() []string { return []string{"https", "http"} }
60+
func (t WebServiceType) AllStringKeys() []string {
61+
if t.scheme == "" {
62+
return []string{"web"}
63+
}
64+
return []string{t.scheme}
65+
}
5966

6067
func (t WebServiceType) NormalizeUsername(s string) (ret string, err error) {
6168
// The username is just the (lowercased) hostname.
@@ -103,7 +110,14 @@ func (t WebServiceType) NormalizeRemoteName(m libkb.MetaContext, s string) (ret
103110
err = libkb.NewWebUnreachableError(host)
104111
return
105112
}
106-
if len(prot) > 0 && prot == "https" && found != "https:" {
113+
if len(t.scheme) > 0 && len(prot) > 0 && prot != t.scheme {
114+
msg := fmt.Sprintf("You tried to prove ownership of %s over %s but gave a %s link.", host, t.scheme, prot)
115+
err = libkb.NewProtocolSchemeMismatch(msg)
116+
return
117+
}
118+
protocolAssertsHTTPS := prot == "https"
119+
proofTypeAssertsHTTPS := t.scheme == "https"
120+
if (protocolAssertsHTTPS || proofTypeAssertsHTTPS) && found != "https:" {
107121
msg := fmt.Sprintf("You specified HTTPS for %s but only HTTP is available", host)
108122
err = libkb.NewProtocolDowngradeError(msg)
109123
return
@@ -176,3 +190,5 @@ func (t WebServiceType) LastWriterWins() bool { return false }
176190
func (t WebServiceType) MakeProofChecker(l libkb.RemoteProofChainLink) libkb.ProofChecker {
177191
return &WebChecker{l}
178192
}
193+
194+
//=============================================================================

‎go/libkb/errors.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,18 @@ func NewWebUnreachableError(h string) WebUnreachableError {
666666

667667
//=============================================================================
668668

669+
type ProtocolSchemeMismatch struct {
670+
msg string
671+
}
672+
673+
func (h ProtocolSchemeMismatch) Error() string {
674+
return h.msg
675+
}
676+
func NewProtocolSchemeMismatch(msg string) ProtocolSchemeMismatch {
677+
return ProtocolSchemeMismatch{msg: msg}
678+
}
679+
680+
//=============================================================================
669681
type ProtocolDowngradeError struct {
670682
msg string
671683
}

‎shared/actions/profile/proofs.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function _addProof(action: ProfileGen.AddProofPayload) {
7474
// flow needs this for some reason
7575
case 'http':
7676
case 'https':
77+
case 'web':
7778
case 'twitter':
7879
case 'facebook':
7980
case 'reddit':

‎shared/common-adapters/platform-icon.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function _specsForMobileOrDesktop() {
3333
dns: {icon: isMobile ? 'icon-website-64' : 'icon-website-48'},
3434
http: {icon: isMobile ? 'icon-website-64' : 'icon-website-48'},
3535
https: {icon: isMobile ? 'icon-website-64' : 'icon-website-48'},
36+
web: {icon: isMobile ? 'icon-website-64' : 'icon-website-48'},
3637
dnsOrGenericWebSite: {icon: isMobile ? 'icon-website-64' : 'icon-website-48'},
3738
rooter: {icon: isMobile ? 'icon-website-64' : 'icon-website-48'},
3839
btc: {icon: isMobile ? 'icon-bitcoin-logo-64' : 'icon-bitcoin-logo-48'},

‎shared/common-adapters/user-proofs.shared.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function iconNameForProof({type}: {type: PlatformsExpandedType}): IconType {
8080
dnsOrGenericWebSite: 'iconfont-identity-website',
8181
http: 'iconfont-identity-website',
8282
https: 'iconfont-identity-website',
83+
web: 'iconfont-identity-website',
8384
dns: 'iconfont-identity-website',
8485
}
8586

‎shared/constants/types/more.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const provablePlatformsMap = {
99
dns: true,
1010
http: true,
1111
https: true,
12+
web: true,
1213
rooter: __DEV__,
1314
}
1415

@@ -22,6 +23,7 @@ const platformsExpandedMap = {
2223
dns: true,
2324
http: true,
2425
https: true,
26+
web: true,
2527
rooter: __DEV__,
2628
btc: true,
2729
zcash: true,

‎shared/profile/confirm-or-pending/shared.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export function propsForPlatform(props: Props): Object {
7272
} doesn't load over https. If you get a real SSL certificate (not self-signed) in the future, please replace this proof with a fresh one.`,
7373
}
7474
case 'https':
75+
case 'web':
7576
return {
7677
...commonConfirm(props),
7778
}

‎shared/profile/post-proof/shared.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export function propsForPlatform(props: Props): MoreProps {
114114
}
115115
case 'http':
116116
case 'https':
117-
const root = `${props.platform}://${props.platformUserName}`
117+
case 'web':
118+
const root = props.platformUserName
118119
const [urlRoot, urlWellKnown] = ['/keybase.txt', '/.well-known/keybase.txt'].map(file => root + file)
119120

120121
return {

‎shared/profile/prove-enter-username/index.stories.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const load = () => {
3434
.add('Bitcoin', () => <ProveEnterUsername {...props} platform="btc" />)
3535
.add('Bitcoin Disabled', () => <ProveEnterUsername {...props} platform="btc" canContinue={false} />)
3636
.add('DNS', () => <ProveEnterUsername {...props} platform="dns" />)
37-
.add('Website', () => <ProveEnterUsername {...props} platform="http" />)
37+
.add('HTTP', () => <ProveEnterUsername {...props} platform="http" />)
38+
.add('HTTPS', () => <ProveEnterUsername {...props} platform="https" />)
39+
.add('Website', () => <ProveEnterUsername {...props} platform="web" />)
3840
.add('Zcash', () => <ProveEnterUsername {...props} platform="zcash" />)
3941
}
4042

0 commit comments

Comments
 (0)